When the user has insufficient access privileges, specify whether superuser access...
authorZac Medico <zmedico@gentoo.org>
Mon, 25 Dec 2006 09:02:20 +0000 (09:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 25 Dec 2006 09:02:20 +0000 (09:02 -0000)
svn path=/main/trunk/; revision=5389

bin/emerge

index 5f8bd5f614abccda2094ec2b202a3569f1728732..1b07d77bf2a7064cac6f44e03efcb3f70b7b505d 100755 (executable)
@@ -4961,18 +4961,32 @@ def emerge_main():
                # We've already allowed "--version" and "--help" above.
                if "--pretend" not in myopts and \
                myaction not in ("search","info"):
-                       if portage.secpass < 1 or \
-                               not ("--fetchonly" in myopts or \
+                       need_superuser = not \
+                               ("--fetchonly" in myopts or \
                                "--fetch-all-uri" in myopts or \
-                               myaction in ("metadata", "regen")):
+                               myaction in ("metadata", "regen"))
+                       if portage.secpass < 1 or \
+                               need_superuser:
+                               if need_superuser:
+                                       access_desc = "superuser"
+                               else:
+                                       access_desc = "portage group"
+                               # Always show portage_group_warning() when only portage group
+                               # access is required but the user is not in the portage group.
+                               from portage_data import portage_group_warning
                                if "--ask" in myopts:
                                        myopts["--pretend"] = True
                                        del myopts["--ask"]
-                                       print "root access would be required..." + \
-                                               " adding --pretend to options."
+                                       print ("%s access would be required... " + \
+                                               "adding --pretend to options.\n") % access_desc
+                                       if portage.secpass < 1 and not need_superuser:
+                                               portage_group_warning()
                                else:
-                                       print "emerge: root access required."
-                                       sys.exit(1)
+                                       sys.stderr.write(("emerge: %s access would be " + \
+                                               "required.\n\n") % access_desc)
+                                       if portage.secpass < 1 and not need_superuser:
+                                               portage_group_warning()
+                                       return 1
 
        disable_emergelog = False
        for x in ("--pretend", "--fetchonly", "--fetch-all-uri"):