aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2007-07-20 18:59:52 +0000
committerAvatar Mike Kelly <pioto@pioto.org> 2007-07-20 18:59:52 +0000
commit682d3f97e3c3986e8e3782842be20c7d021d863e (patch)
treedf4e26d8467eb8b91a7fb4278e807eee0027fc0c
parent4492d8e14c41bf723c5945d0c009853853992a21 (diff)
downloadpaludis-682d3f97e3c3986e8e3782842be20c7d021d863e.tar.gz
paludis-682d3f97e3c3986e8e3782842be20c7d021d863e.tar.xz
MANIFEST 2 !!!!!
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc3
-rw-r--r--paludis/repositories/cran/cran_repository.cc3
-rw-r--r--paludis/repositories/e/e_repository.cc132
-rw-r--r--paludis/repositories/e/e_repository.hh4
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc41
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh49
-rw-r--r--paludis/repositories/e/vdb_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_repository.cc3
-rw-r--r--paludis/repositories/gems/gems_repository.cc3
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc3
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc3
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc3
-rw-r--r--paludis/repository-fwd.hh1
-rw-r--r--paludis/repository.cc4
-rw-r--r--paludis/repository.hh19
-rw-r--r--paludis/repository.sr1
17 files changed, 268 insertions, 10 deletions
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 0c0158c..eb0ecae 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -169,7 +169,8 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.qa_interface(0)
.make_virtuals_interface(0)
.pretend_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"cran_installed"),
PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
{
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index bfed041..2ad11a1 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -112,7 +112,8 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.e_interface(0)
.pretend_interface(0)
.qa_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"cran"),
PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p))
{
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index b7474c1..e01afda 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -20,6 +20,8 @@
#include "config.h"
+#include <paludis/repositories/e/aa_visitor.hh>
+#include <paludis/repositories/e/e_key.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_news.hh>
@@ -61,6 +63,12 @@
#include <paludis/util/set.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+
+#include <paludis/digests/md5.hh>
+#include <paludis/digests/rmd160.hh>
+#include <paludis/digests/sha256.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -71,6 +79,8 @@
#include <algorithm>
#include <vector>
#include <list>
+#include <iostream>
+#include <fstream>
#include <strings.h>
#include <ctype.h>
@@ -285,7 +295,8 @@ ERepository::ERepository(const ERepositoryParams & p) :
#else
.qa_interface(0)
#endif
- .hook_interface(this),
+ .hook_interface(this)
+ .manifest_interface(this),
p.entry_format),
PrivateImplementationPattern<ERepository>(new Implementation<ERepository>(this, p))
{
@@ -1036,6 +1047,125 @@ ERepository::do_some_ids_might_support_action(const SupportsActionTestBase & a)
return q.result;
}
+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.");
+
+ std::list<FSEntry> package_files((DirIterator(package_dir)),
+ DirIterator());
+ for (std::list<FSEntry>::iterator f(package_files.begin()) ;
+ f != package_files.end() ; ++f)
+ {
+ std::string filename(stringify(*f));
+ std::string file_type("MISC");
+
+ if (! (*f).is_regular_file() || ((*f).basename() == "Manifest") )
+ continue;
+ if (is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
+ file_type="EBUILD";
+
+ std::ifstream file_stream(filename.c_str());
+ if (! file_stream)
+ throw ERepositoryConfigurationError("Couldn't read "+filename);
+
+ 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;
+ }
+
+ 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));
+
+ if (is_file_with_prefix_extension(*f,
+ ("digest-"+stringify(qpn.package)), "",
+ IsFileWithOptions()))
+ continue;
+
+ std::ifstream file_stream(filename.c_str());
+ if (! file_stream)
+ throw ERepositoryConfigurationError("Couldn't read "+filename);
+
+ RMD160 rmd160sum(file_stream);
+ manifest << "AUX " << (*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;
+ }
+
+ 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
ERepository::accept_keywords_variable() const
{
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 8ea0c92..7ca800f 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -61,6 +61,7 @@ namespace paludis
public RepositoryEInterface,
public RepositoryHookInterface,
public RepositoryQAInterface,
+ public RepositoryManifestInterface,
public tr1::enable_shared_from_this<ERepository>,
private PrivateImplementationPattern<ERepository>
{
@@ -190,6 +191,9 @@ namespace paludis
const FSEntry &
) const;
+ /* RepositoryManifestInterface */
+ virtual void make_manifest(const QualifiedPackageName & qpn);
+
///\name Information about ERepository
///\{
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index d4804f6..8193d3f 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -36,6 +36,10 @@
#include <test/test_framework.hh>
#include <test/test_runner.hh>
+#include <set>
+#include <fstream>
+#include <string>
+
using namespace test;
using namespace paludis;
@@ -660,5 +664,42 @@ namespace test_cases
}
}
} test_e_repository_query_profile_masks;
+
+ /**
+ * \test Test ERepository Manifest2 generation.
+ *
+ */
+ struct ERepositoryManifestTest : TestCase
+ {
+ ERepositoryManifestTest() : TestCase("manifest2") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<Map<std::string, std::string> > keys(
+ new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "e_repository_TEST_dir/repo11");
+ keys->insert("profiles", "e_repository_TEST_dir/repo11/profiles/profile");
+ tr1::shared_ptr<ERepository> repo(make_ebuild_repository(
+ &env, keys));
+ repo->make_manifest(QualifiedPackageName("category/package"));
+
+ std::multiset<std::string> made_manifest, reference_manifest;
+ std::ifstream made_manifest_stream("e_repository_TEST_dir/repo11/category/package/Manifest"),
+ reference_manifest_stream("e_repository_TEST_dir/repo11/Manifest_correct");
+
+ std::string line;
+
+ while ( getline(made_manifest_stream, line) )
+ made_manifest.insert(line);
+ while ( getline(reference_manifest_stream, line) )
+ reference_manifest.insert(line);
+
+ TEST_CHECK(made_manifest == reference_manifest);
+ }
+ } test_e_repository_manifest;
+
}
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 8b10040..3b65f7e 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -246,3 +246,52 @@ cat <<END > cat/was_masked/was_masked-0.ebuild
END
cd ..
+mkdir -p repo11/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo11/category/package/files || exit 1
+cd repo11 || exit 1
+echo "test-repo-11" >> profiles/repo_name || exit 1
+echo "category" >> profiles/categories || exit 1
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > category/package/package-1.ebuild || exit 1
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI="foo"
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > category/package/package-2.ebuild || exit 1
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI="bar"
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > category/package/ChangeLog || exit 1
+The times, they are-a changin'...
+END
+cat <<END > category/package/metadata.xml || exit
+This isn't valid xml & I don't care!
+END
+cat <<END > category/package/files/some.patch || exit 1
++ Manifest2
+END
+echo "something" > distfiles/foo || exit 1
+echo "for nothing" > distfiles/bar || exit 1
+cat <<END > Manifest_correct || exit 1
+AUX some.patch 12 RMD160 e7f53a2bea1265ef55ae5494ef6050ff7fd1a900 SHA256 26955b4e2d4f60561b8002b72c34ce266f534a4f32f13a29aa33875d39d31cc4
+DIST bar 12 RMD160 90bd2a71cf9d8cf744b0afc0e9a00b999bb59f72 SHA256 27cd06afc317a809116e7730736663b9f09dd863fcc37b69d32d4f5eb58708b2
+DIST foo 10 RMD160 9e19cc1527a061585aa02dae8b7f4047dcd16275 SHA256 4bc453b53cb3d914b45f4b250294236adba2c0e09ff6f03793949e7e39fd4cc1
+EBUILD package-1.ebuild 134 RMD160 0a59df8f246cd5d9f83b89b36026701f1bfe235b SHA256 4d58e5622889397ff6a257d87652a8220585c4d97efbf0a42bf59b3f75d19e03
+EBUILD package-2.ebuild 134 RMD160 d8149a3828ea05849c7033c431d3df5c6eaab67d SHA256 3fb00f77d96c3e6576c2d424d31023958b507bdf20eb6555e89a135b37a54c07
+MISC ChangeLog 34 RMD160 64ae4731e1de8dc8d81f0504c22e586358a5b6f0 SHA256 a8dfbbc187c93c0731fa9722aff87c437a4b9f59b1786d62651fb104b0c3ed97
+MISC metadata.xml 37 RMD160 52a6de8e54eeea3b5e3e8357a400fbc6d3f4062b SHA256 ba3b181b832c002612fba7768c95e526e188658d8fc85b92c153940ad43169de
+END
+cd ..
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 2fcd705..9e40be6 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -143,7 +143,8 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.e_interface(0)
.make_virtuals_interface(0)
.qa_interface(0)
- .hook_interface(this),
+ .hook_interface(this)
+ .manifest_interface(0),
"vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
{
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index e900512..495b4c0 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -51,7 +51,8 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.e_interface(0)
.make_virtuals_interface(0)
.qa_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"fake_installed")
{
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 48a90c9..a660794 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -66,7 +66,8 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.e_interface(0)
.make_virtuals_interface(0)
.qa_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"fake"),
_imp(PrivateImplementationPattern<FakeRepository>::_imp.get())
{
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 2379561..5274ac7 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -81,7 +81,8 @@ GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
.e_interface(0)
.qa_interface(0)
.make_virtuals_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(params))
{
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 06da0f7..3c9b7ca 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -89,7 +89,8 @@ InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepository
.e_interface(0)
.qa_interface(0)
.make_virtuals_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"installed_gems"),
PrivateImplementationPattern<InstalledGemsRepository>(new Implementation<InstalledGemsRepository>(params))
{
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 8ae9a43..d6ebe6a 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -116,7 +116,8 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.e_interface(0)
.make_virtuals_interface(0)
.qa_interface(0)
- .hook_interface(this),
+ .hook_interface(this)
+ .manifest_interface(0),
"installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
new Implementation<InstalledVirtualsRepository>(env, r))
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 408e911..bfcdfc0 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -112,7 +112,8 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.e_interface(0)
.make_virtuals_interface(this)
.qa_interface(0)
- .hook_interface(0),
+ .hook_interface(0)
+ .manifest_interface(0),
"virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
new Implementation<VirtualsRepository>(env))
diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh
index c3a7129..e6c0606 100644
--- a/paludis/repository-fwd.hh
+++ b/paludis/repository-fwd.hh
@@ -47,6 +47,7 @@ namespace paludis
class RepositoryEInterface;
class RepositoryHookInterface;
class RepositoryQAInterface;
+ class RepositoryManifestInterface;
class MergeOptions;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index c5951da..755fa01 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -224,6 +224,10 @@ RepositoryQAInterface::~RepositoryQAInterface()
{
}
+RepositoryManifestInterface::~RepositoryManifestInterface()
+{
+}
+
tr1::shared_ptr<FSEntry>
RepositoryLicensesInterface::license_exists(const std::string & license) const
{
diff --git a/paludis/repository.hh b/paludis/repository.hh
index a2a3edc..01e5f4e 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -776,6 +776,25 @@ namespace paludis
};
/**
+ * Interface for making and verifying Manifest2-style manifests
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE RepositoryManifestInterface
+ {
+ public:
+ /**
+ * Makes the Manifest for a given package. Requires that all
+ * the needed DIST files, etc, have already been fetched.
+ */
+ virtual void make_manifest(const QualifiedPackageName &) = 0;
+
+ virtual ~RepositoryManifestInterface();
+ };
+
+ /**
* Interface for handling hooks.
*
* \see Repository
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 45258b9..748255b 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -20,6 +20,7 @@ make_class_RepositoryCapabilities()
key e_interface "RepositoryEInterface *"
key hook_interface "RepositoryHookInterface *"
key qa_interface "RepositoryQAInterface *"
+ key manifest_interface "RepositoryManifestInterface *"
doxygen_comment << "END"
/**