aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-02-04 03:45:10 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-02-04 03:45:10 +0000
commitea7aca0cb35fed42ce247c31770fb009155ad601 (patch)
treeeab0fb1ca75938210d6061d0638658b6e4091da9
parent8d97ead992117e05c690c66e5a0a37dc6116e17c (diff)
downloadpaludis-ea7aca0cb35fed42ce247c31770fb009155ad601.tar.gz
paludis-ea7aca0cb35fed42ce247c31770fb009155ad601.tar.xz
Support checking/generating SHA1 in Manifest files.
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.cc23
-rw-r--r--paludis/repositories/e/e_repository.cc11
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh18
3 files changed, 43 insertions, 9 deletions
diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc
index 2e64474..9a7693f 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.cc
+++ b/paludis/repositories/e/check_fetched_files_visitor.cc
@@ -37,6 +37,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/kc.hh>
#include <paludis/util/rmd160.hh>
+#include <paludis/util/sha1.hh>
#include <paludis/util/sha256.hh>
#include <paludis/util/md5.hh>
@@ -262,6 +263,28 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
file_stream.seekg(0, std::ios::beg);
}
+ if (! m->sha1.empty())
+ {
+ SHA1 sha1sum(file_stream);
+ if (sha1sum.hexsum() != m->sha1)
+ {
+ Log::get_instance()->message(ll_debug, lc_context)
+ << "Malformed Manifest: failed SHA1 checksum";
+ std::cout << "failed SHA1";
+ _imp->failures->push_back(FetchActionFailure::named_create()
+ (k::target_file(), stringify(distfile.basename()))
+ (k::requires_manual_fetching(), false)
+ (k::failed_integrity_checks(), "Failed SHA1 checksum")
+ (k::failed_automatic_fetching(), false)
+ );
+ return false;
+ }
+ Log::get_instance()->message(ll_debug, lc_context)
+ << "Actual SHA1 = " << sha1sum.hexsum();
+ file_stream.clear();
+ file_stream.seekg(0, std::ios::beg);
+ }
+
if (! m->sha256.empty())
{
SHA256 sha256sum(file_stream);
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index dd6e028..aaa68e4 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -74,6 +74,7 @@
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/kc.hh>
#include <paludis/util/rmd160.hh>
+#include <paludis/util/sha1.hh>
#include <paludis/util/sha256.hh>
#include <map>
@@ -1316,6 +1317,11 @@ ERepository::make_manifest(const QualifiedPackageName & qpn)
file_stream.clear();
file_stream.seekg(0, std::ios::beg);
+ SHA1 sha1sum(file_stream);
+ manifest << " SHA1 " << sha1sum.hexsum();
+
+ file_stream.clear();
+ file_stream.seekg(0, std::ios::beg);
SHA256 sha256sum(file_stream);
manifest << " SHA256 " << sha256sum.hexsum() << std::endl;
}
@@ -1356,6 +1362,11 @@ ERepository::make_manifest(const QualifiedPackageName & qpn)
file_stream.clear();
file_stream.seekg(0, std::ios::beg);
+ SHA1 sha1sum(file_stream);
+ manifest << " SHA1 " << sha1sum.hexsum();
+
+ file_stream.clear();
+ file_stream.seekg(0, std::ios::beg);
SHA256 sha256sum(file_stream);
manifest << " SHA256 " << sha256sum.hexsum()
<< std::endl;
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 859c9e3..b317043 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -370,13 +370,13 @@ 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
+AUX some.patch 12 RMD160 e7f53a2bea1265ef55ae5494ef6050ff7fd1a900 SHA1 eaa98a50a0db46d8ab1b02aacbfe511ea2273234 SHA256 26955b4e2d4f60561b8002b72c34ce266f534a4f32f13a29aa33875d39d31cc4
+DIST bar 12 RMD160 90bd2a71cf9d8cf744b0afc0e9a00b999bb59f72 SHA1 f27a44461791182539e3d22516148b1e5289fdce SHA256 27cd06afc317a809116e7730736663b9f09dd863fcc37b69d32d4f5eb58708b2
+DIST foo 10 RMD160 9e19cc1527a061585aa02dae8b7f4047dcd16275 SHA1 50a4e988380c09d290acdab4bd53d24ee7b497df SHA256 4bc453b53cb3d914b45f4b250294236adba2c0e09ff6f03793949e7e39fd4cc1
+EBUILD package-1.ebuild 134 RMD160 0a59df8f246cd5d9f83b89b36026701f1bfe235b SHA1 ba3e8f6f99abdd220fc9d51c6370e4f29f8c74af SHA256 4d58e5622889397ff6a257d87652a8220585c4d97efbf0a42bf59b3f75d19e03
+EBUILD package-2.ebuild 134 RMD160 d8149a3828ea05849c7033c431d3df5c6eaab67d SHA1 8ae9fc2476191906c8827b42ca86279d6fa0aead SHA256 3fb00f77d96c3e6576c2d424d31023958b507bdf20eb6555e89a135b37a54c07
+MISC ChangeLog 34 RMD160 64ae4731e1de8dc8d81f0504c22e586358a5b6f0 SHA1 4de9269f6cdd0cf97c11c4a552cf3764301f40c0 SHA256 a8dfbbc187c93c0731fa9722aff87c437a4b9f59b1786d62651fb104b0c3ed97
+MISC metadata.xml 37 RMD160 52a6de8e54eeea3b5e3e8357a400fbc6d3f4062b SHA1 071fb2cfe08b9fa1816ec14d65d2e9099810b552 SHA256 ba3b181b832c002612fba7768c95e526e188658d8fc85b92c153940ad43169de
END
cat <<END > category/package-b/package-b-1.ebuild || exit 1
DESCRIPTION="The Description"
@@ -981,8 +981,8 @@ DEPEND=""
END
echo "something" > distfiles/foo || exit 1
cat <<END > Manifest || exit 1
-DIST bar 12 RMD160 90bd2a71cf9d8cf744b0afc0e9a00b999bb59f72 SHA256 27cd06afc317a809166e7730736663b9f09dd863fcc37b69d32d4f5eb58708b2
-DIST foo 10 RMD160 9e19cc1527a061585aa02dae8b7f4047dcd16275 SHA256 4bc453b53cb3d914b45f4b250294236adba2c0e09ff6f03793949e7e39fd4cc1
+DIST bar 12 RMD160 90bd2a71cf9d8cf744b0afc0e9a00b999bb59f72 SHA1 f27a44461791182539e3d22516148b1e5289fdce SHA256 27cd06afc317a809116e7730736663b9f09dd863fcc37b69d32d4f5eb58708b2
+DIST foo 10 RMD160 9e19cc1527a061585aa02dae8b7f4047dcd16275 SHA1 50a4e988380c09d290acdab4bd53d24ee7b497df SHA256 4bc453b53cb3d914b45f4b250294236adba2c0e09ff6f03793949e7e39fd4cc1
END
cp Manifest category/package-a/
cp Manifest category/package-b/