export PATH="${PREFIX}/sbin:${PREFIX}/usr/sbin:@PORTAGE_BASE@/bin:${PREFIX}/bin:${PREFIX}/usr/bin:${ROOTPATH}"
[ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH"
-source @PORTAGE_BASE@/bin/isolated-functions.sh &>/dev/null
+source /usr/lib/portage/bin/isolated-functions.sh &>/dev/null
+# TODO: make this conditional on config settings, fix any remaining stuff
+set_colors
# the sandbox is disabled by default except when overridden in the relevant stages
export SANDBOX_ON="0"
# sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (/usr/lib64/conftest fex, bug #60147)
-addread()
-{
+addread() {
export SANDBOX_READ="$SANDBOX_READ:$1"
}
-addwrite()
-{
+addwrite() {
export SANDBOX_WRITE="$SANDBOX_WRITE:$1"
}
-adddeny()
-{
+adddeny() {
export SANDBOX_DENY="$SANDBOX_DENY:$1"
}
-addpredict()
-{
+addpredict() {
export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1"
}
-lchown()
-{
+lchown() {
chown -h "$@"
}
-lchgrp()
-{
+lchgrp() {
chgrp -h "$@"
}
neg=1
fi
local x
-
+
# Make sure we have this USE flag in IUSE
if ! hasq "${u}" ${IUSE} ${E_IUSE} && ! hasq "${u}" ${PORTAGE_ARCHLIST} selinux; then
echo "QA Notice: USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}" >&2
local me=$1
shift
-
+
# All the TTY checks really only help out depend. Which is nice.
# Logging kills all this anyway. Everything becomes a pipe. --NJ
for x in "$@"; do
return 1
fi
- local UW_SUFFIX=""
+ local UW_SUFFIX=""
if [ ! -z "${3}" ]; then
UW_SUFFIX="=${3}"
fi
if [ -z "${UWORD}" ]; then
UWORD="$1"
fi
-
+
if useq $1; then
echo "--with-${UWORD}${UW_SUFFIX}"
else
return 1
fi
- local UE_SUFFIX=""
+ local UE_SUFFIX=""
if [ ! -z "${3}" ]; then
UE_SUFFIX="=${3}"
fi
if [ -z "${UWORD}" ]; then
UWORD="$1"
fi
-
+
if useq $1; then
echo "--enable-${UWORD}${UE_SUFFIX}"
else
export EXEDESTTREE=""
export DOCDESTTREE=""
export INSOPTIONS="-m0644"
-export EXEOPTIONS="-m0755"
+export EXEOPTIONS="-m0755"
export LIBOPTIONS="-m0644"
export DIROPTIONS="-m0755"
export MOPREFIX=${PN}
-check_KV()
-{
+check_KV() {
if [ -z "${KV}" ]; then
eerror ""
eerror "Could not determine your kernel version."
}
# adds ".keep" files so that dirs aren't auto-cleaned
-keepdir()
-{
+keepdir() {
dodir "$@"
local x
if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then
if [ "$USERLAND" == "BSD" ]; then
tarvars=""
else
- tarvars="--no-same-owner"
- fi
+ tarvars="--no-same-owner"
+ fi
[ -z "$*" ] && die "Nothing passed to the 'unpack' command"
;;
bz2)
if [ "${y}" == "tar" ]; then
- bzip2 -dc "${srcdir}${x}" | tar xf - ${tarvars}
+ bzip2 -dc "${srcdir}${x}" | tar xf - ${tarvars}
assert "$myfail"
else
bzip2 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
done
}
-strip_duplicate_slashes () {
+strip_duplicate_slashes () {
if [ -n "${1}" ]; then
local removed="${1/\/\///}"
[ "${removed}" != "${removed/\/\///}" ] && removed=$(strip_duplicate_slashes "${removed}")
if [ ! -z "${CTARGET}" ]; then
LOCAL_EXTRA_ECONF="--target=${CTARGET} ${LOCAL_EXTRA_ECONF}"
fi
-
+
# if the profile defines a location to install libs to aside from default, pass it on.
# if the ebuild passes in --libdir, they're responsible for the conf_libdir fun.
LIBDIR_VAR="LIBDIR_${ABI}"
LOCAL_EXTRA_ECONF="--libdir=${CONF_LIBDIR_RESULT} ${LOCAL_EXTRA_ECONF}"
fi
-
+
echo "${ECONF_SOURCE}/configure" \
--prefix=${PREFIX}/usr \
--host=${CHOST} \
fi
}
-pkg_setup()
-{
+pkg_setup() {
return
}
-pkg_nofetch()
-{
+pkg_nofetch() {
[ -z "${SRC_URI}" ] && return
echo "!!! The following are listed in SRC_URI for ${PN}:"
src_unpack() {
if [ "${A}" != "" ]; then
unpack ${A}
- fi
+ fi
}
src_compile() {
fi
}
-src_test()
-{
+src_test() {
addpredict /
- if make check -n &> /dev/null; then
+ if emake -j1 check -n &> /dev/null; then
echo ">>> Test phase [check]: ${CATEGORY}/${PF}"
- if ! make check; then
+ if ! emake -j1 check; then
hasq test $FEATURES && die "Make check failed. See above for details."
hasq test $FEATURES || eerror "Make check failed. See above for details."
fi
- elif make test -n &> /dev/null; then
+ elif emake -j1 test -n &> /dev/null; then
echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
- if ! make test; then
+ if ! emake -j1 test; then
hasq test $FEATURES && die "Make test failed. See above for details."
hasq test $FEATURES || eerror "Make test failed. See above for details."
fi
SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
}
-src_install()
-{
+src_install() {
return
}
-pkg_preinst()
-{
+pkg_preinst() {
return
}
-pkg_postinst()
-{
+pkg_postinst() {
return
}
-pkg_prerm()
-{
+pkg_prerm() {
return
}
-pkg_postrm()
-{
+pkg_postrm() {
return
}
-pkg_config()
-{
+pkg_config() {
eerror "This ebuild does not have a config function."
}
chmod 0755 $1
}
-dyn_setup()
-{
+dyn_setup() {
[ "$(type -t pre_pkg_setup)" == "function" ] && pre_pkg_setup
pkg_setup
[ "$(type -t post_pkg_setup)" == "function" ] && post_pkg_setup
return 0
fi
fi
-
+
install -m0700 -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
[ -d "$WORKDIR" ] && cd "${WORKDIR}"
echo ">>> Unpacking source..."
chflags -R noschg,nouchg,nosappnd,nouappnd,nosunlnk,nouunlnk \
"${BUILDDIR}"
fi
-
+
if [ "$USERLAND" == "Darwin" ] && type -p chflags &>/dev/null; then
chflags -R noschg,nouchg,nosappnd,nouappnd "${BUILDDIR}"
fi
sleep 3
fi
+ local srcdir=${BUILDDIR}
cd "${BUILDDIR}"
- if [ ! -e "build-info" ]; then
+ if [ ! -e "build-info" ]; then
mkdir build-info
fi
cp "${EBUILD}" "build-info/${PF}.ebuild"
-
+
if [ ${BUILDDIR}/.compiled -nt "${WORKDIR}" ]; then
echo ">>> It appears that ${PN} is already compiled; skipping."
echo ">>> (clean to force compilation)"
return
fi
if [ -d "${S}" ]; then
+ srcdir=${S}
cd "${S}"
fi
#our custom version of libtool uses $S and $D to fix
#some packages use an alternative to $S to build in, cause
#our libtool to create problematic .la files
export PWORKDIR="$WORKDIR"
+ echo ">>> Compiling source in ${srcdir} ..."
src_compile
+ echo ">>> Source compiled."
#|| abort_compile "fail"
cd "${BUILDDIR}"
touch .compiled
if [ -d "${S}" ]; then
cd "${S}"
fi
- if hasq maketest $RESTRICT || hasq test $RESTRICT; then
+ if hasq test $RESTRICT; then
ewarn "Skipping make test/check due to ebuild restriction."
echo ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
elif ! hasq test $FEATURES; then
echo ">>> Test phase [not enabled]: ${CATEGORY}/${PF}"
else
- echo ">>> Test phase [enabled]: ${CATEGORY}/${PF}"
src_test
fi
[ "$(type -t post_src_test)" == "function" ] && post_src_test
trap SIGINT SIGQUIT
}
-
PORTAGE_INST_UID="0"
PORTAGE_INST_GID="0"
echo "UNSAFE SetUID: $i"
chmod -s,o-w "$i"
done
-
+
# Now we look for all world writable files.
for i in $(find "${D}/" -type f -perm -2); do
echo -ne '\a'
done
if type -p scanelf > /dev/null ; then
+ local qa_sucks_for_sure=0 qa_kinda_sucks=0
+
# Make sure we disallow insecure RUNPATH/RPATH's
# Don't want paths that point to the tree where the package was built
# (older, broken libtools would do this). Also check for null paths
echo " http://bugs.gentoo.org/81745"
echo "${f}"
echo -ne '\a\n'
- die "Insecure binaries detected"
+ qa_sucks_for_sure=1
fi
# Check for setid binaries but are not built with BIND_NOW
echo " LDFLAGS='-Wl,-z,now' emerge ${PN}"
echo "${f}"
echo -ne '\a\n'
- [[ ${FEATURES/stricter} != "${FEATURES}" ]] \
- && die "Aborting due to lazy bindings"
+ qa_kinda_sucks=1
sleep 1
fi
echo " consider writing a patch which addresses this problem."
echo "${f}"
echo -ne '\a\n'
- [[ ${FEATURES/stricter} != "${FEATURES}" ]] \
- && die "Aborting due to textrels"
+ qa_kinda_sucks=1
sleep 1
fi
echo " at http://bugs.gentoo.org/ to make sure the file is fixed."
echo "${f}"
echo -ne '\a\n'
- [[ ${FEATURES/stricter} != "${FEATURES}" ]] \
- && die "Aborting due to +x stack"
+ qa_kinda_sucks=1
sleep 1
fi
# Save NEEDED information
scanelf -qyRF '%p %n' "${D}" | sed -e 's:^:/:' > "${BUILDDIR}"/build-info/NEEDED
+
+ if [[ ${qa_sucks_for_sure} -eq 1 ]] ; then
+ die "Aborting due to serious QA concerns"
+ elif [[ ${qa_kinda_sucks} -eq 1 ]] && has stricter ${FEATURES} && ! has stricter ${RESTRICT} ; then
+ die "Aborting due to QA concerns"
+ fi
fi
if [[ ${UNSAFE} > 0 ]] ; then
die "There are ${UNSAFE} unsafe files. Portage will not install them."
fi
-
+
# dumps perms to stdout. if error, no perms dumped.
function stat_perms() {
local f
# set IMAGE depending if this is a binary or compile merge
[ "${EMERGE_FROM}" == "binary" ] && IMAGE=${PKG_TMPDIR}/${PF}/bin \
|| IMAGE=${D}
-
+
[ "$(type -t pre_pkg_preinst)" == "function" ] && pre_pkg_preinst
declare -r D=${IMAGE}
[ -z "$T" ] && return 0
while [ "$1" ]; do
-
+
# extra user-configurable targets
if [ "$ECLASS_DEBUG_OUTPUT" == "on" ]; then
echo "debug: $1"
elif [ -n "$ECLASS_DEBUG_OUTPUT" ]; then
echo "debug: $1" >> $ECLASS_DEBUG_OUTPUT
fi
-
+
# default target
echo "$1" >> "${T}/eclass-debug.log"
# let the portage user own/write to this file
chmod g+w "${T}/eclass-debug.log" &>/dev/null
-
+
shift
done
}
#We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
#(if set).. and then restore them after the inherit call.
-
+
#turn off glob expansion
set -f
unset IUSE DEPEND RDEPEND PDEPEND
#turn on glob expansion
set +f
-
+
source "$location" || export ERRORMSG="died sourcing $location in inherit()"
[ -z "${ERRORMSG}" ] || die "${ERRORMSG}"
-
+
#turn off glob expansion
set -f
#turn on glob expansion
set +f
-
+
hasq $1 $INHERITED || export INHERITED="$INHERITED $1"
export ECLASS="$PECLASS"
# for X in @PORTAGE_BASE@/bin/functions/*.sh; do
# source ${X} || die "Failed to source ${X}"
# done
-
+
else
killparent() {
#!@PYTHON@ -O
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: /var/cvsroot/gentoo-src/portage/bin/emerge,v 1.345.2.38 2005/08/13 17:25:26 ferringb Exp $
sys.stdout.write("\b\b "+spinner[spinpos])
sys.stdout.flush()
+def update_quiet_spinner():
+ return
+
spinpos = 0
spinner = "/-\\|/-\\|/-\\|/-\\|\\-/|\\-/|\\-/|\\-/|"
update_spinner = update_twirl_spinner
params=["selective", "deep", "self", "recurse", "empty"]
actions=[
"clean", "config", "depclean",
-"info", "inject", "metadata",
+"info", "inject", "metadata",
"prune", "regen", "rsync", "search",
"sync", "system", "unmerge", "world",
]
options=[
"--ask",
"--buildpkg", "--buildpkgonly",
-"--changelog", "--columns",
+"--changelog", "--columns", "--cols",
"--debug", "--deep",
"--digest",
"--emptytree",
#tmpcmdline.extend(portage.settings["EMERGE_OPTS"].split())
cmdline=[]
for x in tmpcmdline:
- if x[0:1]=="-"and x[1:2]!="-":
+ if x[0:1]=="-" and x[1:2]!="-":
for y in x[1:]:
if shortmapping.has_key(y):
if shortmapping[y] in cmdline:
if not x:
continue
if len(x)>=2 and x[0:2]=="--":
+ if x == "--cols":
+ x = "--columns"
if x in options:
myopts.append(x)
elif x[2:] in actions:
print "emerge: can't specify both of \"--tree\" and \"--columns\"."
sys.exit(1)
+if ("--quiet" in myopts):
+ update_spinner = update_quiet_spinner
+
# Always create packages if FEATURES=buildpkg
# Imply --buildpkg if --buildpkgonly
if ("buildpkg" in portage.features) or ("--buildpkgonly" in myopts):
print "="+string.join(sp_absx[sp_vdb_len:],"/")
candidate_catpkgs.append("="+string.join(sp_absx[sp_vdb_len:],"/"))
- if ("--pretend" in myopts) or ("--ask" in myopts):
+ if (("--pretend" in myopts) or ("--ask" in myopts)) and not ("--quiet" in myopts):
print darkgreen("\n>>> These are the packages that I would unmerge:")
pkgmap={}
"--delete", # Delete files that aren't in the master tree
"--delete-after", # Delete only after everything else is done
"--stats", # Show final statistics about what was transfered
- "--timeout="+str(mytimeout), # IO timeout if not done in X seconds
+ "--timeout="+str(mytimeout), # IO timeout if not done in X seconds
"--exclude='/distfiles'", # Exclude distfiles from consideration
"--exclude='/local'", # Exclude local from consideration
"--exclude='/packages'", # Exclude packages from consideration
i = conf.categories.index("virtual")
if i != -1:
conf.categories.remove(i)
- except (ValueError, IndexError):
+ except (ValueError, IndexError):
pass
pdb = portage.portdbapi(porttree_root, conf)
def __init__(self, dbapi):
self.dbapi = dbapi
self.cp_all = dbapi.cp_all()
- self.cp_all.sort()
l = len(self.cp_all)
self.call_update_min = 100000000
self.min_cp_all = l/100.0
self.count = 1
self.pstr = ''
-
+
def __iter__(self):
for x in self.cp_all:
self.count += 1
for y in self.dbapi.cp_list(x):
yield y
self.call_update_mine = 0
-
+
def update(self, *arg):
try: self.pstr = int(self.pstr) + 1
except ValueError: self.pstr = 1
sys.stdout.write("%s%i%%" % ("\b" * (len(str(self.pstr))+1), self.pstr))
sys.stdout.flush()
self.call_update_min = 10000000
-
+
def finish(self, *arg):
sys.stdout.write("\b\b\b\b100%\n")
sys.stdout.flush()
else:
noise_maker = source = percentage_noise_maker(pdb)
cache.util.mirror_cache(source, cm, pdb.auxdb[porttree_root], eclass_cache=ec, verbose_instance=noise_maker)
-
+
sys.stdout.flush()
portage.portageexit()
emergelog(" >>> depclean")
mydepgraph=depgraph(myaction,myopts)
- print "\nCalculating dependencies ",
+ if not ("--quiet" in myopts):
+ print "\nCalculating dependencies ",
if not mydepgraph.xcreate("world"):
print "\n!!! Failed to create deptree."
sys.exit(1)
- print "\b\b ... done!"
+ if not ("--quiet" in myopts):
+ print "\b\b ... done!"
if ("--usepkgonly" in myopts) and mydepgraph.missingbins:
sys.stderr.write(red("The following binaries are not available for merging...\n"))
else:
favorites=[]
syslist=getlist("system")
- if (("--pretend" in myopts) and not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts)) or ("--ask" in myopts):
+ if ((("--pretend" in myopts) and not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts)) or ("--ask" in myopts)) and not ("--quiet" in myopts):
if "--tree" in myopts:
print
print darkgreen("These are the packages that I would merge, in reverse order:")
mydepgraph=depgraph(myaction,myopts)
if myaction in ["system","world"]:
- print "Calculating",myaction,"dependencies ",
- sys.stdout.flush()
+ if not ("--quiet" in myopts):
+ print "Calculating",myaction,"dependencies ",
+ sys.stdout.flush()
if not mydepgraph.xcreate(myaction):
print "!!! Depgraph creation failed."
sys.exit(1)
- print "\b\b ...done!"
+ if not ("--quiet" in myopts):
+ print "\b\b ...done!"
else:
if not myfiles:
print "emerge: please tell me what to do."
help()
sys.exit(1)
#we don't have any files to process; skip this step and exit
- print "Calculating dependencies ",
- sys.stdout.flush()
+ if not ("--quiet" in myopts):
+ print "Calculating dependencies ",
+ sys.stdout.flush()
retval,favorites=mydepgraph.select_files(myfiles)
if not retval:
sys.exit(1)
- print "\b\b ...done!"
+ if not ("--quiet" in myopts):
+ print "\b\b ...done!"
if ("--usepkgonly" in myopts) and mydepgraph.missingbins:
sys.stderr.write(red("The following binaries are not available for merging...\n"))
os.environ["PORTAGE_CALLER"] = "portageq"
sys.path = ["@PORTAGE_BASE@/pym"]+sys.path
-import portage,types,string
+import types,string
#-----------------------------------------------------------------------------
def envvar(argv):
- """<variable>
+ """<variable>+
Returns a specific environment variable as exists prior to ebuild.sh.
Similar to: emerge --verbose --info | @EGREP@ '^<variable>='
"""
- print portage.settings[argv[0]]
+ if (argv[0] == "-v"):
+ verbose=1
+ argv=argv[1:]
+ else:
+ verbose=0
+ for arg in argv:
+ if verbose:
+ print arg +"='"+ portage.settings[arg] +"'"
+ else:
+ print portage.settings[arg]
#-----------------------------------------------------------------------------
lines = string.split(doc, '\n')
print " "+name+" "+string.strip(lines[0])
- for line in lines[1:]:
- print " "+string.strip(line)
-
+ if (len(sys.argv) > 1):
+ if ("--help" not in sys.argv):
+ lines = lines[:-1]
+ for line in lines[1:]:
+ print " "+string.strip(line)
+ if (len(sys.argv) == 1):
+ print "\nRun portageq with --help for info"
def main():
- if (len(sys.argv) < 2):
+ if (len(sys.argv) < 2) or ("-h" in sys.argv or "--help" in sys.argv):
usage(sys.argv)
sys.exit()
-
+
+ # no more fatties
+ global portage
+ import portage
+
cmd = sys.argv[1]
try:
function = globals()[cmd]
function(sys.argv[2:])
except KeyError:
- usage()
+ usage(sys.argv)
sys.exit()
main()
from portage_checksum import perform_md5,perform_checksum,prelink_capable
import eclass_cache
from portage_localization import _
+
+ # Need these functions directly in portage namespace to not break every external tool in existence
+ from portage_versions import ververify,vercmp,catsplit,catpkgsplit,pkgsplit,pkgcmp
+
except SystemExit, e:
raise
except Exception, e:
mygraph.okeys=self.okeys[:]
return mygraph
+def elog_process(cpv, mysettings):
+ mylogfiles = listdir(mysettings["T"]+"/logging/")
+ # shortcut for packages without any messages
+ if len(mylogfiles) == 0:
+ return
+ # exploit listdir() file order so we process log entries in cronological order
+ mylogfiles.reverse()
+ mylogentries = {}
+ for f in mylogfiles:
+ msgfunction, msgtype = f.split(".")
+ if not msgtype.upper() in mysettings["PORTAGE_ELOG_CLASSES"].split() \
+ and not msgtype.lower() in mysettings["PORTAGE_ELOG_CLASSES"].split():
+ continue
+ if msgfunction not in portage_const.EBUILD_PHASES:
+ print "!!! can't process invalid log file: %s" % f
+ continue
+ if not msgfunction in mylogentries:
+ mylogentries[msgfunction] = []
+ msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines()
+ mylogentries[msgfunction].append((msgtype, msgcontent))
+
+ # in case the filters matched all messages
+ if len(mylogentries) == 0:
+ return
+
+ # generate a single string with all log messages
+ fulllog = ""
+ for phase in portage_const.EBUILD_PHASES:
+ if not phase in mylogentries:
+ continue
+ for msgtype,msgcontent in mylogentries[phase]:
+ fulllog += "%s: %s\n" % (msgtype, phase)
+ for line in msgcontent:
+ fulllog += line
+ fulllog += "\n"
+
+ # pass the processing to the individual modules
+ logsystems = mysettings["PORTAGE_ELOG_SYSTEM"].split()
+ for s in logsystems:
+ try:
+ # FIXME: ugly ad.hoc import code
+ # TODO: implement a common portage module loader
+ logmodule = __import__("elog_modules.mod_"+s)
+ m = getattr(logmodule, "mod_"+s)
+ m.process(mysettings, cpv, mylogentries, fulllog)
+ except (ImportError, AttributeError), e:
+ print "!!! Error while importing logging modules while loading \"mod_%s\":" % s
+ print e
+ except portage_exception.PortageException, e:
+ print e
+
# valid end of version components; integers specify offset from release version
# pre=prerelease, p=patchlevel (should always be followed by an int), rc=release candidate
# all but _p (where it is required) can be followed by an optional trailing integer
writemsg("PORTAGE_GPG_DIR is invalid. Removing gpg from FEATURES.\n")
self.features.remove("gpg")
- if "maketest" in self.features and "test" not in self.features:
- self.features.append("test")
-
if not portage_exec.sandbox_capable and ("sandbox" in self.features or "usersandbox" in self.features):
writemsg(red("!!! Problem with sandbox binary. Disabling...\n\n"))
if "sandbox" in self.features:
self.already_in_regenerate = 0
def getvirtuals(self, myroot):
+ if self.virtuals:
+ return self.virtuals
+
myvirts = {}
# This breaks catalyst/portage when setting to a fresh/empty root.
return 1
-def digestcheck(myfiles, mysettings, strict=0):
+def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
"""Checks md5sums. Assumes all files have been downloaded."""
# archive files
basedir=mysettings["DISTDIR"]+"/"
print "--- Manifest check failed. 'strict' not enabled; ignoring."
print
+ if justmanifest:
+ return 1
+
# Just return the status, as it's the last check.
return digestCheckFiles(myfiles, mydigests, basedir, note="src_uri", strict=strict)
mysettings["PV"] = mysplit[1]
mysettings["PR"] = mysplit[2]
mysettings["PREFIX"] = portage_const.PREFIX
-
if mydo != "depend":
try:
mysettings["INHERITED"], mysettings["RESTRICT"] = db[root][tree].dbapi.aux_get( \
mysettings["DEST"]=os.path.join(mysettings["BUILDDIR"],"image")
mysettings["D"]=mysettings["BUILDDIR"]+"/image"+portage_const.PREFIX
if mysettings.has_key("PORT_LOGDIR"):
+ if not os.access(mysettings["PORT_LOGDIR"],os.F_OK):
+ try:
+ os.mkdir(mysettings["PORT_LOGDIR"])
+ except OSError:
+ print "!!! Unable to create PORT_LOGDIR"
+ print "!!!",e
if os.access(mysettings["PORT_LOGDIR"]+"/",os.W_OK):
try:
os.chown(mysettings["PORT_LOGDIR"],portage_uid,portage_gid)
except:
pass
- if mydo!="manifest" and not fetch(fetchme, mysettings, listonly=listonly, fetchonly=fetchonly):
+ # Only try and fetch the files if we are going to need them ... otherwise,
+ # if user has FEATURES=noauto and they run `ebuild clean unpack compile install`,
+ # we will try and fetch 4 times :/
+ if (mydo in ["digest","fetch","unpack"] or "noauto" not in features) and \
+ not fetch(fetchme, mysettings, listonly=listonly, fetchonly=fetchonly):
return 1
if mydo=="fetch" and listonly:
if mydo=="manifest":
return (not digestgen(aalist,mysettings,overwrite=1,manifestonly=1))
- if not digestcheck(checkme, mysettings, ("strict" in features)):
+ # See above comment about fetching only when needed
+ if not digestcheck(checkme, mysettings, ("strict" in features), (mydo not in ["digest","fetch","unpack"] and settings["PORTAGE_CALLER"] == "ebuild" and "noauto" in features)):
return 1
if mydo=="fetch":
def counter_tick_core(self,myroot,incrementing=1,mycpv=None):
"This method will grab the next COUNTER value and record it back to the global file. Returns new counter value."
- cpath=myroot+portage_const.CACHE_PATH+"/counter"
+ cpath=os.path.normpath(myroot+portage_const.CACHE_PATH+"/counter")
changed=0
min_counter = 0
if mycpv:
INCREMENTALS=["USE","USE_EXPAND","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"]
STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"]
-
+EBUILD_PHASES = ["setup","unpack","compile","test","install","preinst","postinst","prerm","postrm"]
DEFAULT_PATH = ":".join(map(lambda x: os.path.join(PREFIX, x), ["/sbin", "/usr/sbin/", "/bin", "/usr/bin"]))
-EAPI = 0
+EAPI = "prefix"
# ===========================================================================
# END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT
os.environ["XARGS"]="xargs"
def lchown(*pos_args, **key_args):
pass
-elif ostype in ["FreeBSD","OpenBSD"]:
+elif ostype in ["FreeBSD","OpenBSD","NetBSD"]:
userland="BSD"
os.environ["XARGS"]="xargs"
else:
sys.stderr.write(mystr)
sys.stderr.flush()
-def grabfile(myfilename, compat_level=0):
+def grabfile(myfilename, compat_level=0, recursive=0):
"""This function grabs the lines in a file, normalizes whitespace and returns lines in a list; if a line
begins with a #, it is ignored, as are empty lines"""
- try:
- myfile=open(myfilename,"r")
- except IOError:
- return []
- mylines=myfile.readlines()
- myfile.close()
+ mylines=grablines(myfilename, recursive)
newlines=[]
for x in mylines:
#the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
mylist.append(handler(x+"/"+basename))
return mylist
-def grabdict(myfilename,juststrings=0,empty=0):
+def grabdict(myfilename,juststrings=0,empty=0,recursive=0):
"""This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary"""
newdict={}
- try:
- myfile=open(myfilename,"r")
- except IOError,e:
- return newdict
- mylines=myfile.readlines()
- myfile.close()
+ mylines=grablines(myfilename,recursive)
for x in mylines:
#the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
#into single spaces.
newdict[myline[0]]=myline[1:]
return newdict
-def grabdict_package(myfilename,juststrings=0):
- pkgs=grabdict(myfilename, juststrings, empty=1)
+def grabdict_package(myfilename,juststrings=0,recursive=0):
+ pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive)
for x in pkgs.keys():
if not isvalidatom(x):
del(pkgs[x])
writemsg("--- Invalid atom in %s: %s\n" % (myfilename, x))
return pkgs
-def grabfile_package(myfilename,compatlevel=0):
- pkgs=grabfile(myfilename,compatlevel)
+def grabfile_package(myfilename,compatlevel=0,recursive=0):
+ pkgs=grabfile(myfilename,compatlevel,recursive=recursive)
for x in range(len(pkgs)-1,-1,-1):
pkg = pkgs[x]
if pkg[0] == "-":
del(pkgs[x])
return pkgs
-def grabints(myfilename):
+def grabints(myfilename,recursive=0):
newdict={}
- try:
- myfile=open(myfilename,"r")
- except IOError:
- return newdict
- mylines=myfile.readlines()
- myfile.close()
+ mylines=grablines(myfilename,recursive)
for x in mylines:
#the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
#into single spaces.
newdict[myline[0]]=string.atoi(myline[1])
return newdict
+def grablines(myfilename,recursive=0):
+ mylines=[]
+ if recursive and os.path.isdir(myfilename):
+ myfiles = [myfilename+os.path.sep+x for x in os.listdir(myfilename)]
+ myfiles.sort()
+ for f in myfiles:
+ mylines.extend(grablines(f, recursive))
+ else:
+ try:
+ myfile = open(myfilename, "r")
+ mylines = myfile.readlines()
+ myfile.close()
+ except IOError:
+ pass
+ return mylines
+
def writeints(mydict,myfilename):
try:
myfile=open(myfilename,"w")
cd ${DEST}
find -name CVS -exec rm -rf {} \;
+find -name '.svn' -exec rm -rf {} \;
find -name '*~' -exec rm -rf {} \;
find -name '*.pyc' -exec rm -rf {} \;
find -name '*.pyo' -exec rm -rf {} \;