aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2007-07-23 14:49:36 +0000
committerAvatar Mike Kelly <pioto@pioto.org> 2007-07-23 14:49:36 +0000
commit045b80de9ce8a16fbf88c915406f5e4613f5b256 (patch)
tree84622f4bd64e2c732c5fed4fd991a2914e585b7e
parent8b176385595af3afdc95e6c281d2e6ad1463a343 (diff)
downloadpaludis-045b80de9ce8a16fbf88c915406f5e4613f5b256.tar.gz
paludis-045b80de9ce8a16fbf88c915406f5e4613f5b256.tar.xz
Improved Manifest2. Fixes ticket:253
-rw-r--r--paludis/repositories/e/e_repository.cc149
-rw-r--r--paludis/repositories/e/e_repository_entries.hh6
-rw-r--r--paludis/repositories/e/ebin_entries.cc9
-rw-r--r--paludis/repositories/e/ebin_entries.hh2
-rw-r--r--paludis/repositories/e/ebuild_entries.cc11
-rw-r--r--paludis/repositories/e/ebuild_entries.hh2
-rw-r--r--paludis/repositories/e/exheres_layout.cc55
-rw-r--r--paludis/repositories/e/exheres_layout.hh3
-rw-r--r--paludis/repositories/e/layout.cc3
-rw-r--r--paludis/repositories/e/layout.hh4
-rw-r--r--paludis/repositories/e/traditional_layout.cc55
-rw-r--r--paludis/repositories/e/traditional_layout.hh3
12 files changed, 210 insertions, 92 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index dd43982..219a20a 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -58,6 +58,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/map.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
@@ -1049,64 +1050,75 @@ ERepository::do_some_ids_might_support_action(const SupportsActionTestBase & a)
void
ERepository::make_manifest(const QualifiedPackageName & qpn)
{
- if (_imp->params.layout == "traditional")
+ FSEntry package_dir = _imp->layout->package_directory(qpn);
+
+ FSEntry(package_dir / "Manifest").unlink();
+ std::ofstream manifest(stringify(FSEntry(package_dir
+ / "Manifest")).c_str());
+ if (! manifest)
+ throw ERepositoryConfigurationError("Couldn't open Manifest for writing.");
+
+ tr1::shared_ptr<Map<FSEntry, std::string> > files = _imp->layout->manifest_files(qpn);
+
+ for (Map<FSEntry, std::string>::Iterator f(files->begin()) ;
+ f != files->end() ; ++f)
{
- FSEntry package_dir = _imp->layout->package_directory(qpn);
-
- FSEntry(package_dir / "Manifest").unlink();
- std::ofstream manifest(stringify(FSEntry(package_dir
- / "Manifest")).c_str());
- if (! manifest)
- throw ERepositoryConfigurationError("Couldn't open Manifest for writing.");
-
- std::list<FSEntry> package_files((DirIterator(package_dir)),
- DirIterator());
- for (std::list<FSEntry>::iterator f(package_files.begin()) ;
- f != package_files.end() ; ++f)
+ FSEntry file(f->first);
+ std::string filename = file.basename();
+ std::string file_type(f->second);
+
+ if ("AUX" == file_type)
{
- std::string filename(stringify(*f));
- std::string file_type("MISC");
+ filename = stringify(file).substr(stringify(package_dir / "files").length()+1);
+ }
- if (! (*f).is_regular_file() || ((*f).basename() == "Manifest") )
- continue;
- if (is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
- file_type="EBUILD";
+ std::ifstream file_stream(stringify(file).c_str());
+ if (! file_stream)
+ throw ERepositoryConfigurationError("Couldn't read "
+ + stringify(file));
- std::ifstream file_stream(filename.c_str());
- if (! file_stream)
- throw ERepositoryConfigurationError("Couldn't read "+filename);
+ RMD160 rmd160sum(file_stream);
+ manifest << file_type << " " << filename << " "
+ << file.file_size() << " RMD160 " << rmd160sum.hexsum();
- RMD160 rmd160sum(file_stream);
- manifest << file_type << " " << (*f).basename() << " "
- << (*f).file_size()
- << " RMD160 " << rmd160sum.hexsum();
+ file_stream.clear();
+ file_stream.seekg(0, std::ios::beg);
+ SHA256 sha256sum(file_stream);
+ manifest << " SHA256 " << sha256sum.hexsum() << std::endl;
+ }
- file_stream.clear();
- file_stream.seekg(0, std::ios::beg);
- SHA256 sha256sum(file_stream);
- manifest << " SHA256 " << sha256sum.hexsum()
- << std::endl;
- }
+ tr1::shared_ptr<const PackageIDSequence> versions;
+ versions = package_ids(qpn);
- std::list<FSEntry> files_files((DirIterator(package_dir / "files")),
- DirIterator());
- for (std::list<FSEntry>::iterator f(files_files.begin()) ;
- f != files_files.end() ; ++f)
- {
- std::string filename(stringify(*f));
+ std::set<std::string> done_files;
+
+ for (PackageIDSequence::Iterator v(versions->begin()),
+ v_end(versions->end()) ;
+ v != v_end ; ++v)
+ {
+ tr1::shared_ptr<const PackageID> id = (*v);
+ if (! id->src_uri_key())
+ continue;
+ paludis::erepository::AAVisitor aa;
+ id->src_uri_key()->value()->accept(aa);
- if (is_file_with_prefix_extension(*f,
- ("digest-"+stringify(qpn.package)), "",
- IsFileWithOptions()))
+ for (paludis::erepository::AAVisitor::Iterator d(aa.begin()) ;
+ d != aa.end() ; ++d)
+ {
+ if (done_files.count(*d))
continue;
+ done_files.insert(*d);
- std::ifstream file_stream(filename.c_str());
+ FSEntry f(params().distdir / *d);
+
+ std::ifstream file_stream(stringify(f).c_str());
if (! file_stream)
- throw ERepositoryConfigurationError("Couldn't read "+filename);
+ throw ERepositoryConfigurationError("Couldn't read "
+ + stringify(f));
RMD160 rmd160sum(file_stream);
- manifest << "AUX " << (*f).basename() << " "
- << (*f).file_size()
+ manifest << "DIST " << f.basename() << " "
+ << f.file_size()
<< " RMD160 " << rmd160sum.hexsum();
file_stream.clear();
@@ -1115,54 +1127,7 @@ ERepository::make_manifest(const QualifiedPackageName & qpn)
manifest << " SHA256 " << sha256sum.hexsum()
<< std::endl;
}
-
- tr1::shared_ptr<const PackageIDSequence> versions;
- versions = package_ids(qpn);
-
- std::set<std::string> done_files;
-
- for (PackageIDSequence::Iterator v(versions->begin()),
- v_end(versions->end()) ;
- v != v_end ; ++v)
- {
- tr1::shared_ptr<const PackageID> id = (*v);
- if (! id->src_uri_key())
- continue;
- paludis::erepository::AAVisitor aa;
- id->src_uri_key()->value()->accept(aa);
-
- for (paludis::erepository::AAVisitor::Iterator d(aa.begin()) ;
- d != aa.end() ; ++d)
- {
- if (done_files.count(*d))
- continue;
- done_files.insert(*d);
-
- FSEntry f(params().distdir / *d);
-
- std::ifstream file_stream(stringify(f).c_str());
- if (! file_stream)
- throw ERepositoryConfigurationError("Couldn't read "
- +stringify(f));
-
- RMD160 rmd160sum(file_stream);
- manifest << "DIST " << f.basename() << " "
- << f.file_size()
- << " RMD160 " << rmd160sum.hexsum();
-
- file_stream.clear();
- file_stream.seekg(0, std::ios::beg);
- SHA256 sha256sum(file_stream);
- manifest << " SHA256 " << sha256sum.hexsum()
- << std::endl;
- }
- }
-
- return;
}
- throw InternalError(PALUDIS_HERE,
- "Manifest creation not supported for \""
- +_imp->params.layout+"\" layout.");
}
std::string
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 8cc82af..8eb719f 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -97,6 +97,12 @@ namespace paludis
* Handle a merge.
*/
virtual void merge(const MergeOptions &) = 0;
+
+ /**
+ * Gives the Manifest key for a given package file (for
+ * example, "EBUILD").
+ */
+ virtual std::string get_package_file_manifest_key(const FSEntry &, const QualifiedPackageName &) const = 0;
};
/**
diff --git a/paludis/repositories/e/ebin_entries.cc b/paludis/repositories/e/ebin_entries.cc
index 8454619..d706686 100644
--- a/paludis/repositories/e/ebin_entries.cc
+++ b/paludis/repositories/e/ebin_entries.cc
@@ -467,5 +467,14 @@ EbinEntries::pretend(const QualifiedPackageName &, const VersionSpec &,
{
return true;
}
+
+std::string
+EbinEntries::get_package_file_manifest_key(const FSEntry & f, const QualifiedPackageName & q) const
+{
+ if (is_package_file(q, f)
+ return "EBIN";
+ return "";
+}
+
#endif
diff --git a/paludis/repositories/e/ebin_entries.hh b/paludis/repositories/e/ebin_entries.hh
index 6e897e8..db4c4a9 100644
--- a/paludis/repositories/e/ebin_entries.hh
+++ b/paludis/repositories/e/ebin_entries.hh
@@ -72,6 +72,8 @@ namespace paludis
tr1::shared_ptr<const ERepositoryProfile>) const;
virtual void merge(const MergeOptions &);
+
+ virtual std::string get_package_file_manifest_key(const FSEntry &, const QualifiedPackageName &) const;
};
}
}
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 714eb06..302e366 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -692,3 +692,14 @@ EbuildEntries::pretend(const tr1::shared_ptr<const ERepositoryID> & id,
return true;
}
+std::string
+EbuildEntries::get_package_file_manifest_key(const FSEntry & f, const QualifiedPackageName & q) const
+{
+ if (! is_package_file(q, f))
+ return "";
+ if (is_file_with_prefix_extension(f, stringify(q.package) + "-", ".ebuild", IsFileWithOptions()))
+ return "EBUILD";
+ else
+ return "EXHERES";
+}
+
diff --git a/paludis/repositories/e/ebuild_entries.hh b/paludis/repositories/e/ebuild_entries.hh
index c25f5d1..840726d 100644
--- a/paludis/repositories/e/ebuild_entries.hh
+++ b/paludis/repositories/e/ebuild_entries.hh
@@ -84,6 +84,8 @@ namespace paludis
virtual bool pretend(const tr1::shared_ptr<const ERepositoryID> &,
tr1::shared_ptr<const ERepositoryProfile>) const;
+
+ virtual std::string get_package_file_manifest_key(const FSEntry &, const QualifiedPackageName &) const;
};
}
}
diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc
index ca15bac..391e3fe 100644
--- a/paludis/repositories/e/exheres_layout.cc
+++ b/paludis/repositories/e/exheres_layout.cc
@@ -30,6 +30,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/map.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/is_file_with_extension.hh>
@@ -461,3 +462,57 @@ ExheresLayout::exlibsdirs(const QualifiedPackageName & q) const
return result;
}
+namespace
+{
+ void aux_files_helper(const FSEntry & d,
+ tr1::shared_ptr<Map<FSEntry, std::string> > & m,
+ const QualifiedPackageName & qpn)
+ {
+ std::list<FSEntry> files((DirIterator(d)),
+ DirIterator());
+ for (std::list<FSEntry>::iterator f(files.begin()) ;
+ f != files.end() ; ++f)
+ {
+ if (f->is_directory())
+ {
+ aux_files_helper((*f), m, qpn);
+ }
+ else
+ {
+ if (! f->is_regular_file())
+ continue;
+ if (is_file_with_prefix_extension((*f),
+ ("digest-"+stringify(qpn.package)), "",
+ IsFileWithOptions()))
+ continue;
+ m->insert((*f), "AUX");
+ }
+ }
+ }
+}
+
+tr1::shared_ptr<Map<FSEntry, std::string> >
+ExheresLayout::manifest_files(const QualifiedPackageName & qpn) const
+{
+ tr1::shared_ptr<Map<FSEntry, std::string> > result(new Map<FSEntry, std::string>);
+ FSEntry package_dir = _imp->repository->layout()->package_directory(qpn);
+
+ std::list<FSEntry> package_files((DirIterator(package_dir)),
+ DirIterator());
+ for (std::list<FSEntry>::iterator f(package_files.begin()) ;
+ f != package_files.end() ; ++f)
+ {
+ if (! (*f).is_regular_file() || ((*f).basename() == "Manifest") )
+ continue;
+
+ std::string file_type("MISC");
+ if (_imp->entries->is_package_file(qpn, (*f)))
+ file_type=_imp->entries->get_package_file_manifest_key((*f), qpn);
+
+ result->insert((*f), file_type);
+ }
+
+ aux_files_helper((package_dir / "files"), result, qpn);
+
+ return result;
+}
diff --git a/paludis/repositories/e/exheres_layout.hh b/paludis/repositories/e/exheres_layout.hh
index 3c3b9fd..e8edc6c 100644
--- a/paludis/repositories/e/exheres_layout.hh
+++ b/paludis/repositories/e/exheres_layout.hh
@@ -110,6 +110,9 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const FSEntrySequence> exlibsdirs(const QualifiedPackageName &) const;
+
+ virtual tr1::shared_ptr<Map<FSEntry, std::string> > manifest_files(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/repositories/e/layout.cc b/paludis/repositories/e/layout.cc
index b19f442..d98c64e 100644
--- a/paludis/repositories/e/layout.cc
+++ b/paludis/repositories/e/layout.cc
@@ -24,6 +24,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/map-impl.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -36,6 +37,8 @@ template class VirtualConstructor<std::string,
template class InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>;
+template class Map<FSEntry, std::string>;
+
Layout::Layout(tr1::shared_ptr<const FSEntry> l) :
_master_repository_location(l)
{
diff --git a/paludis/repositories/e/layout.hh b/paludis/repositories/e/layout.hh
index 30e6f00..356f041 100644
--- a/paludis/repositories/e/layout.hh
+++ b/paludis/repositories/e/layout.hh
@@ -29,6 +29,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/map-fwd.hh>
namespace paludis
{
@@ -131,6 +132,9 @@ namespace paludis
virtual tr1::shared_ptr<const FSEntrySequence> exlibsdirs(const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual tr1::shared_ptr<Map<FSEntry, std::string> > manifest_files(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
///\}
};
diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc
index 2b5a0b2..099dbe2 100644
--- a/paludis/repositories/e/traditional_layout.cc
+++ b/paludis/repositories/e/traditional_layout.cc
@@ -32,6 +32,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/iterator.hh>
+#include <paludis/util/map.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/mutex.hh>
@@ -480,3 +481,57 @@ TraditionalLayout::exlibsdirs(const QualifiedPackageName & q) const
return result;
}
+namespace
+{
+ void aux_files_helper(const FSEntry & d,
+ tr1::shared_ptr<Map<FSEntry, std::string> > & m,
+ const QualifiedPackageName & qpn)
+ {
+ std::list<FSEntry> files((DirIterator(d)),
+ DirIterator());
+ for (std::list<FSEntry>::iterator f(files.begin()) ;
+ f != files.end() ; ++f)
+ {
+ if (f->is_directory())
+ {
+ aux_files_helper((*f), m, qpn);
+ }
+ else
+ {
+ if (! f->is_regular_file())
+ continue;
+ if (is_file_with_prefix_extension((*f),
+ ("digest-"+stringify(qpn.package)), "",
+ IsFileWithOptions()))
+ continue;
+ m->insert((*f), "AUX");
+ }
+ }
+ }
+}
+
+tr1::shared_ptr<Map<FSEntry, std::string> >
+TraditionalLayout::manifest_files(const QualifiedPackageName & qpn) const
+{
+ tr1::shared_ptr<Map<FSEntry, std::string> > result(new Map<FSEntry, std::string>);
+ FSEntry package_dir = _imp->repository->layout()->package_directory(qpn);
+
+ std::list<FSEntry> package_files((DirIterator(package_dir)),
+ DirIterator());
+ for (std::list<FSEntry>::iterator f(package_files.begin()) ;
+ f != package_files.end() ; ++f)
+ {
+ if (! (*f).is_regular_file() || ((*f).basename() == "Manifest") )
+ continue;
+
+ std::string file_type("MISC");
+ if (_imp->entries->is_package_file(qpn, (*f)))
+ file_type=_imp->entries->get_package_file_manifest_key((*f), qpn);
+
+ result->insert((*f), file_type);
+ }
+
+ aux_files_helper((package_dir / "files"), result, qpn);
+
+ return result;
+}
diff --git a/paludis/repositories/e/traditional_layout.hh b/paludis/repositories/e/traditional_layout.hh
index 6f208df..8427b63 100644
--- a/paludis/repositories/e/traditional_layout.hh
+++ b/paludis/repositories/e/traditional_layout.hh
@@ -112,6 +112,9 @@ namespace paludis
virtual tr1::shared_ptr<const FSEntrySequence> exlibsdirs(const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<Map<FSEntry, std::string> > manifest_files(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}