summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-09 22:03:14 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-09 22:03:14 +0000
commit2517d4e948a8bbaeb6c6264b0fe5bcb6f798c2fb (patch)
tree6e9549a9f52c623cdbc5749096f8e00f03e41c18
parentc6a4ff425c95023bed711b22e07d9e9caf6b231c (diff)
downloadportage-2517d4e948a8bbaeb6c6264b0fe5bcb6f798c2fb.tar.gz
portage-2517d4e948a8bbaeb6c6264b0fe5bcb6f798c2fb.tar.bz2
portage-2517d4e948a8bbaeb6c6264b0fe5bcb6f798c2fb.zip
Bug #250166 - To avoid accidental regeneration of digests with the incorrect
files (such as partially downloaded files), trigger the fetch code if the file exists and it's size doesn't match the current manifest entry. If there really is a legitimate reason for the digest to change, `ebuild --force digest` can be used to avoid triggering this code (or else the old digests can be manually removed from the Manifest). svn path=/main/trunk/; revision=12186
-rw-r--r--pym/portage/__init__.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 59ddfd5d8..1ca0404b9 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -4245,6 +4245,14 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
required_hash_types.add(portage.const.MANIFEST2_REQUIRED_HASH)
dist_hashes = mf.fhashdict.get("DIST", {})
missing_hashes = set()
+ # To avoid accidental regeneration of digests with the incorrect
+ # files (such as partially downloaded files), trigger the fetch
+ # code if the file exists and it's size doesn't match the current
+ # manifest entry. If there really is a legitimate reason for the
+ # digest to change, `ebuild --force digest` can be used to avoid
+ # triggering this code (or else the old digests can be manually
+ # removed from the Manifest).
+ wrong_size_files = set()
for myfile in distfiles_map:
myhashes = dist_hashes.get(myfile)
if not myhashes:
@@ -4255,7 +4263,19 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
continue
if myhashes["size"] == 0:
missing_hashes.add(myfile)
- if missing_hashes:
+ continue
+ try:
+ st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ continue
+ if st.st_size == 0 or st.st_size != myhashes["size"]:
+ wrong_size_files.add(myfile)
+ continue
+
+ if missing_hashes or wrong_size_files:
missing_files = []
for myfile in missing_hashes:
try:
@@ -4269,6 +4289,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
# If the file is empty then it's obviously invalid.
if st.st_size == 0:
missing_files.append(myfile)
+ missing_files.extend(wrong_size_files)
if missing_files:
mytree = os.path.realpath(os.path.dirname(
os.path.dirname(mysettings["O"])))