diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-07-05 07:18:31 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-07-05 07:18:31 +0000 |
commit | ddddc6e7ff41d6c30bde682dac4e2e42e017a13f (patch) | |
tree | 1a2b10f3ec699d7bb5415d231634de0758783451 /pym/_emerge/__init__.py | |
parent | efead8fa199be63234d8b93e64e68797d3909aa9 (diff) | |
download | portage-ddddc6e7ff41d6c30bde682dac4e2e42e017a13f.tar.gz portage-ddddc6e7ff41d6c30bde682dac4e2e42e017a13f.tar.bz2 portage-ddddc6e7ff41d6c30bde682dac4e2e42e017a13f.zip |
* Implement a new binarytree.digestCheck() method and use it to check
digests for binary packages.
* Split out a AsynchronousTask base class from SubProcess.
* Derive a new BinpkgVerifier class from AsynchronousTask. Even though
this is not really asynchronous yet, it can fake the interface by
doing everything in the start() method.
svn path=/main/trunk/; revision=10935
Diffstat (limited to 'pym/_emerge/__init__.py')
-rw-r--r-- | pym/_emerge/__init__.py | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index bfae9e20a..20629c1f9 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1454,8 +1454,29 @@ class EbuildFetchPretend(SlotObject): mydbapi=portdb, tree="porttree") return retval -class SubProcess(SlotObject): - __slots__ = ("cancelled", "pid", "returncode") +class AsynchronousTask(SlotObject): + __slots__ = ("cancelled", "returncode") + + def start(self): + """ + Start an asynchronous task and then return as soon as possible. + """ + pass + + def isAlive(self): + return self.returncode is None + + def poll(self): + return self.returncode + + def wait(self): + return self.returncode + + def cancel(self): + pass + +class SubProcess(AsynchronousTask): + __slots__ = ("pid",) def poll(self): if self.returncode is not None: @@ -2175,6 +2196,8 @@ class Binpkg(EbuildBuildDir): tree = "bintree" settings.setcpv(pkg) debug = settings.get("PORTAGE_DEBUG") == "1" + verify = "strict" in settings.features and \ + not opts.pretend # The prefetcher has already completed or it # could be running now. If it's running now, @@ -2227,6 +2250,13 @@ class Binpkg(EbuildBuildDir): if opts.fetchonly: return os.EX_OK + if verify: + verifier = BinpkgVerifier(pkg=pkg) + verifier.start() + retval = verifier.wait() + if retval != os.EX_OK: + return retval + msg = " === (%s of %s) Merging Binary (%s::%s)" % \ (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path) short_msg = "emerge: (%s of %s) %s Merge Binary" % \ @@ -2352,8 +2382,7 @@ class Binpkg(EbuildBuildDir): class BinpkgFetcher(Task): - __slots__ = ("use_locks", "pkg", "pretend", - "pkg_path", "remote") + __slots__ = ("use_locks", "pkg", "pretend", "pkg_path", "remote") def __init__(self, **kwargs): Task.__init__(self, **kwargs) @@ -2498,6 +2527,47 @@ class BinpkgFetcherAsync(SpawnProcess): self._lock_obj = None self.locked = False +class BinpkgVerifier(AsynchronousTask): + __slots__ = ("pkg",) + + def start(self): + """ + Note: Unlike a normal AsynchronousTask.start() method, + this one does all work is synchronously. The returncode + attribute will be set before it returns. + """ + + pkg = self.pkg + root_config = pkg.root_config + bintree = root_config.trees["bintree"] + rval = os.EX_OK + try: + bintree.digestCheck(pkg) + except portage.exception.FileNotFound: + writemsg("!!! Fetching Binary failed " + \ + "for '%s'\n" % pkg.cpv, noiselevel=-1) + rval = 1 + 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) + rval = 1 + + self.returncode = rval + + def cancel(self): + self.cancelled = True + + def poll(self): + return self.returncode + class BinpkgExtractorAsync(SpawnProcess): __slots__ = ("image_dir", "pkg", "pkg_path") |