From 367042c0eddb16adde0b7b559cde4e8c48d3c3a5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 29 Apr 2006 00:40:43 +0000 Subject: [PATCH] Catch Permission Denied errors during manifest/digest generation for bug #131073. svn path=/main/trunk/; revision=3263 --- pym/portage.py | 22 ++++++++------- pym/portage_manifest.py | 61 ++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/pym/portage.py b/pym/portage.py index f17bf054c..cf5b700fc 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2710,17 +2710,19 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, if mydo=="fetch" and listonly: return 0 - if "digest" in features: - #generate digest if it doesn't exist. - if mydo=="digest": - return (not digestgen(aalist, mysettings, overwrite=1, myportdb=mydbapi)) - else: + try: + if mydo == "manifest": + return not digestgen(aalist, mysettings, overwrite=1, + manifestonly=1, myportdb=mydbapi) + elif mydo == "digest": + return not digestgen(aalist, mysettings, overwrite=1, + myportdb=mydbapi) + elif "digest" in mysettings.features: digestgen(aalist, mysettings, overwrite=0, myportdb=mydbapi) - elif mydo=="digest": - #since we are calling "digest" directly, recreate the digest even if it already exists - return (not digestgen(aalist, mysettings, overwrite=1, myportdb=mydbapi)) - if mydo=="manifest": - return (not digestgen(aalist,mysettings,overwrite=1,manifestonly=1, myportdb=mydbapi)) + except portage_exception.PermissionDenied, e: + writemsg("!!! %s\n" % str(e)) + if mydo in ("digest", "manifest"): + return 1 # See above comment about fetching only when needed if not digestcheck(checkme, mysettings, ("strict" in features), diff --git a/pym/portage_manifest.py b/pym/portage_manifest.py index 1a6780a51..856ba6fbc 100644 --- a/pym/portage_manifest.py +++ b/pym/portage_manifest.py @@ -332,34 +332,39 @@ class Manifest(object): def write(self, sign=False, force=False): """ Write Manifest instance to disk, optionally signing it """ - if self.compat: - self._writeDigests() - myentries = list(self._createManifestEntries()) - update_manifest = True - if not force: - try: - f = open(self.getFullname(), "r") - oldentries = list(self._parseManifestLines(f)) - f.close() - if len(oldentries) == len(myentries): - update_manifest = False - for i in xrange(len(oldentries)): - if oldentries[i] != myentries[i]: - update_manifest = True - break - except (IOError, OSError), e: - if e.errno == errno.ENOENT: - pass - else: - raise - if update_manifest: - fd = open(self.getFullname(), "w") - for myentry in myentries: - fd.write("%s\n" % str(myentry)) - fd.close() - if sign: - self.sign() - + try: + if self.compat: + self._writeDigests() + myentries = list(self._createManifestEntries()) + update_manifest = True + if not force: + try: + f = open(self.getFullname(), "r") + oldentries = list(self._parseManifestLines(f)) + f.close() + if len(oldentries) == len(myentries): + update_manifest = False + for i in xrange(len(oldentries)): + if oldentries[i] != myentries[i]: + update_manifest = True + break + except (IOError, OSError), e: + if e.errno == errno.ENOENT: + pass + else: + raise + if update_manifest: + fd = open(self.getFullname(), "w") + for myentry in myentries: + fd.write("%s\n" % str(myentry)) + fd.close() + if sign: + self.sign() + except (IOError, OSError), e: + if e.errno == errno.EACCES: + raise PermissionDenied(str(e)) + raise + def sign(self): """ Sign the Manifest """ raise NotImplementedError() -- 2.26.2