From: Kito Date: Mon, 12 Dec 2005 18:44:54 +0000 (-0000) Subject: Merge with trunk - rev 2360 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=2fbd690bbc5579e3fa82e5273e295b608a0ff62e;p=portage.git Merge with trunk - rev 2360 svn path=/main/branches/prefix/; revision=2361 --- diff --git a/bin/ebuild.sh b/bin/ebuild.sh index e065e5f67..f0daf33cc 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -51,39 +51,35 @@ fi 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 "$@" } @@ -130,7 +126,7 @@ useq() { 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 @@ -172,7 +168,7 @@ hasq() { 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 @@ -358,7 +354,7 @@ use_with() { return 1 fi - local UW_SUFFIX="" + local UW_SUFFIX="" if [ ! -z "${3}" ]; then UW_SUFFIX="=${3}" fi @@ -367,7 +363,7 @@ use_with() { if [ -z "${UWORD}" ]; then UWORD="$1" fi - + if useq $1; then echo "--with-${UWORD}${UW_SUFFIX}" else @@ -383,7 +379,7 @@ use_enable() { return 1 fi - local UE_SUFFIX="" + local UE_SUFFIX="" if [ ! -z "${3}" ]; then UE_SUFFIX="=${3}" fi @@ -392,7 +388,7 @@ use_enable() { if [ -z "${UWORD}" ]; then UWORD="$1" fi - + if useq $1; then echo "--enable-${UWORD}${UE_SUFFIX}" else @@ -426,13 +422,12 @@ export INSDESTTREE="" 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." @@ -447,8 +442,7 @@ check_KV() } # adds ".keep" files so that dirs aren't auto-cleaned -keepdir() -{ +keepdir() { dodir "$@" local x if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then @@ -470,8 +464,8 @@ unpack() { if [ "$USERLAND" == "BSD" ]; then tarvars="" else - tarvars="--no-same-owner" - fi + tarvars="--no-same-owner" + fi [ -z "$*" ] && die "Nothing passed to the 'unpack' command" @@ -512,7 +506,7 @@ unpack() { ;; 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" @@ -531,7 +525,7 @@ unpack() { done } -strip_duplicate_slashes () { +strip_duplicate_slashes () { if [ -n "${1}" ]; then local removed="${1/\/\///}" [ "${removed}" != "${removed/\/\///}" ] && removed=$(strip_duplicate_slashes "${removed}") @@ -561,7 +555,7 @@ econf() { 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}" @@ -594,7 +588,7 @@ econf() { LOCAL_EXTRA_ECONF="--libdir=${CONF_LIBDIR_RESULT} ${LOCAL_EXTRA_ECONF}" fi - + echo "${ECONF_SOURCE}/configure" \ --prefix=${PREFIX}/usr \ --host=${CHOST} \ @@ -667,13 +661,11 @@ einstall() { fi } -pkg_setup() -{ +pkg_setup() { return } -pkg_nofetch() -{ +pkg_nofetch() { [ -z "${SRC_URI}" ] && return echo "!!! The following are listed in SRC_URI for ${PN}:" @@ -685,7 +677,7 @@ pkg_nofetch() src_unpack() { if [ "${A}" != "" ]; then unpack ${A} - fi + fi } src_compile() { @@ -697,18 +689,17 @@ 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 @@ -718,33 +709,27 @@ src_test() 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." } @@ -759,8 +744,7 @@ END 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 @@ -799,7 +783,7 @@ dyn_unpack() { return 0 fi fi - + install -m0700 -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'" [ -d "$WORKDIR" ] && cd "${WORKDIR}" echo ">>> Unpacking source..." @@ -818,7 +802,7 @@ dyn_clean() { 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 @@ -1022,12 +1006,13 @@ dyn_compile() { 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)" @@ -1036,6 +1021,7 @@ dyn_compile() { return fi if [ -d "${S}" ]; then + srcdir=${S} cd "${S}" fi #our custom version of libtool uses $S and $D to fix @@ -1044,7 +1030,9 @@ dyn_compile() { #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 @@ -1125,13 +1113,12 @@ dyn_test() { 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 @@ -1140,7 +1127,6 @@ dyn_test() { [ "$(type -t post_src_test)" == "function" ] && post_src_test trap SIGINT SIGQUIT } - PORTAGE_INST_UID="0" PORTAGE_INST_GID="0" @@ -1177,7 +1163,7 @@ dyn_install() { 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' @@ -1189,6 +1175,8 @@ dyn_install() { 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 @@ -1202,7 +1190,7 @@ dyn_install() { 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 @@ -1214,8 +1202,7 @@ dyn_install() { 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 @@ -1231,8 +1218,7 @@ dyn_install() { 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 @@ -1246,19 +1232,24 @@ dyn_install() { 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 @@ -1359,7 +1350,7 @@ dyn_preinst() { # 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} @@ -1588,19 +1579,19 @@ debug-print() { [ -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 } @@ -1662,7 +1653,7 @@ inherit() { #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 @@ -1675,10 +1666,10 @@ inherit() { 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 @@ -1703,7 +1694,7 @@ inherit() { #turn on glob expansion set +f - + hasq $1 $INHERITED || export INHERITED="$INHERITED $1" export ECLASS="$PECLASS" @@ -1865,7 +1856,7 @@ if [ "$*" != "depend" ] && [ "$*" != "clean" ] && [ "$*" != "setup" ]; then # for X in @PORTAGE_BASE@/bin/functions/*.sh; do # source ${X} || die "Failed to source ${X}" # done - + else killparent() { diff --git a/bin/emerge b/bin/emerge index f3ea73ec8..f271123dd 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1,5 +1,5 @@ #!@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 $ @@ -63,6 +63,9 @@ def update_twirl_spinner(): sys.stdout.write("\b\b "+spinner[spinpos]) sys.stdout.flush() +def update_quiet_spinner(): + return + spinpos = 0 spinner = "/-\\|/-\\|/-\\|/-\\|\\-/|\\-/|\\-/|\\-/|" update_spinner = update_twirl_spinner @@ -162,14 +165,14 @@ merged=0 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", @@ -222,7 +225,7 @@ tmpcmdline=sys.argv[1:] #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: @@ -241,6 +244,8 @@ for x 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: @@ -319,6 +324,9 @@ if ("--tree" in myopts) and ("--columns" in myopts): 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): @@ -2122,7 +2130,7 @@ def unmerge(unmerge_action, unmerge_files): 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={} @@ -2427,7 +2435,7 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): "--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 @@ -2686,7 +2694,7 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): 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) @@ -2698,13 +2706,12 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): 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 @@ -2714,14 +2721,14 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): 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() @@ -2737,7 +2744,7 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): 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() @@ -2987,11 +2994,13 @@ elif "depclean"==myaction: 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")) @@ -3066,7 +3075,7 @@ elif "depclean"==myaction: 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:") @@ -3099,24 +3108,28 @@ else: 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")) diff --git a/bin/portageq b/bin/portageq index e37dabcfe..82464a7db 100755 --- a/bin/portageq +++ b/bin/portageq @@ -7,7 +7,7 @@ import sys, os os.environ["PORTAGE_CALLER"] = "portageq" sys.path = ["@PORTAGE_BASE@/pym"]+sys.path -import portage,types,string +import types,string #----------------------------------------------------------------------------- @@ -190,11 +190,20 @@ def distdir(argv): def envvar(argv): - """ + """+ Returns a specific environment variable as exists prior to ebuild.sh. Similar to: emerge --verbose --info | @EGREP@ '^=' """ - 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] #----------------------------------------------------------------------------- @@ -233,21 +242,29 @@ def usage(argv): 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() diff --git a/pym/portage.py b/pym/portage.py index 468090895..05e0939cc 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -100,6 +100,10 @@ try: 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: @@ -456,6 +460,57 @@ class digraph: 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 @@ -1208,9 +1263,6 @@ class config: 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: @@ -1417,6 +1469,9 @@ class config: 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. @@ -2235,7 +2290,7 @@ def digestCheckFiles(myfiles, mydigests, basedir, note="", strict=0): 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"]+"/" @@ -2312,6 +2367,9 @@ def digestcheck(myfiles, mysettings, strict=0): 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) @@ -2427,7 +2485,6 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea 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( \ @@ -2633,6 +2690,12 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea 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) @@ -2713,7 +2776,11 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea 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: @@ -2731,7 +2798,8 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea 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": @@ -4092,7 +4160,7 @@ class dbapi: 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: diff --git a/pym/portage_const.py b/pym/portage_const.py index c6fdeb9d4..0a031ba3a 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -47,10 +47,10 @@ CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" 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 diff --git a/pym/portage_data.py b/pym/portage_data.py index 04c2979d3..ebe3bfb51 100644 --- a/pym/portage_data.py +++ b/pym/portage_data.py @@ -20,7 +20,7 @@ elif ostype == "Darwin": 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: diff --git a/pym/portage_util.py b/pym/portage_util.py index 6a0c10155..9c521ab8a 100644 --- a/pym/portage_util.py +++ b/pym/portage_util.py @@ -13,16 +13,11 @@ def writemsg(mystr,noiselevel=0): 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 @@ -130,15 +125,10 @@ def grab_multiple(basename, locations, handler, all_must_exist=0): 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. @@ -155,16 +145,16 @@ def grabdict(myfilename,juststrings=0,empty=0): 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] == "-": @@ -176,14 +166,9 @@ def grabfile_package(myfilename,compatlevel=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. @@ -193,6 +178,22 @@ def grabints(myfilename): 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") diff --git a/tarball.sh b/tarball.sh index c9718bcf5..eb8e7ae15 100755 --- a/tarball.sh +++ b/tarball.sh @@ -46,6 +46,7 @@ cp ChangeLog ${DEST} 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 {} \;