Merged from trunk -r12520:12524
authorFabian Groffen <grobian@gentoo.org>
Sat, 17 Jan 2009 16:58:20 +0000 (16:58 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 17 Jan 2009 16:58:20 +0000 (16:58 -0000)
   | 12521   | Bug #255101 - Fix 'Permission denied' error handling in      |
   | zmedico | NewsManager.getUnreadItems(). If there's no permission to    |
   |         | lock the unread file, skip the lock and try to read the file |
   |         | anyway.                                                      |

   | 12522   | Revert chown behavior change from the previous commit, so    |
   | zmedico | that chown will not be called on a pre-existing file.        |

   | 12523   | Identify which package has unused local USE descriptions, in |
   | zmedico | case more than one package is being scanned. Thanks to       |
   |         | Thomas Sachau <tommy@g.o> for reporting.                     |

   | 12524   | Fix false positive in the 'unused local USE-description'     |
   | zmedico | warning. Thanks to Alexis Ballier <aballier@g.o> for         |
   |         | reporting.                                                   |

svn path=/main/branches/prefix/; revision=12527

bin/repoman
pym/portage/locks.py
pym/portage/news.py

index c788f1f683cbec1e0d83c44b5f4d5263c9188291..7a4728e7e33e7d2bdf3de94daa1bdab6e4fe5e7f 100755 (executable)
@@ -1369,11 +1369,11 @@ for x in scanlist:
                default_use = []
                for myflag in myaux["IUSE"].split():
                        flag_name = myflag.lstrip("+-")
+                       used_useflags.add(flag_name)
                        if myflag != flag_name:
                                default_use.append(myflag)
                        if flag_name not in uselist:
                                myuse.append(flag_name)
-               used_useflags.update(myuse)
 
                # uselist checks - metadata
                for mypos in range(len(myuse)-1,-1,-1):
@@ -1586,7 +1586,8 @@ for x in scanlist:
        for myflag in muselist.difference(used_useflags):
                stats["metadata.warning"] += 1
                fails["metadata.warning"].append(
-                       "unused local USE-description: '%s'" % myflag)
+                       "%s/metadata.xml: unused local USE-description: '%s'" % \
+                       (x, myflag))
 
 if options.mode == "manifest":
        sys.exit(dofail)
index 659ad3d4b772cd5abc0b40988a374282aebfdac5..912b2a32f566ccf82e12878c015e05c13877c538 100644 (file)
@@ -9,7 +9,7 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
 
 import errno, os, stat, time, types
 from portage.exception import DirectoryNotFound, FileNotFound, \
-       InvalidData, TryAgain
+       InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
 from portage.data import portage_gid
 from portage.output import EOutput
 from portage.util import writemsg
@@ -56,22 +56,36 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
        if type(mypath) == types.StringType:
                if not os.path.exists(os.path.dirname(mypath)):
                        raise DirectoryNotFound(os.path.dirname(mypath))
-               if not os.path.exists(lockfilename):
-                       old_mask=os.umask(000)
-                       myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660)
+               preexisting = os.path.exists(lockfilename)
+               old_mask = os.umask(000)
+               try:
                        try:
-                               if os.stat(lockfilename).st_gid != portage_gid:
-                                       os.chown(lockfilename,os.getuid(),portage_gid)
+                               myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0660)
                        except OSError, e:
-                               if e[0] == 2: # No such file or directory
-                                       return lockfile(mypath, wantnewlockfile=wantnewlockfile,
-                                               unlinkfile=unlinkfile, waiting_msg=waiting_msg,
-                                               flags=flags)
+                               func_call = "open('%s')" % lockfilename
+                               if e.errno == OperationNotPermitted.errno:
+                                       raise OperationNotPermitted(func_call)
+                               elif e.errno == PermissionDenied.errno:
+                                       raise PermissionDenied(func_call)
                                else:
-                                       writemsg("Cannot chown a lockfile. This could cause inconvenience later.\n");
+                                       raise
+
+                       if not preexisting:
+                               try:
+                                       if os.stat(lockfilename).st_gid != portage_gid:
+                                               os.chown(lockfilename, -1, portage_gid)
+                               except OSError, e:
+                                       if e.errno == errno.ENOENT: # No such file or directory
+                                               return lockfile(mypath,
+                                                       wantnewlockfile=wantnewlockfile,
+                                                       unlinkfile=unlinkfile, waiting_msg=waiting_msg,
+                                                       flags=flags)
+                                       else:
+                                               writemsg("Cannot chown a lockfile. This could " + \
+                                                       "cause inconvenience later.\n")
+
+               finally:
                        os.umask(old_mask)
-               else:
-                       myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660)
 
        elif type(mypath) == types.IntType:
                myfd = mypath
index 90dd3a065796eb1af512d6b17a873e3fab86b9c0..b20fd422e1917ea709eefb04880cd6c1e82da8b7 100644 (file)
@@ -157,7 +157,7 @@ class NewsManager(object):
                try:
                        unread_lock = lockfile(unread_filename, wantnewlockfile=1)
                except (InvalidLocation, OperationNotPermitted, PermissionDenied):
-                       return 0
+                       pass
                try:
                        try:
                                return len(grabfile(unread_filename))