import traceback
from _emerge.SpawnProcess import SpawnProcess
+import copy
import sys
import portage
from portage import os
class EbuildFetcher(SpawnProcess):
__slots__ = ("config_pool", "fetchonly", "fetchall", "pkg", "prefetch") + \
- ("_settings", "_uri_map")
+ ("_digests", "_settings", "_uri_map")
def _start(self):
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',
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
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 = {}
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:
'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:
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", "")) \