summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/emerge/__init__.py29
-rw-r--r--pym/portage/dbapi/bintree.py28
2 files changed, 51 insertions, 6 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index c653104a9..f14836dc1 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -49,6 +49,7 @@ import portage.locks
import portage.exception
from portage.data import secpass
from portage.util import normalize_path as normpath
+from portage.util import writemsg
if not hasattr(__builtins__, "set"):
from sets import Set as set
@@ -2939,6 +2940,8 @@ class MergeTask(object):
def merge(self, mylist, favorites, mtimedb):
failed_fetches = []
+ fetchonly = "--fetchonly" in self.myopts or \
+ "--fetch-all-uri" in self.myopts
mymergelist=[]
ldpath_mtimes = mtimedb["ldpath"]
xterm_titles = "notitles" not in self.settings.features
@@ -3239,9 +3242,29 @@ class MergeTask(object):
short_msg = "emerge: (%s of %s) %s Fetch" % \
(mergecount, len(mymergelist), pkg_key)
emergelog(xterm_titles, msg, short_msg=short_msg)
- if not self.trees[myroot]["bintree"].gettbz2(
- pkg_key):
- return 1
+ try:
+ self.trees[myroot]["bintree"].gettbz2(pkg_key)
+ except portage.exception.FileNotFound:
+ writemsg("!!! Fetching Binary failed " + \
+ "for '%s'\n" % pkg_key, noiselevel=-1)
+ if not fetchonly:
+ return 1
+ failed_fetches.append(pkg_key)
+ except portage.exception.DigestException, e:
+ writemsg("\n!!! Digest verification failed:\n",
+ noiselevel=-1)
+ writemsg("!!! %s\n" % e.value[0],
+ noiselevel=-1)
+ writemsg("!!! Reason: %s\n" % e.value[1],
+ noiselevel=-1)
+ writemsg("!!! Got: %s\n" % e.value[2],
+ noiselevel=-1)
+ writemsg("!!! Expected: %s\n" % e.value[3],
+ noiselevel=-1)
+ os.unlink(mytbz2)
+ if not fetchonly:
+ return 1
+ failed_fetches.append(pkg_key)
finally:
if tbz2_lock:
portage.locks.unlockfile(tbz2_lock)
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index c3a3aad1d..c6cc084c9 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -775,6 +775,7 @@ class binarytree(object):
else:
writemsg("Resuming download of this tbz2, but it is possible that it is corrupt.\n",
noiselevel=-1)
+ tbz2_path = self.getname(pkgname)
mydest = os.path.dirname(self.getname(pkgname))
try:
os.makedirs(mydest, 0775)
@@ -797,9 +798,30 @@ class binarytree(object):
else:
url = urljoin(base_url, tbz2name)
success = portage.getbinpkg.file_get(url, mydest, fcmd=fcmd)
- if success:
- self.inject(pkgname)
- return success
+ if success and "strict" in self.settings.features:
+ metadata = self._remotepkgs[pkgname]
+ digests = {}
+ if "MD5" in metadata:
+ digests["MD5"] = self._remotepkgs[pkgname]["MD5"]
+ if "SIZE" in metadata:
+ try:
+ digests["size"] = long(self._remotepkgs[pkgname]["SIZE"])
+ except ValueError:
+ writemsg("!!! Malformed SIZE attribute in remote " + \
+ "metadata for '%s'\n" % pkgname)
+ if digests:
+ from portage.checksum import verify_all
+ ok, reason = verify_all(tbz2_path, digests)
+ if not ok:
+ raise portage.exception.DigestException(
+ tuple([tbz2_path]+list(reason)))
+ if not success:
+ try:
+ os.unlink(self.getname(pkgname))
+ except OSError:
+ pass
+ raise portage.exception.FileNotFound(mydest)
+ self.inject(pkgname)
def getslot(self, mycatpkg):
"Get a slot for a catpkg; assume it exists."