Tweak --buildpkgonly and fakeroot logic so that --buildpkgonly can be
authorZac Medico <zmedico@gentoo.org>
Fri, 11 Apr 2008 00:50:03 +0000 (00:50 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 Apr 2008 00:50:03 +0000 (00:50 -0000)
used by a non-root user to build binary packages with fakeroot.
(trunk r9825)

svn path=/main/branches/2.1.2/; revision=9826

bin/emerge
pym/portage.py

index d61c473e58aadc3d846ba9e7c411f12f15de2740..e1ee662b1fa4dc5174931c8115e25f2d4a7fd290 100755 (executable)
@@ -4921,7 +4921,7 @@ class MergeTask(object):
                                try:
                                        catdir_lock = portage_locks.lockdir(catdir)
                                        portage_util.ensure_dirs(catdir,
-                                               uid=portage.portage_uid, gid=portage.portage_gid,
+                                               gid=portage.portage_gid,
                                                mode=070, mask=0)
                                        builddir_lock = portage_locks.lockdir(
                                                pkgsettings["PORTAGE_BUILDDIR"])
@@ -6971,6 +6971,7 @@ def action_build(settings, trees, mtimedb,
        ldpath_mtimes = mtimedb["ldpath"]
        favorites=[]
        merge_count = 0
+       buildpkgonly = "--buildpkgonly" in myopts
        pretend = "--pretend" in myopts
        fetchonly = "--fetchonly" in myopts or "--fetch-all-uri" in myopts
        ask = "--ask" in myopts
@@ -7273,7 +7274,7 @@ def action_build(settings, trees, mtimedb,
                                        + " AUTOCLEAN is disabled.  This can cause serious"
                                        + " problems due to overlapping packages.\n")
 
-               if merge_count and not (pretend or fetchonly):
+               if merge_count and not (buildpkgonly or fetchonly or pretend):
                        post_emerge(settings, mtimedb, retval)
                return retval
 
@@ -7715,13 +7716,17 @@ def emerge_main():
                emergehelp.help(myaction, myopts, output.havecolor)
                sys.exit(1)
 
+       pretend = "--pretend" in myopts
+       fetchonly = "--fetchonly" in myopts or "--fetch-all-uri" in myopts
+       buildpkgonly = "--buildpkgonly" in myopts
+
        # check if root user is the current user for the actions where emerge needs this
        if portage.secpass < 2:
                # We've already allowed "--version" and "--help" above.
                if "--pretend" not in myopts and myaction not in ("search","info"):
                        need_superuser = not \
-                               ("--fetchonly" in myopts or \
-                               "--fetch-all-uri" in myopts or \
+                               (fetchonly or \
+                               (buildpkgonly and secpass >= 1) or \
                                myaction in ("metadata", "regen") or \
                                (myaction == "sync" and os.access(settings["PORTDIR"], os.W_OK)))
                        if portage.secpass < 1 or \
@@ -7823,14 +7828,14 @@ def emerge_main():
                vartree = trees[settings["ROOT"]]["vartree"]
                if 1 == unmerge(settings, myopts, vartree, myaction, myfiles,
                        mtimedb["ldpath"]):
-                       if "--pretend" not in myopts:
+                       if not (buildpkgonly or fetchonly or pretend):
                                post_emerge(settings, mtimedb, 0)
 
        elif myaction in ("depclean", "prune"):
                validate_ebuild_environment(trees)
                action_depclean(settings, trees, mtimedb["ldpath"],
                        myopts, myaction, myfiles, spinner)
-               if "--pretend" not in myopts:
+               if not (buildpkgonly or fetchonly or pretend):
                        post_emerge(settings, mtimedb, 0)
        # "update", "system", or just process files:
        else:
index cc47a3cb27cf10d00db7970e96c383506e372f97..504c20f3f000c1d83631968693f62ccd5cecc868 100644 (file)
@@ -2903,7 +2903,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
        if not free:
                free=((droppriv and "usersandbox" not in features) or \
                        (not droppriv and "sandbox" not in features and \
-                       "usersandbox" not in features))
+                       "usersandbox" not in features and not fakeroot))
 
        if free or "SANDBOX_ACTIVE" in os.environ:
                keywords["opt_name"] += " bash"
@@ -4470,6 +4470,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                vartree = db[myroot]["vartree"]
 
        features = mysettings.features
+       from portage_data import secpass
 
        validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
                        "config","info","setup","depend","fetch","digest",
@@ -4972,7 +4973,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                        "sesandbox" in mysettings.features
 
                droppriv = "userpriv" in mysettings.features and \
-                       "userpriv" not in restrict
+                       "userpriv" not in restrict and \
+                       secpass >= 2
 
                fakeroot = "fakeroot" in mysettings.features