summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-12 21:28:11 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-12 21:28:11 +0000
commit2fa6a6ac1aa99626bc001a979f17f8d07e709504 (patch)
tree01d3b46a87f23998d2776f00d9de77b6883dbd1a /pym
parentc3be86d8d02168115a5e5591b38b96a7c59cfffe (diff)
downloadportage-2fa6a6ac1aa99626bc001a979f17f8d07e709504.tar.gz
portage-2fa6a6ac1aa99626bc001a979f17f8d07e709504.tar.bz2
portage-2fa6a6ac1aa99626bc001a979f17f8d07e709504.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). (trunk r12185:12188) svn path=/main/branches/2.1.6/; revision=12221
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py50
1 files changed, 29 insertions, 21 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 931947a66..ae499bcb2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -4234,32 +4234,40 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
required_hash_types.add("size")
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).
+ missing_files = []
for myfile in distfiles_map:
myhashes = dist_hashes.get(myfile)
if not myhashes:
- missing_hashes.add(myfile)
- continue
- if required_hash_types.difference(myhashes):
- missing_hashes.add(myfile)
+ missing_files.append(myfile)
continue
- if myhashes["size"] == 0:
- missing_hashes.add(myfile)
- if missing_hashes:
- missing_files = []
- for myfile in missing_hashes:
- try:
- st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- del e
+ size = myhashes.get("size")
+
+ try:
+ st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ if size == 0:
missing_files.append(myfile)
- else:
- # If the file is empty then it's obviously invalid.
- if st.st_size == 0:
- missing_files.append(myfile)
- if missing_files:
+ continue
+ if required_hash_types.difference(myhashes):
+ missing_files.append(myfile)
+ continue
+ else:
+ if st.st_size == 0 or size is not None and size != st.st_size:
+ missing_files.append(myfile)
+ continue
+
+ if missing_files:
mytree = os.path.realpath(os.path.dirname(
os.path.dirname(mysettings["O"])))
fetch_settings = config(clone=mysettings)