From 0c7530f9d1258259c13bb63349b4a7287270498f Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 24 Aug 2008 13:21:34 +0000 Subject: [PATCH] Merged from trunk -r11445:11446 | 11446 | Fix typo in "directory" spelling. Thanks to Ofer Wald in bug | | zmedico | #219957. | Merged from trunk -r11448:11454 | 11449 | For consistency, show [0] in the repo display instead of | | zmedico | suppressing it. Now the repo display and [0] will only be | | | suppressed when [0] is all that would show for every | | | package. Thanks to Joe Peterson for the | | | suggestion. | | 11450 | Use shlex.split() to split CONFIG_PROTECT and | | zmedico | CONFIG_PROTECT_MASK. | | 11451 | Update ROOT docs wrt make.conf since it can now be set there | | zmedico | regardless of PORTAGE_CONFIGROOT setting. | | 11452 | Fix isprotected() call in dblink._collision_protect() to | | zmedico | properly account for $ROOT. | | 11453 | Add a new is_protected command which queries whether or not | | zmedico | CONFIG_PROTECT applies to a given file, using logic | | | identical to the merge code. | | 11454 | Add a new src_prepare phase function which is called | | zmedico | in-between src_unpack and src_configure (and bump EAPI to | | | 2_pre3). Thanks to Ciaran McCreesh for the suggestion. | svn path=/main/branches/prefix/; revision=11462 --- bin/ebuild.sh | 44 +++++++++++++++++++-- bin/isolated-functions.sh | 8 ++-- bin/portageq | 47 ++++++++++++++++++++++ doc/package/ebuild/eapi/2.docbook | 15 ++++++- man/emerge.1 | 3 +- pym/_emerge/__init__.py | 65 +++++++++++++++++++++---------- pym/portage/__init__.py | 17 +++++--- pym/portage/const.py | 2 +- pym/portage/dbapi/vartree.py | 7 ++-- 9 files changed, 168 insertions(+), 40 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 0ff5ab4a1..41eba7696 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -735,7 +735,7 @@ dyn_clean() { fi if ! hasq keepwork $FEATURES; then - rm -f "$PORTAGE_BUILDDIR"/.{exit_status,logid,unpacked} \ + rm -f "$PORTAGE_BUILDDIR"/.{exit_status,logid,unpacked,prepared} \ "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged} rm -rf "${PORTAGE_BUILDDIR}/build-info" @@ -841,6 +841,12 @@ abort_handler() { trap SIGINT SIGQUIT } +abort_prepare() { + abort_handler src_prepare $1 + rm -f "$PORTAGE_BUILDDIR/.prepared" + exit 1 +} + abort_configure() { abort_handler src_configure $1 rm -f "$PORTAGE_BUILDDIR/.configured" @@ -865,6 +871,32 @@ abort_install() { exit 1 } +dyn_prepare() { + + if [[ $PORTAGE_BUILDDIR/.prepared -nt $WORKDIR ]] ; then + vecho ">>> It appears that '$PF' is already prepared; skipping." + vecho ">>> Remove '$PORTAGE_BUILDDIR/.prepared' to force prepare." + return 0 + fi + + local srcdir + if [[ -d $S ]] ; then + srcdir=$S + else + srcdir=$WORKDIR + fi + cd "$srcdir" + + trap abort_prepare SIGINT SIGQUIT + + ebuild_phase pre_src_prepare + ebuild_phase src_prepare + touch "$PORTAGE_BUILDDIR"/.prepared + ebuild_phase post_src_prepare + + trap SIGINT SIGQUIT +} + dyn_configure() { if [[ $PORTAGE_BUILDDIR/.configured -nt $WORKDIR ]] ; then @@ -1048,7 +1080,8 @@ dyn_help() { echo " fetch : download source archive(s) and patches" echo " digest : create a manifest file for the package" echo " manifest : create a manifest file for the package" - echo " unpack : unpack/patch sources (auto-fetch if needed)" + echo " unpack : unpack sources (auto-dependencies if needed)" + echo " prepare : prepare sources (auto-dependencies if needed)" echo " configure : configure sources (auto-fetch/unpack if needed)" echo " compile : compile sources (auto-fetch/unpack/configure if needed)" echo " test : test package (auto-fetch/unpack/configure/compile if needed)" @@ -1397,7 +1430,7 @@ _ebuild_phase_funcs() { [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*" local eapi=$1 local phase_func=$2 - local default_phases="pkg_nofetch src_unpack src_configure + local default_phases="pkg_nofetch src_unpack src_prepare src_configure src_compile src_install src_test" local x y default_func="" @@ -1450,6 +1483,7 @@ _ebuild_phase_funcs() { eapi0_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } eapi0_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi0_src_prepare () { die "$FUNCNAME is not supported" ; } eapi0_src_configure () { die "$FUNCNAME is not supported" ; } eapi0_src_compile () { _eapi0_src_compile "$@" ; } eapi0_src_test () { _eapi0_src_test "$@" ; } @@ -1457,6 +1491,7 @@ _ebuild_phase_funcs() { eapi1_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } eapi1_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi1_src_prepare () { die "$FUNCNAME is not supported" ; } eapi1_src_configure () { die "$FUNCNAME is not supported" ; } eapi1_src_compile () { _eapi1_src_compile "$@" ; } eapi1_src_test () { _eapi0_src_test "$@" ; } @@ -1464,6 +1499,7 @@ _ebuild_phase_funcs() { eapi2_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } eapi2_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi2_src_prepare () { true ; } eapi2_src_configure () { _eapi2_src_configure "$@" ; } eapi2_src_compile () { _eapi2_src_compile "$@" ; } eapi2_src_test () { _eapi0_src_test "$@" ; } @@ -1959,7 +1995,7 @@ ebuild_main() { | bzip2 -c -f9 > "$PORTAGE_UPDATE_ENV" fi ;; - unpack|configure|compile|test|clean|install) + unpack|prepare|configure|compile|test|clean|install) if [[ ${SANDBOX_DISABLED:-0} = 0 ]] ; then export SANDBOX_ON="1" else diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 931aec2f7..b509aceb7 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -532,7 +532,7 @@ save_ebuild_env() { if hasq --exclude-init-phases $* ; then unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_ - unset -f pkg_nofetch src_unpack src_configure \ + unset -f pkg_nofetch src_unpack src_prepare src_configure \ src_compile src_test src_install if [[ -n $PYTHONPATH ]] ; then export PYTHONPATH=${PYTHONPATH/${PORTAGE_PYM_PATH}:} @@ -558,7 +558,7 @@ save_ebuild_env() { # There's no need to bloat environment.bz2 with internally defined # functions and variables, so filter them out if possible. - for x in pkg_setup pkg_nofetch src_unpack src_configure \ + for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \ src_compile src_test src_install pkg_preinst pkg_postinst \ pkg_prerm pkg_postrm ; do unset -f {,_}default_$x {,_}eapi{0,1,2}_$x @@ -574,8 +574,8 @@ save_ebuild_env() { keepdir unpack strip_duplicate_slashes econf einstall \ dyn_setup dyn_unpack dyn_clean into insinto exeinto docinto \ insopts diropts exeopts libopts \ - abort_handler abort_configure abort_compile \ - abort_test abort_install dyn_configure \ + abort_handler abort_prepare abort_configure abort_compile \ + abort_test abort_install dyn_prepare dyn_configure \ dyn_compile dyn_test dyn_install \ dyn_preinst dyn_help debug-print debug-print-function \ debug-print-section inherit EXPORT_FUNCTIONS newdepend newrdepend \ diff --git a/bin/portageq b/bin/portageq index 09276526b..7fe52b3da 100755 --- a/bin/portageq +++ b/bin/portageq @@ -214,6 +214,53 @@ def owners(argv): owners.uses_root = True +def is_protected(argv): + """ + Given a single filename, return code 0 if it's protected, 1 otherwise. + The filename must begin with . + """ + if len(argv) != 2: + sys.stderr.write("ERROR: expeced 2 parameters, got %d!\n" % len(argv)) + sys.stderr.flush() + return 2 + + root, filename = argv + + err = sys.stderr + cwd = None + try: + cwd = os.getcwd() + except OSError: + pass + + f = portage.normalize_path(filename) + if not f.startswith(os.path.sep): + if cwd is None: + err.write("ERROR: cwd does not exist!\n") + err.flush() + return 2 + f = os.path.join(cwd, f) + f = portage.normalize_path(f) + + if not f.startswith(root): + err.write("ERROR: file paths must begin with !\n") + err.flush() + return 2 + + import shlex + from portage.util import ConfigProtect + + settings = portage.settings + protect = shlex.split(settings.get("CONFIG_PROTECT", "")) + protect_mask = shlex.split(settings.get("CONFIG_PROTECT_MASK", "")) + protect_obj = ConfigProtect(root, protect, protect_mask) + + if protect_obj.isprotected(f): + return 0 + return 1 + +is_protected.uses_root = True + def best_visible(argv): """ []+ Returns category/package-version (without .ebuild). diff --git a/doc/package/ebuild/eapi/2.docbook b/doc/package/ebuild/eapi/2.docbook index 1a4073e5e..20f7434df 100644 --- a/doc/package/ebuild/eapi/2.docbook +++ b/doc/package/ebuild/eapi/2.docbook @@ -106,7 +106,7 @@ The configure portion of the src_compile function has been split into a separate function which is named src_configure. The - src_configure function is called in between the src_unpack and + src_configure function is called in-between the src_unpack and src_compile functions. @@ -274,3 +274,16 @@ src_compile() { +
+ EAPI 2_pre3 +
+ Phases +
+ New src_prepare Phase Function + + A new src_prepare function is called in-between the src_unpack and + src_configure functions, with cwd initially set to $S. + +
+
+
diff --git a/man/emerge.1 b/man/emerge.1 index e26c4c46f..e4e0533b4 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -471,8 +471,7 @@ command line. .TP \fBROOT\fR = \fI[path]\fR Use \fBROOT\fR to specify the target root filesystem to be used for -merging packages or ebuilds. This variable can be set in \fBmake.conf\fR(5) -when \fBPORTAGE_CONFIGROOT\fR has a value other than /. +merging packages or ebuilds. This variable can be set in \fBmake.conf\fR(5). .br Defaults to /. .TP diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 953728d1d..0c0230d7c 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -2615,7 +2615,7 @@ class EbuildExecuter(CompositeTask): __slots__ = ("pkg", "scheduler", "settings") + ("_tree",) - _phases = ("configure", "compile", "test", "install") + _phases = ("prepare", "configure", "compile", "test", "install") _live_eclasses = frozenset([ "cvs", @@ -2686,9 +2686,12 @@ class EbuildExecuter(CompositeTask): pkg = self.pkg phases = self._phases - EAPIPREFIX - if pkg.metadata["EAPI"].replace(EAPIPREFIX, "").strip() in ("0", "1", "2_pre1"): - # skip src_configure + eapi = pkg.metadata["EAPI"].replace(EAPIPREFIX, "").strip() + if eapi in ("0", "1", "2_pre1"): + # skip src_prepare and src_configure + phases = phases[2:] + elif eapi in ("2_pre2",): + # skip src_prepare phases = phases[1:] for phase in phases: @@ -6787,7 +6790,6 @@ class depgraph(object): return ret repo_display = RepoDisplay(self.roots) - show_repos = False tree_nodes = [] display_list = [] @@ -6938,6 +6940,10 @@ class depgraph(object): # in size display (verbose mode) myfetchlist=[] + # Use this set to detect when all the "repoadd" strings are "[0]" + # and disable the entire repo display in this case. + repoadd_set = set() + for mylist_index in xrange(len(mylist)): x, depth, ordered = mylist[mylist_index] pkg_type = x[0] @@ -7086,7 +7092,8 @@ class depgraph(object): counters.new += 1 verboseadd = "" - + repoadd = None + if True: # USE flag display forced_flags = set() @@ -7206,7 +7213,7 @@ class depgraph(object): myfetchlist.append(myfetchfile) if ordered: counters.totalsize += mysize - verboseadd+=format_size(mysize)+" " + verboseadd += format_size(mysize) # overlay verbose # assign index for a previous version in the same slot @@ -7221,7 +7228,6 @@ class depgraph(object): ["repository"])[0] # now use the data to generate output - repoadd = None if pkg.installed or not has_previous: repoadd = repo_display.repoStr(repo_path_real) else: @@ -7235,9 +7241,8 @@ class depgraph(object): repoadd = "%s=>%s" % ( repo_display.repoStr(repo_path_prev), repo_display.repoStr(repo_path_real)) - if repoadd and repoadd != "0": - show_repos = True - verboseadd += teal("[%s]" % repoadd) + if repoadd: + repoadd_set.add(repoadd) xs = [portage.cpv_getkey(pkg_key)] + \ list(portage.catpkgsplit(pkg_key)[2:]) @@ -7318,6 +7323,7 @@ class depgraph(object): myprint=myprint+darkblue(" "+xs[1]+xs[2])+" " myprint=myprint+myoldbest myprint=myprint+darkgreen("to "+x[1]) + verboseadd = None else: if not pkg_merge: myprint = "[%s] %s%s" % \ @@ -7333,21 +7339,21 @@ class depgraph(object): if (oldlp-nc_len(myprint)) > 0: myprint=myprint+" "*(oldlp-nc_len(myprint)) myprint=myprint+myoldbest - myprint=myprint+darkgreen("to "+x[1])+" "+verboseadd + myprint += darkgreen("to " + pkg.root) else: if not pkg_merge: myprint = "[%s] " % pkgprint(pkg_status.ljust(13)) else: myprint = "[" + pkg_type + " " + addl + "] " myprint += indent + pkgprint(pkg_key) + " " + \ - myoldbest + darkgreen("to " + myroot) + " " + \ - verboseadd + myoldbest + darkgreen("to " + myroot) else: if "--columns" in self.myopts: if "--quiet" in self.myopts: myprint=addl+" "+indent+pkgprint(pkg_cp) myprint=myprint+" "+green(xs[1]+xs[2])+" " myprint=myprint+myoldbest + verboseadd = None else: if not pkg_merge: myprint = "[%s] %s%s" % \ @@ -7362,16 +7368,19 @@ class depgraph(object): myprint=myprint+green(" ["+xs[1]+xs[2]+"] ") if (oldlp-nc_len(myprint)) > 0: myprint=myprint+(" "*(oldlp-nc_len(myprint))) - myprint=myprint+myoldbest+" "+verboseadd + myprint += myoldbest else: if not pkg_merge: - myprint = "[%s] %s%s %s %s" % \ + myprint = "[%s] %s%s %s" % \ (pkgprint(pkg_status.ljust(13)), indent, pkgprint(pkg.cpv), - myoldbest, verboseadd) + myoldbest) else: - myprint="["+pkgprint(pkg_type)+" "+addl+"] "+indent+pkgprint(pkg_key)+" "+myoldbest+" "+verboseadd - p.append(myprint) + myprint = "[%s %s] %s%s %s" % \ + (pkgprint(pkg_type), addl, indent, + pkgprint(pkg.cpv), myoldbest) + + p.append((myprint, verboseadd, repoadd)) if "--tree" not in self.myopts and \ "--quiet" not in self.myopts and \ @@ -7391,8 +7400,24 @@ class depgraph(object): p.append(colorize("WARN", "*** Portage will stop merging at this point and reload itself,")) p.append(colorize("WARN", " then resume the merge.")) + out = sys.stdout + show_repos = repoadd_set != set(["0"]) + for x in p: - print x + if isinstance(x, basestring): + out.write("%s\n" % (x,)) + continue + + myprint, verboseadd, repoadd = x + + if verboseadd: + myprint += " " + verboseadd + + if show_repos: + myprint += " " + teal("[%s]" % repoadd) + + out.write("%s\n" % (myprint,)) + for x in blockers: print x diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 6da037e19..9372f33f7 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -4344,7 +4344,12 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0, if retval: return retval - if mydo == "configure" and mysettings["EAPI"] in ("0", "1", "2_pre1"): + eapi = mysettings["EAPI"] + + if mydo == "configure" and eapi in ("0", "1", "2_pre1"): + return os.EX_OK + + if mydo == "prepare" and eapi in ("0", "1", "2_pre1", "2_pre2"): return os.EX_OK kwargs = actionmap[mydo]["args"] @@ -4615,7 +4620,7 @@ def eapi_is_supported(eapi): eapi.remove(prop) # now check if what's left is supported (can) - properties = [ "2_pre2", "2_pre1" ] # another clumpsy solution + properties = [ "2_pre3", "2_pre2", "2_pre1" ] # another clumpsy solution for i in range(portage.const.EAPI + 1): properties.append(str(i)) @@ -5153,7 +5158,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, actionmap_deps={ "setup": [], "unpack": ["setup"], - "configure": ["unpack"], + "prepare": ["unpack"], + "configure": ["prepare"], "compile":["configure"], "test": ["compile"], "install":["test"], @@ -5175,7 +5181,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst", "config", "info", "setup", "depend", "fetch", "fetchall", "digest", - "unpack", "configure", "compile", "test", + "unpack", "prepare", "configure", "compile", "test", "install", "rpm", "qmerge", "merge", "package","unmerge", "manifest"] @@ -5447,7 +5453,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, writemsg("Can not execute files in %s\n" % checkdir + \ "Likely cause is that you've mounted it with one of the\n" + \ "following mount options: 'noexec', 'user', 'users'\n\n" + \ - "Please make sure that portage can execute files in this direxctory.\n" \ + "Please make sure that portage can execute files in this directory.\n" \ , noiselevel=-1) fd.close() return 1 @@ -5761,6 +5767,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, actionmap = { "setup": {"cmd":ebuild_sh, "args":{"droppriv":0, "free":1, "sesandbox":0, "fakeroot":0}}, "unpack": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0, "sesandbox":sesandbox, "fakeroot":0}}, +"prepare": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0, "sesandbox":sesandbox, "fakeroot":0}}, "configure":{"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}}, "compile": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}}, "test": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}}, diff --git a/pym/portage/const.py b/pym/portage/const.py index 51a123e86..d04ab0f4e 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -79,7 +79,7 @@ INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES", "ACCEPT_KEYWORDS", "ACCEPT_LICENSE", "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"] -EBUILD_PHASES = ["setup", "unpack", "configure", +EBUILD_PHASES = ["setup", "unpack", "prepare", "configure", "compile", "test", "install", "package", "preinst", "postinst","prerm", "postrm", "nofetch", "config", "info", "other"] diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 1e33a353b..a47ce9159 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1843,8 +1843,8 @@ class dblink(object): self.myroot=myroot protect_obj = ConfigProtect(myroot, - mysettings.get("CONFIG_PROTECT","").split(), - mysettings.get("CONFIG_PROTECT_MASK","").split()) + shlex.split(mysettings.get("CONFIG_PROTECT", "")), + shlex.split(mysettings.get("CONFIG_PROTECT_MASK", ""))) self.updateprotect = protect_obj.updateprotect self.isprotected = protect_obj.isprotected self._installed_instance = None @@ -2800,8 +2800,9 @@ class dblink(object): if f[0] != "/": f="/"+f isowned = False + full_path = os.path.join(destroot, f.lstrip(os.path.sep)) for ver in [self] + mypkglist: - if (ver.isowner(f, destroot) or ver.isprotected(f)): + if (ver.isowner(f, destroot) or ver.isprotected(full_path)): isowned = True break if not isowned: -- 2.26.2