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"
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"
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
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)"
[ $# -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=""
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 "$@" ; }
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 "$@" ; }
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 "$@" ; }
| 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
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}:}
# 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
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 \
owners.uses_root = True
+def is_protected(argv):
+ """<root> <filename>
+ Given a single filename, return code 0 if it's protected, 1 otherwise.
+ The filename must begin with <root>.
+ """
+ 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 <root>!\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):
"""<root> [<category/package>]+
Returns category/package-version (without .ebuild).
<para>
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.
</para>
<programlisting>
</section>
</section>
</section>
+<section id='package-ebuild-eapi-2_pre3'>
+ <title>EAPI 2_pre3</title>
+ <section id='package-ebuild-eapi-2-phases'>
+ <title>Phases</title>
+ <section id='package-ebuild-eapi-2-phases-src-prepare'>
+ <title>New src_prepare Phase Function</title>
+ <para>
+ A new src_prepare function is called in-between the src_unpack and
+ src_configure functions, with cwd initially set to $S.
+ </para>
+ </section>
+ </section>
+</section>
.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
__slots__ = ("pkg", "scheduler", "settings") + ("_tree",)
- _phases = ("configure", "compile", "test", "install")
+ _phases = ("prepare", "configure", "compile", "test", "install")
_live_eclasses = frozenset([
"cvs",
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:
return ret
repo_display = RepoDisplay(self.roots)
- show_repos = False
tree_nodes = []
display_list = []
# 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]
counters.new += 1
verboseadd = ""
-
+ repoadd = None
+
if True:
# USE flag display
forced_flags = set()
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
["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:
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:])
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" % \
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" % \
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 \
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
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"]
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))
actionmap_deps={
"setup": [],
"unpack": ["setup"],
- "configure": ["unpack"],
+ "prepare": ["unpack"],
+ "configure": ["prepare"],
"compile":["configure"],
"test": ["compile"],
"install":["test"],
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"]
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
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}},
"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"]
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
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: