EbuildFetcher: pass digests to fetch()
authorZac Medico <zmedico@gentoo.org>
Tue, 28 Dec 2010 20:41:26 +0000 (12:41 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 28 Dec 2010 20:41:26 +0000 (12:41 -0800)
pym/_emerge/EbuildFetcher.py
pym/portage/package/ebuild/fetch.py

index bfac5a6c004fa43f75f1deba244924dc0ceae024..06285499da7557d5fa9d266486847f41abb4a7c4 100644 (file)
@@ -4,6 +4,7 @@
 import traceback
 
 from _emerge.SpawnProcess import SpawnProcess
+import copy
 import sys
 import portage
 from portage import os
@@ -18,7 +19,7 @@ from portage.util._pty import _create_pty_or_pipe
 class EbuildFetcher(SpawnProcess):
 
        __slots__ = ("config_pool", "fetchonly", "fetchall", "pkg", "prefetch") + \
-               ("_settings", "_uri_map")
+               ("_digests", "_settings", "_uri_map")
 
        def _start(self):
 
@@ -46,6 +47,9 @@ class EbuildFetcher(SpawnProcess):
                        self.wait()
                        return
 
+               self._digests = portage.Manifest(
+                       os.path.dirname(ebuild_path), None).getTypeDigests("DIST")
+
                settings = self.config_pool.allocate()
                settings.setcpv(self.pkg)
                portage.doebuild_environment(ebuild_path, 'fetch',
@@ -98,7 +102,8 @@ class EbuildFetcher(SpawnProcess):
 
                rval = 1
                try:
-                       if fetch(self._uri_map, self._settings, fetchonly=self.fetchonly):
+                       if fetch(self._uri_map, self._settings, fetchonly=self.fetchonly,
+                               digests=copy.deepcopy(self._digests)):
                                rval = os.EX_OK
                except SystemExit:
                        raise
@@ -121,7 +126,6 @@ class EbuildFetcher(SpawnProcess):
                return portdb.getFetchMap(self.pkg.cpv, useflags=use, mytree=mytree)
 
        def _prefetch_size_ok(self, uri_map, settings, ebuild_path):
-               pkgdir = os.path.dirname(ebuild_path)
                distdir = settings["DISTDIR"]
 
                sizes = {}
@@ -136,7 +140,7 @@ class EbuildFetcher(SpawnProcess):
                                return False
                        sizes[filename] = st.st_size
 
-               digests = portage.Manifest(pkgdir, distdir).getTypeDigests("DIST")
+               digests = self._digests
                for filename, actual_size in sizes.items():
                        size = digests.get(filename, {}).get('size')
                        if size is None:
index f1bd2408ab9a45b597af6bc59944a03d096f7bce..7e4365fb782489fd820f0ff8dac2ca213389c974 100644 (file)
@@ -230,7 +230,8 @@ _size_suffix_map = {
        'Y' : 80,
 }
 
-def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",use_locks=1, try_mirrors=1):
+def fetch(myuris, mysettings, listonly=0, fetchonly=0,
+       locks_in_subdir=".locks", use_locks=1, try_mirrors=1, digests=None):
        "fetch files.  Will use digest file if available."
 
        if not myuris:
@@ -352,12 +353,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
 
        skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1"
        pkgdir = mysettings.get("O")
-       if not (pkgdir is None or skip_manifest):
+       if digests is None and not (pkgdir is None or skip_manifest):
                mydigests = Manifest(
                        pkgdir, mysettings["DISTDIR"]).getTypeDigests("DIST")
-       else:
+       elif digests is None:
                # no digests because fetch was not called for a specific package
                mydigests = {}
+       else:
+               mydigests = digests
 
        ro_distdirs = [x for x in \
                shlex_split(mysettings.get("PORTAGE_RO_DISTDIRS", "")) \