For bug #180165, make portageq print a "Permission denied" error when appropriate...
authorZac Medico <zmedico@gentoo.org>
Mon, 30 Jul 2007 04:31:03 +0000 (04:31 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 30 Jul 2007 04:31:03 +0000 (04:31 -0000)
svn path=/main/branches/2.1.2.9/; revision=7470

bin/ebuild.sh
bin/emerge
bin/portageq
pym/portage.py

index 5b9abd7a6145953bee0caeb6040498c55140bdfe..18c946840694aeca5ec68b5dcdc6749c863a045e 100755 (executable)
@@ -190,11 +190,19 @@ has_version() {
        fi
        # return shell-true/shell-false if exists.
        # Takes single depend-type atoms.
-       if "${PORTAGE_BIN_PATH}/portageq" 'has_version' "${ROOT}" "$1"; then
-               return 0
-       else
-               return 1
-       fi
+       "${PORTAGE_BIN_PATH}"/portageq has_version "${ROOT}" "$1"
+       local retval=$?
+       case "${retval}" in
+               0)
+                       return 0
+                       ;;
+               1)
+                       return 1
+                       ;;
+               *)
+                       die "unexpected portageq exit code: ${retval}"
+                       ;;
+       esac
 }
 
 portageq() {
index 8e43bb822a03d9a1bd0c2e7828e2d13c9f0eb740..80b72e1424527910bd9aef80150cb5429f6ad9e5 100755 (executable)
@@ -5582,5 +5582,10 @@ def emerge_main():
                        post_emerge(settings, mtimedb, 0)
 
 if __name__ == "__main__":
-       retval = emerge_main()
+       from portage_exception import PermissionDenied
+       try:
+               retval = emerge_main()
+       except PermissionDenied, e:
+               sys.stderr.write("Permission denied: '%s'\n" % str(e))
+               sys.exit(e.errno)
        sys.exit(retval)
index 6147e5627f7832eb7435d7000e11685821828c8a..1a59af8bca2dae485d4d56d5074ac003d71e1b9a 100755 (executable)
@@ -133,12 +133,7 @@ def best_visible(argv):
                sys.exit(2)
        try:
                mylist=portage.db[argv[0]]["porttree"].dbapi.match(argv[1])
-               visible=portage.best(mylist)
-               if visible:
-                       print visible
-                       sys.exit(0)
-               else:
-                       sys.exit(1)
+               print portage.best(mylist)
        except KeyError:
                sys.exit(1)
 best_visible.uses_root = True
index 2a153a29833e85b7f2d87fcf1f3e168eaa7281bb..2ee843c2b5a030bc9390052ae0582680f6db82fd 100644 (file)
@@ -185,7 +185,14 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        mtime = pathstat[stat.ST_MTIME]
                else:
                        raise portage_exception.DirectoryNotFound(mypath)
-       except (IOError,OSError,portage_exception.PortageException):
+       except EnvironmentError, e:
+               if e.errno == portage_exception.PermissionDenied.errno:
+                       raise portage_exception.PermissionDenied(mypath)
+               del e
+               if EmptyOnError:
+                       return [], []
+               return None, None
+       except portage_exception.PortageException:
                if EmptyOnError:
                        return [], []
                return None, None
@@ -199,8 +206,6 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        if e.errno != errno.EACCES:
                                raise
                        del e
-                       if EmptyOnError:
-                               return [], []
                        raise portage_exception.PermissionDenied(mypath)
                ftype = []
                for x in list: