Catch Permission Denied errors during manifest/digest generation for bug #131073.
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Apr 2006 00:40:43 +0000 (00:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Apr 2006 00:40:43 +0000 (00:40 -0000)
svn path=/main/trunk/; revision=3263

pym/portage.py
pym/portage_manifest.py

index f17bf054c28563d833dff317d0f5ce560aa3eb3f..cf5b700fc3778b9fe5bd128820e98e5f5dd8d29d 100644 (file)
@@ -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),
index 1a6780a51902647fa5ac9e47f8e6207dd7a2f7b5..856ba6fbc24e03725ab9fe369e9699b2cb2df3ed 100644 (file)
@@ -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()