diff options
author | Nicholas Jones <carpaski@gentoo.org> | 2004-02-04 22:40:21 +0000 |
---|---|---|
committer | Nicholas Jones <carpaski@gentoo.org> | 2004-02-04 22:40:21 +0000 |
commit | 8250c472cdf7495aa810247e7322c127f65e2255 (patch) | |
tree | 029c9570b964b273df0f78d87f8dac1d17bf48f9 | |
parent | Added a little notice about not modifying this file. (diff) | |
download | portage-cvs-portage_2_0_50_pre22.tar.gz portage-cvs-portage_2_0_50_pre22.tar.bz2 portage-cvs-portage_2_0_50_pre22.zip |
Lots of modifications... Mostly cleanupsportage_2_0_50_pre22
2.0.50_pre22
-rw-r--r-- | ChangeLog | 62 | ||||
-rwxr-xr-x | bin/ebuild.sh | 69 | ||||
-rwxr-xr-x | bin/emerge | 240 | ||||
-rwxr-xr-x | bin/emergehelp.py | 14 | ||||
-rw-r--r-- | bin/extra_functions.sh | 8 | ||||
-rwxr-xr-x | bin/prepstrip | 4 | ||||
-rw-r--r-- | pym/getbinpkg.py | 40 | ||||
-rw-r--r-- | pym/portage.py | 300 | ||||
-rw-r--r-- | src/sandbox-1.1/Makefile | 6 |
9 files changed, 516 insertions, 227 deletions
@@ -1,44 +1,46 @@ # ChangeLog for Portage; the Gentoo Linux ports system # Copyright 2000-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2 -# $Id: ChangeLog,v 1.539 2004/02/04 18:47:16 carpaski Exp $ +# $Id: ChangeLog,v 1.540 2004/02/04 22:40:21 carpaski Exp $ + +*portage-2.0.50_pre22 (04 Feb 2003): Cleanups and stablizing 21 Jan 2004; Nicholas Jones <carpaski@gentoo.org> ebuild.sh: TGL's fixes - for exec/child/wait problems. Unset GREP_OPTIONS GREP_COLOR. has() and use() - no longer attempt to determine if they are to be quiet or noisy -- They - default to noisy -- useq() and hasq() are the non-verbose versions. - EBUILD_PHASE set to add a hack-ish way around global scope calls in - eclasses -- NOTHING SHOULD BE CALLED IN THE GLOBAL SCOPE. Touchup to the - inherit() code that should finally allow the removal of the ECLASS and - INHERITED settings. Removed tty (use/has) calls. Removed dirname calls -- - portage.py handles setting the dbkey filename now. - + for exec/child/wait problems. Unset GREP_OPTIONS GREP_COLOR. has() and use() + no longer attempt to determine if they are to be quiet or noisy -- They + default to noisy -- useq() and hasq() are the non-verbose versions. + EBUILD_PHASE set to add a hack-ish way around global scope calls in + eclasses -- NOTHING SHOULD BE CALLED IN THE GLOBAL SCOPE. Touchup to the + inherit() code that should finally allow the removal of the ECLASS and + INHERITED settings. Removed tty (use/has) calls. Removed dirname calls -- + portage.py handles setting the dbkey filename now. + 21 Jan 2004; Nicholas Jones <carpaski@gentoo.org> emerge: Ed Catmur's - (with a little TGL added in) patch for --ask. Added a 'metadata' target - that skips the sync and only updates the cache. FEATURES="getbinpkg" added. - TGL's exit code fixes. Fixed match code for -S so it doesn't complain about - specific and double versions. Unmerge via dbpath fix. Rewrote rsync's - options that supports --verbose and --quiet operation now and can force - checksumming all files using --debug. Sort the files in the cache update - so it's a little more predictable. + (with a little TGL added in) patch for --ask. Added a 'metadata' target + that skips the sync and only updates the cache. FEATURES="getbinpkg" added. + TGL's exit code fixes. Fixed match code for -S so it doesn't complain about + specific and double versions. Unmerge via dbpath fix. Rewrote rsync's + options that supports --verbose and --quiet operation now and can force + checksumming all files using --debug. Sort the files in the cache update + so it's a little more predictable. 21 Jan 2004; Nicholas Jones <carpaski@gentoo.org> prepstrip: changed - --strip-debug to --strip-unneeded. + --strip-debug to --strip-unneeded. 21 Jan 2004; Nicholas Jones <carpaski@gentoo.org> getbinpkg.py: Updates to - enable HTTP/HTTPS authentication. + enable HTTP/HTTPS authentication. 21 Jan 2004; Nicholas Jones <carpaski@gentoo.org> portage.py: best_from_dict - added to grab the best entry from set of dicts using a list of the keys for - priority. jstubb's patch to fix listdir -- splits it into a cache and list - setup. jstubb's patch for varexpand to handle $VAR better. Latexer's patch - for KernelVersion code to use Makefiles instead of the version.h. Modules - are loaded from /etc/portage/modules or defaults, whichever works. Fixed - the /etc/make.profile-is-missing traceback. Spawn can be given 3 pipes to - redirect stdin,stdout,stderr to specific outputs, terminals, or files. - TGL's patch for cache functions in portage.py so that they do not cache at - inappropriate times. PORTAGE_TMPFS is now used if set as a temporary file - operation area -- recommended to actually be a ramfs/tmpfs filesystem for - speed. Genone enhanced the deprecated profile patch. + added to grab the best entry from set of dicts using a list of the keys for + priority. jstubb's patch to fix listdir -- splits it into a cache and list + setup. jstubb's patch for varexpand to handle $VAR better. Latexer's patch + for KernelVersion code to use Makefiles instead of the version.h. Modules + are loaded from /etc/portage/modules or defaults, whichever works. Fixed + the /etc/make.profile-is-missing traceback. Spawn can be given 3 pipes to + redirect stdin,stdout,stderr to specific outputs, terminals, or files. + TGL's patch for cache functions in portage.py so that they do not cache at + inappropriate times. PORTAGE_TMPFS is now used if set as a temporary file + operation area -- recommended to actually be a ramfs/tmpfs filesystem for + speed. Genone enhanced the deprecated profile patch. 31 Jan 2004; Masatomo Nakano <nakano@gentoo.org> emerge: Fixed --skipfirst bug. This closes #36880. diff --git a/bin/ebuild.sh b/bin/ebuild.sh index eb85e3b..3b1e5a6 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/ebuild.sh,v 1.153 2004/01/22 05:51:45 carpaski Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/ebuild.sh,v 1.154 2004/02/04 22:40:21 carpaski Exp $ SANDBOX_PREDICT="${SANDBOX_PREDICT}:/proc/self/maps:/dev/console" SANDBOX_WRITE="${SANDBOX_WRITE}:/dev/shm:${PORTAGE_TMPDIR}" @@ -24,11 +24,8 @@ if [ "$*" != "depend" ] && [ "$*" != "clean" ]; then touch "${PORT_LOGDIR}/${LOG_COUNTER}-${PF}.log" &> /dev/null chmod g+w "${PORT_LOGDIR}/${LOG_COUNTER}-${PF}.log" &> /dev/null echo "$*" >> "${PORT_LOGDIR}/${LOG_COUNTER}-${PF}.log" - $0 $* 2>&1 | tee -a "${PORT_LOGDIR}/${LOG_COUNTER}-${PF}.log" - if [ "$?" != "0" ]; then - rm -f "${T}/successful" - exit 1 - fi + { $0 $* || rm -f "${T}/successful" ; } 2>&1 \ + | tee -i -a "${PORT_LOGDIR}/${LOG_COUNTER}-${PF}.log" if [ -f "${T}/successful" ]; then rm -f "${T}/successful" exit 0 @@ -52,7 +49,7 @@ fi unalias -a # Unset some variables that break things. -unset GZIP BZIP BZIP2 CDPATH +unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR # We need this next line for "die" and "assert". It expands # It _must_ preceed all the calls to die and assert. @@ -89,7 +86,16 @@ esyslog() { return 0 } + use() { + if useq ${1}; then + echo "${1}" + return 0 + fi + return 1 +} + +useq() { local u="${1}" local neg=0 if [ "${u:0:1}" == "!" ]; then @@ -102,21 +108,11 @@ use() { if [ ${neg} -eq 1 ]; then return 1 else - if [ -r /dev/fd/1 ]; then - tty --quiet < /dev/stdout || echo "${x}" - else - echo "${x}" - fi return 0 fi fi done if [ ${neg} -eq 1 ]; then - if [ -r /dev/fd/1 ]; then - tty --quiet < /dev/stdout || echo "${x}" - else - echo "${x}" - fi return 0 else return 1 @@ -124,6 +120,14 @@ use() { } has() { + if hasq "$@"; then + echo "${1}" + return 0 + fi + return 1 +} + +hasq() { local x local me=$1 @@ -133,17 +137,6 @@ has() { # Logging kills all this anyway. Everything becomes a pipe. --NJ for x in "$@"; do if [ "${x}" == "${me}" ]; then - if [ -r /proc/self/fd/1 ]; then - tty --quiet < /proc/self/fd/1 || echo "${x}" - elif [ -r /dev/fd/1 ]; then - echo "/dev/fd/1" >&2 - tty --quiet < /dev/fd/1 || echo "${x}" - elif [ -r /dev/stdout ]; then - echo "/dev/stdout" >&2 - tty --quiet < /dev/stdout || echo "${x}" - else - echo "${x}" - fi return 0 fi done @@ -151,6 +144,7 @@ has() { } has_version() { + [ "${EBUILD_PHASE}" == "depend" ] && echo "has_version() in global scope: ${CATEGORY}/$PF" >&2 # return shell-true/shell-false if exists. # Takes single depend-type atoms. if /usr/lib/portage/bin/portageq 'has_version' "${ROOT}" "$1"; then @@ -160,7 +154,13 @@ has_version() { fi } +portageq() { + [ "${EBUILD_PHASE}" == "depend" ] && echo "portageq in global scope: ${CATEGORY}/$PF" >&2 + /usr/lib/portage/bin/portageq "$@" +} + best_version() { + [ "${EBUILD_PHASE}" == "depend" ] && echo "best_version() in global scope: ${CATEGORY}/$PF" >&2 # returns the best/most-current match. # Takes single depend-type atoms. /usr/lib/portage/bin/portageq 'best_version' "${ROOT}" "$1" @@ -183,7 +183,7 @@ use_with() { UWORD="$1" fi - if use $1 &>/dev/null; then + if useq $1; then echo "--with-${UWORD}${UW_SUFFIX}" return 0 else @@ -209,7 +209,7 @@ use_enable() { UWORD="$1" fi - if use $1 &>/dev/null; then + if useq $1; then echo "--enable-${UWORD}${UE_SUFFIX}" return 0 else @@ -1056,6 +1056,7 @@ inherit() { fi local location + local PECLASS while [ "$1" ]; do location="${ECLASSDIR}/${1}.eclass" @@ -1122,10 +1123,9 @@ inherit() { #turn on glob expansion set +f - has $1 $INHERITED || export INHERITED="$INHERITED $1" + hasq $1 $INHERITED || export INHERITED="$INHERITED $1" export ECLASS="$PECLASS" - unset PECLASS shift done @@ -1287,6 +1287,7 @@ export S=${WORKDIR}/${P} unset DEPEND RDEPEND CDEPEND PDEPEND unset E_DEPEND E_RDEPEND E_CDEPEND E_PDEPEND +export EBUILD_PHASE="$*" source ${EBUILD} || die "error sourcing ebuild" [ -z "${ERRORMSG}" ] || die "${ERRORMSG}" @@ -1386,8 +1387,8 @@ for myarg in $*; do # Handled in portage.py now #dbkey=${PORTAGE_CACHEDIR}/${CATEGORY}/${PF} - if [ ! -d "$(dirname "${dbkey}")" ]; then - install -d -g ${PORTAGE_GID} -m2775 "$(dirname "${dbkey}")" + if [ ! -d "${dbkey%/*}" ]; then + install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}" fi # Make it group writable. 666&~002==664 @@ -1,7 +1,7 @@ #!/usr/bin/python -O # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/emerge,v 1.261 2004/01/31 02:15:49 nakano Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/emerge,v 1.262 2004/02/04 22:40:21 carpaski Exp $ import os,sys os.environ["PORTAGE_CALLER"]="emerge" @@ -21,6 +21,43 @@ def normpath(mystr): else: return os.path.normpath(mystr) +def userquery(prompt, responses=None, colours=None): + """Displays a prompt and a set of responses, then waits for a response + which is checked against the responses and the first to match is + returned. + + prompt: a String. + responses: a List of Strings. + colours: a List of Functions taking and returning a String, used to + process the responses for display. Typically these will be functions + like red() but could be e.g. lambda x: "DisplayString". + If responses is omitted, defaults to ["Yes, "No"], [green, red]. + If only colours is omitted, defaults to [bold, ...]. + + Returns a member of the List responses. (If called without optional + arguments, returns "Yes" or "No".) + KeyboardInterrupt is converted to SystemExit to avoid tracebacks being + printed.""" + if responses is None: + responses, colours = ["Yes", "No"], [green, red] + elif colours is None: + colours=[bold] + colours=(colours*len(responses))[:len(responses)] + print bold(prompt), + try: + while True: + response=raw_input("["+string.join([colours[i](responses[i]) for i in range(len(responses))],"/")+"] ") + for key in responses: + if response.upper()==key[:len(response)].upper(): + return key + for key in responses: + if response.upper()==key[:len(response)].upper(): + return key + print "Sorry, response '%s' not understood." % response, + except KeyboardInterrupt: + print "Interrupted." + sys.exit(1) + if portage.settings.has_key("PORTAGE_NICENESS"): try: os.nice(int(portage.settings["PORTAGE_NICENESS"])) @@ -42,10 +79,13 @@ spinpos=0 merged=0 params=["selective", "deep", "self", "recurse", "empty"] actions=[ -"clean", "config", "depclean", "help", "info", "inject", "prune", -"regen", "rsync", "search", "sync", "system", "unmerge", "world" +"clean", "config", "depclean", +"help", "info", "inject", "metadata", +"prune", "regen", "rsync", "search", +"sync", "system", "unmerge", "world", ] options=[ +"--ask", "--buildpkg", "--buildpkgonly", "--changelog", "--columns", "--debug", "--deep", @@ -66,6 +106,7 @@ options=[ ] shortmapping={ +"a":"--ask", "b":"--buildpkg", "B":"--buildpkgonly", "c":"--clean", "C":"--unmerge", "d":"--debug", "D":"--deep", @@ -119,9 +160,9 @@ for x in cmdline: myopts.append(x) elif x[2:] in actions: if x[2:]=="rsync": - #print - #print red("*** --rsync has been deprecated.") - #print red("*** Please use '--sync' instead.") + print + print red("*** 'rsync' has been deprecated.") + print red("*** Please use 'sync' instead.") x="--sync" if myaction: if myaction not in ["system", "world"]: @@ -179,6 +220,10 @@ if ("--searchdesc" in myopts): myopts.append("--search") myaction = "search" +# Always try and fetch binary packages if FEATURES=getbinpkg +if ("getbinpkg" in portage.features): + myopts.append("--getbinpkg") + if ("--getbinpkgonly" in myopts) and not ("--usepkgonly" in myopts): myopts.append("--usepkgonly") @@ -202,6 +247,17 @@ if ("--changelog" in myopts) and not ("--pretend" in myopts): print ">>> --changelog implies --pretend... adding --pretend to options." myopts.append("--pretend") +# Allow -p to remove --ask +if ("--pretend" in myopts) and ("--ask" in myopts): + print ">>> --pretend disables --ask... removing --ask from options." + myopts.remove("--ask") + +# forbid --ask when not in a terminal +# note: this breaks `emerge --ask | tee logfile`, but that doesn't work anyway. +if ("--ask" in myopts) and (not sys.stdout.isatty()): + portage.writemsg("!!! \"--ask\" should only be used in a terminal. Exiting.\n") + sys.exit(1) + # Set so that configs will be merged regardless of remembered status if ("--noconfmem" in myopts): portage.settings.unlock() @@ -239,16 +295,14 @@ def emergelog(mystr): pass def emergeexit(): - """This gets out final log message in before we quit. As it overrides - any other atexit's we have setup, we need to call them ourself.""" - portage.portageexit() - emergelog(" *** terminating.") + """This gets out final log message in before we quit.""" + if "--pretend" not in myopts: + emergelog(" *** terminating.") if "notitles" not in portage.features: xtermTitleReset() atexit.register(emergeexit) def emergeexitsig(signum, frame): - emergeexit() sys.exit(100+signum) signal.signal(signal.SIGINT, emergeexitsig) @@ -527,8 +581,9 @@ class search: masked=1 full_package=portage.best(portage.portdb.xmatch("match-all",match)) else: - full_package=match - catpack=portage.pkgsplit(match)[0] + full_package = match + match = portage.pkgsplit(match)[0] + if full_package: try: desc, homepage, license = portage.portdb.aux_get(full_package,["DESCRIPTION","HOMEPAGE","LICENSE"]) @@ -663,8 +718,8 @@ class depgraph: if "--usepkg" in myopts: try: portage.db["/"]["bintree"].populate(("--getbinpkg" in myopts), ("--getbinpkgonly" in myopts)) - except ValueError, e: - sys.stderr.write(red("!!! Failed to get all metadata: "+str(e)+"\n")) + except Exception, e: + sys.stderr.write(red("!!! Failed to get all metadata:\n")+" "+str(e)+"\n") sys.exit(1) def create(self,mybigkey,myparent=None,addme=1,myuse=None): @@ -1614,7 +1669,7 @@ def unmerge(unmerge_action, unmerge_files): return 0 for x in unmerge_files: arg_parts=x.split('/') - if arg_parts[-1][-7:]!=".ebuild": + if (x[0] not in [".","/"]) and (arg_parts[-1][-7:] != ".ebuild"): #possible cat/pkg or dep; treat as such candidate_catpkgs.append(x) elif unmerge_action in ["prune","clean"]: @@ -1626,16 +1681,43 @@ def unmerge(unmerge_action, unmerge_files): if not os.path.exists(x): print "\n!!! The path '"+x+"' doesn't exist.\n" return 0 - absx=os.path.abspath(x) - spabsx=absx.split("/") - if (absx[:12]!=(portage.root+portage.VDB_PATH)) or len(spabsx)!=7: + + absx = os.path.abspath(x) + sp_absx = absx.split("/") + if sp_absx[-1][-7:] == ".ebuild": + del sp_absx[-1] + absx = string.join(sp_absx,"/") + + sp_absx_len = len(sp_absx) + + vdb_path = portage.root+portage.VDB_PATH + vdb_len = len(vdb_path) + + sp_vdb = vdb_path.split("/") + sp_vdb_len = len(sp_vdb) + + if not os.path.exists(absx+"/CONTENTS"): + print "!!! Not a valid db dir: "+str(absx) + return 0 + + if sp_absx_len <= sp_vdb_len: + # The Path is shorter... so it can't be inside the vdb. print spabsx print absx - print "\n!!!",x,"is not inside "+(portage.root+portage.VDB_PATH)+"; aborting.\n" + print "\n!!!",x,"cannot be inside "+(portage.root+portage.VDB_PATH)+"; aborting.\n" return 0 - candidate_catpkgs.append("="+spabsx[4]+"/"+spabsx[5]) - if "--pretend" in myopts: + for idx in range(0,sp_vdb_len): + if (idx >= sp_absx_len) or (sp_vdb[idx] != sp_absx[idx]): + print sp_absx + print absx + print "\n!!!",x,"is not inside "+(portage.root+portage.VDB_PATH)+"; aborting.\n" + return 0 + + 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): print darkgreen("\n>>> These are the packages that I would unmerge:") pkgmap={} @@ -1734,6 +1816,12 @@ def unmerge(unmerge_action, unmerge_files): if "--pretend" in myopts: #we're done... return return 0 + if "--ask" in myopts: + if userquery("Do you want me to unmerge these packages?")=="No": + print + print "Quitting." + print + return 0 #the real unmerging begins, after a short delay.... if mysettings["CLEAN_DELAY"]: @@ -1864,12 +1952,12 @@ def post_emerge(retval=0): if "--debug" in myopts: edebug=1 -if myaction in ["sync","rsync"] and (not "--help" in myopts): +if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): if "--pretend" in myopts: - print "emerge: the \"sync\" action does not support \"--pretend.\"" + print "emerge: \"sync\" actions do not support \"--pretend.\"" sys.exit(1) - emergelog(" === rsync") + emergelog(" === "+str(myaction)) myportdir=portage.settings["PORTDIR"] if myportdir[-1]=="/": myportdir=myportdir[:-1] @@ -1878,9 +1966,10 @@ if myaction in ["sync","rsync"] and (not "--help" in myopts): os.makedirs(myportdir,0755) syncuri=string.rstrip(portage.settings["SYNC"]) os.umask(0022) - if 0: + if myaction == "metadata": print "skipping sync" updatecache_flg = True + tmpservertimestampfile = None elif syncuri[:8]=="rsync://": if not os.path.exists("/usr/bin/rsync"): print "!!! /usr/bin/rsync does not exist, so rsync support is disabled." @@ -1892,14 +1981,46 @@ if myaction in ["sync","rsync"] and (not "--help" in myopts): mytimeout=int(portage.settings["RSYNC_TIMEOUT"]) except: pass - rsynccommand="/usr/bin/rsync -rlptDvz --progress --stats --delete --delete-after --timeout="+str(mytimeout)+" --exclude='distfiles/*' --exclude='local/*' --exclude='packages/*'" + + rsync_flags = [ + "--recursive", # Recurse directories + "--links", # Consider symlinks + "--safe-links", # Ignore links outside of tree + "--perms", # Preserve permissions + "--times", # Preserive mod times + "--compress", # Compress the data transmitted + "--force", # Force deletion on non-empty dirs + "--whole-file", # Don't do block transfers, only entire files + "--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 + "--exclude='distfiles/*'", # Exclude distfiles from consideration + "--exclude='local/*'", # Exclude local from consideration + "--exclude='packages/*'", # Exclude packages from consideration + ] + + if "--quiet" in myopts: + rsync_flags.append("--quiet") # Shut up a lot + else: + rsync_flags.append("--progress") # Progress meter for each file + + if "--verbose" in myopts: + rsync_flags.append("--verbose") # More noise? Not really sure what + + if "--debug" in myopts: + rsync_flags.append("--checksum") # Force checksum on all files + if portage.settings.has_key("RSYNC_EXCLUDEFROM"): if os.path.exists(portage.settings["RSYNC_EXCLUDEFROM"]): - rsynccommand=rsynccommand+" --exclude-from "+portage.settings["RSYNC_EXCLUDEFROM"] + rsync_flags.append("--exclude-from="+portage.settings["RSYNC_EXCLUDEFROM"]) else: print "!!! RSYNC_EXCLUDEFROM specified, but file does not exist." + if portage.settings.has_key("RSYNC_RATELIMIT"): - rsynccommand = rsynccommand+ " --bwlimit="+portage.settings["RSYNC_RATELIMIT"]+" " + rsync_flags.append("--bwlimit="+portage.settings["RSYNC_RATELIMIT"]) + + rsynccommand = "/usr/bin/rsync " + string.join(rsync_flags, " ") servertimestampdir = portage.settings["PORTAGE_CACHEDIR"]+"/" servertimestampfile = portage.settings["PORTAGE_CACHEDIR"]+"/timestamp.chk" @@ -1954,6 +2075,12 @@ if myaction in ["sync","rsync"] and (not "--help" in myopts): dosyncuri=syncuri if (retries==0): + if "--ask" in myopts: + if userquery("Do you want to sync your Portage tree with the mirror at\n" + blue(dosyncuri) + bold("?"))=="No": + print + print "Quitting." + print + sys.exit(0) emergelog(">>> starting rsync with "+dosyncuri) print ">>> starting rsync with "+dosyncuri+"..." else: @@ -2077,7 +2204,8 @@ if myaction in ["sync","rsync"] and (not "--help" in myopts): # save timestamp.chk for next timestamp check. try: - portage.movefile(tmpservertimestampfile, servertimestampfile) + if tmpservertimestampfile != None: + portage.movefile(tmpservertimestampfile, servertimestampfile) except Exception, e: print "!!! Failed to save current timestamp." print "!!!",e @@ -2089,9 +2217,11 @@ if myaction in ["sync","rsync"] and (not "--help" in myopts): except: pass mynodes=portage.portdb.cp_all() + mynodes.sort() for x in mynodes: myxsplit=x.split("/") mymatches=portage.portdb.xmatch("match-all",x) + mymatches.sort() for y in mymatches: update_spinner() try: @@ -2208,6 +2338,12 @@ elif "inject"==myaction: if portage.db["/"]["vartree"].exists_specific(x): print "!!! Not injecting",x+"; Package already exists." else: + if "--ask" in myopts: + if userquery("Do you want to inject the package %s?" % x)=="No": + print + print "Quitting." + print + sys.exit(0) portage.db["/"]["vartree"].dbapi.cpv_inject(x) print ">>> Injected",x+"." emergelog(" === inject: "+x) @@ -2236,7 +2372,7 @@ elif "depclean"==myaction: print red("*** WARNING ***")+" : MERGING *** THE PACKAGE THAT COMPLAINS *** ABOUT THE" print red("*** WARNING ***")+" : MISSING LIBRARY." print - if not "--pretend" in myopts: + if ("--pretend" not in myopts) and ("--ask" not in myopts): countdown(10, ">>> Depclean") emergelog(" >>> depclean") @@ -2282,7 +2418,7 @@ elif "depclean"==myaction: red("!!! "+str(string.split(x)[2])+"\n\n")+ "!!! Please ensure that blocking/conflicting packages are not merged."+ "!!! 'emerge -p "+str(string.split(x)[2])+"\n\n") - if "--pretend" not in myopts: + if ("--pretend" not in myopts) and ("--ask" not in myopts): countdown(15, "*** Continuing") continue @@ -2315,7 +2451,7 @@ elif "depclean"==myaction: #print if len(cleanlist): - unmerge("unmerge", cleanlist) + retval=unmerge("unmerge", cleanlist) print print "Packages installed: "+str(len(myvarlist)) @@ -2323,18 +2459,17 @@ elif "depclean"==myaction: print "Packages in system: "+str(len(syslist)) print "Unique package names: "+str(len(reallist)) print "Required packages: "+str(len(alldeps)) - if "--pretend" in myopts: + if ("--pretend" in myopts) or 1!=retval: print "Number to remove: "+str(len(cleanlist)) else: print "Number removed: "+str(len(cleanlist)) - - post_emerge() + post_emerge() # "update", "system", or just process files: else: favorites=[] syslist=getlist("system") - if ("--pretend" in myopts) and not ("--fetchonly" in myopts): + if (("--pretend" in myopts) and not ("--fetchonly" in myopts)) or ("--ask" in myopts): if "--tree" in myopts: print print darkgreen("These are the packages that I would merge, in reverse order:") @@ -2390,6 +2525,37 @@ else: sys.stderr.write("\nThese are required by '--usepkgonly' -- Terminating.\n\n") sys.exit(1) + if "--ask" in myopts: + if "--resume" in myopts: + mydepgraph.display(portage.mtimedb["resume"]["mergelist"]) + prompt="Do you want me to resume merging these packages?" + else: + mydepgraph.display(mydepgraph.altlist()) + mergecount=0 + for x in mydepgraph.altlist(): + if x[3]!="nomerge": + mergecount+=1 + if mergecount==0: + if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: + prompt="Nothing to merge; do you want me to auto-clean packages?" + else: + print + print "Nothing to merge; quitting." + print + sys.exit(0) + elif "--fetchonly" in myopts: + prompt="Do you want me to fetch the source files for these packages?" + else: + prompt="Do you want me to merge these packages?" + print + if userquery(prompt)=="No": + print + print "Quitting." + print + sys.exit(0) + # Don't ask again (e.g. when auto-cleaning packages after merge) + myopts.remove("--ask") + if ("--pretend" in myopts) and ("--fetchonly" not in myopts): if ("--resume" in myopts): mydepgraph.display(portage.mtimedb["resume"]["mergelist"]) diff --git a/bin/emergehelp.py b/bin/emergehelp.py index 6bd86f6..7c22322 100755 --- a/bin/emergehelp.py +++ b/bin/emergehelp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2.2 # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/Attic/emergehelp.py,v 1.19 2004/01/22 05:51:45 carpaski Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/Attic/emergehelp.py,v 1.20 2004/02/04 22:40:21 carpaski Exp $ import os,sys from output import * @@ -13,9 +13,9 @@ def shorthelp(): print " "+turquoise("emerge")+" [ "+green("options")+" ] [ "+green("action")+" ] [ "+turquoise("ebuildfile")+" | "+turquoise("tbz2file")+" | "+turquoise("dependency")+" ] [ ... ]" print " "+turquoise("emerge")+" [ "+green("options")+" ] [ "+green("action")+" ] < "+turquoise("system")+" | "+turquoise("world")+" >" print " "+turquoise("emerge")+" < "+turquoise("sync")+" | "+turquoise("info")+" >" - print " "+turquoise("emerge")+" "+turquoise("--resume")+" ["+green("--pretend")+" | "+green("--skipfirst")+"]" + print " "+turquoise("emerge")+" "+turquoise("--resume")+" [ "+green("--pretend")+" | "+green("--ask")+" | "+green("--skipfirst")+" ]" print " "+turquoise("emerge")+" "+turquoise("help")+" [ "+green("system")+" | "+green("config")+" | "+green("sync")+" ] " - print bold("Options:")+" "+green("-")+"["+green("bcCdDefhikKlnoOpPsSuUvV")+"] ["+green("--oneshot")+"] ["+green("--noconfmem")+"]" + print bold("Options:")+" "+green("-")+"["+green("abcCdDefhikKlnoOpPsSuUvV")+"] ["+green("--oneshot")+"] ["+green("--noconfmem")+"]" print " ["+green("--columns")+"] ["+green("--nospinner")+"]" print bold("Actions:")+" [ "+green("clean")+" | "+green("depclean")+" | "+green("inject")+" | "+green("prune")+" | "+green("regen")+" | "+green("search")+" | "+green("unmerge")+" ]" print @@ -121,6 +121,14 @@ def help(myaction,myopts,havecolor=1): print " format described in the "+bold("clean")+" action above." print print turquoise("Options:") + print " "+green("--ask")+" ("+green("-a")+" short option)" + print " before performing the merge, display what ebuilds and tbz2s will" + print " be installed, in the same format as when using --pretend; then" + print " ask whether to continue with the merge or abort. Using --ask is" + print " more efficient than using --pretend and then executing the same" + print " command without --pretend, as dependencies will only need to be" + print " calculated once." + print print " "+green("--buildpkg")+" ("+green("-b")+" short option)" print " tell emerge to build binary packages for all ebuilds processed" print " (in addition to actually merging the packages. Useful for" diff --git a/bin/extra_functions.sh b/bin/extra_functions.sh index 4747e5e..403aec9 100644 --- a/bin/extra_functions.sh +++ b/bin/extra_functions.sh @@ -1,6 +1,10 @@ # Copyright 2002-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/Attic/extra_functions.sh,v 1.6 2003/06/30 06:43:38 carpaski Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/Attic/extra_functions.sh,v 1.7 2004/02/04 22:40:21 carpaski Exp $ + +ordertest() { + echo "RUNNING FROM EXTRA_FUNCTIONS.SH" +} # ============================================================================ # Extracted from flag-o-matic -- March 10, 2003 @@ -169,6 +173,8 @@ EPATCH_FORCE="no" # <azarah@gentoo.org> (10 Nov 2002) # epatch() { + echo "RUNNING FROM extra_functions.sh" + local PIPE_CMD="" local STDERR_TARGET="${T}/$$.out" local PATCH_TARGET="${T}/$$.patch" diff --git a/bin/prepstrip b/bin/prepstrip index 598bc0e..97013d3 100755 --- a/bin/prepstrip +++ b/bin/prepstrip @@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/prepstrip,v 1.16 2003/12/15 23:40:25 carpaski Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/prepstrip,v 1.17 2004/02/04 22:40:21 carpaski Exp $ if [ "${FEATURES//*nostrip*/true}" == "true" ] || [ "${RESTRICT//*nostrip*/true}" == "true" ] ; then echo "nostrip" @@ -28,7 +28,7 @@ for x in "$@"; do # "$@" quotes each element... Plays nice with spaces. fi if [ -z "${f/*SB shared object*/}" ]; then echo " ${x:${#D}:${#x}}" - ${STRIP} --strip-debug "${x}" + ${STRIP} --strip-unneeded "${x}" # etdyn binaries are shared objects, but not really. Non-relocatable. if [ -x /usr/bin/isetdyn ]; then diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py index 8d4aea7..690d9f3 100644 --- a/pym/getbinpkg.py +++ b/pym/getbinpkg.py @@ -1,10 +1,10 @@ # getbinpkg.py -- Portage binary-package helper functions # Copyright 2003 Gentoo Technologies, Inc. # Distributed under the GNU Public License v2 -# $Id: getbinpkg.py,v 1.4 2003/12/25 03:06:09 carpaski Exp $ +# $Id: getbinpkg.py,v 1.5 2004/02/04 22:40:21 carpaski Exp $ from output import * -import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,cPickle +import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,cPickle,base64 try: import ftplib @@ -94,6 +94,18 @@ def create_conn(baseurl,conn=None): password = None del userpass + http_headers = {} + http_params = {} + if username and password: + http_headers = { + "Authorization": "Basic %s" % + string.replace( + base64.encodestring("%s:%s" % (username, password)), + "\012", + "" + ), + } + if not conn: if protocol == "https": conn = httplib.HTTPSConnection(host) @@ -111,7 +123,7 @@ def create_conn(baseurl,conn=None): else: raise NotImplementedError, "%s is not a supported protocol." % protocol - return (conn,protocol,address) + return (conn,protocol,address, http_params, http_headers) def make_ftp_request(conn, address, rest=None, dest=None): """(conn,address,rest) --- uses the conn object to request the data @@ -248,18 +260,19 @@ def dir_get_list(baseurl,conn=None): else: keepconnection = 1 - conn,protocol,address = create_conn(baseurl, conn) + conn,protocol,address,params,headers = create_conn(baseurl, conn) + listing = None if protocol in ["http","https"]: - headers = {} - params = {} - page,rc,msg = make_http_request(conn, address, params, headers) - + page,rc,msg = make_http_request(conn,address,params,headers) + if page: parser = ParseLinks() parser.feed(page) del page listing = parser.get_anchors() + else: + raise Exception, "Unable to get listing: %s" % (rc,msg) elif protocol in ["ftp"]: if address[-1] == '/': olddir = conn.pwd() @@ -287,11 +300,10 @@ def file_get_metadata(baseurl,conn=None, chunk_size=3000): else: keepconnection = 1 - conn,protocol,address = create_conn(baseurl, conn) + conn,protocol,address,params,headers = create_conn(baseurl, conn) if protocol in ["http","https"]: - headers = {"Range": "bytes=-"+str(chunk_size)} - params = {} + headers["Range"] = "bytes=-"+str(chunk_size) data,rc,msg = make_http_request(conn, address, params, headers) elif protocol in ["ftp"]: data,rc,msg = make_ftp_request(conn, address, -chunk_size) @@ -360,11 +372,11 @@ def file_get_lib(baseurl,dest,conn=None): else: keepconnection = 1 - conn,protocol,address = create_conn(baseurl, conn) + conn,protocol,address,params,headers = create_conn(baseurl, conn) sys.stderr.write("Fetching '"+str(os.path.basename(address)+"'\n")) if protocol in ["http","https"]: - data,rc,msg = make_http_request(conn, address, dest=dest) + data,rc,msg = make_http_request(conn, address, params, headers, dest=dest) elif protocol in ["ftp"]: data,rc,msg = make_ftp_request(conn, address, dest=dest) else: @@ -387,7 +399,7 @@ def dir_get_metadata(baseurl,conn=None, chunk_size=3000, verbose=1, usingcache=1 if makepickle == None: makepickle = "/var/cache/edb/metadata.idx.most_recent" - conn,protocol,address = create_conn(baseurl, conn) + conn,protocol,address,params,headers = create_conn(baseurl, conn) filedict = {} diff --git a/pym/portage.py b/pym/portage.py index d78b46f..ae4058f 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1,7 +1,7 @@ # portage.py -- core Portage functionality # Copyright 1998-2003 Daniel Robbins, Gentoo Technologies, Inc. # Distributed under the GNU Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage.py,v 1.385 2004/01/27 14:37:53 nakano Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage.py,v 1.386 2004/02/04 22:40:21 carpaski Exp $ VERSION="2.0.50_pre17" @@ -37,6 +37,18 @@ def load_mod(name): mod = getattr(mod, comp) return mod +def best_from_dict(key, top_dict, key_order, EmptyOnError=1, FullCopy=1, AllowEmpty=1): + for x in key_order: + if top_dict.has_key(x) and top_dict[x].has_key(key): + if FullCopy: + return copy.deepcopy(top_dict[x][key]) + else: + return top_dict[x][key] + if EmptyOnError: + return "" + else: + raise KeyError, "Key not found in list; '%s'" % key + def lockdir(mydir): return lockfile(mydir,wantnewlockfile=1) def unlockdir(mylock): @@ -243,9 +255,8 @@ def prefix_array(array,prefix,doblanks=1): return newarray dircache={} -def listdir(mypath,recursive=0,filesonly=0,ignorecvs=0,ignorelist=[],EmptyOnError=0): - """List directory contents, using cache. - Returns none unless EmptyOnError is non-zero""" +def cacheddir (mypath, ignorecvs, ignorelist, EmptyOnError): + if dircache.has_key(mypath): cached_mtime, list, ftype = dircache[mypath] else: @@ -254,24 +265,41 @@ def listdir(mypath,recursive=0,filesonly=0,ignorecvs=0,ignorelist=[],EmptyOnErro mtime = os.stat(mypath)[ST_MTIME] else: if EmptyOnError: - return [] - return None + return [], [] + return None, None if mtime != cached_mtime: list = os.listdir(mypath) ftype = [] - for x in range(len(list)-1,-1,-1): - if (list[x] in ignorelist) or \ - (ignorecvs and (len(list[x]) > 2) and (list[x][:2]==".#")): - del list[x] - continue - if os.path.isfile(mypath+"/"+list[x]): - ftype.insert(0,0) - elif os.path.isdir(mypath+"/"+list[x]): - ftype.insert(0,1) + for x in list: + if os.path.isfile(mypath+"/"+x): + ftype.append(0) + elif os.path.isdir(mypath+"/"+x): + ftype.append(1) else: - ftype.insert(0,2) + ftype.append(2) dircache[mypath] = mtime, list, ftype + ret_list = [] + ret_ftype = [] + for x in range(0, len(list)): + if not ((list[x] in ignorelist) or \ + (ignorecvs and (len(list[x]) > 2) and + (list[x][:2]==".#"))): + ret_list.append(list[x]) + ret_ftype.append(ftype[x]) + + return ret_list, ret_ftype + + +def listdir (mypath, + recursive=False, + filesonly=False, + ignorecvs=False, + ignorelist=[], + EmptyOnError=False): + + list, ftype = cacheddir(mypath, ignorecvs, ignorelist, EmptyOnError) + if not filesonly and not recursive: return list @@ -281,8 +309,12 @@ def listdir(mypath,recursive=0,filesonly=0,ignorecvs=0,ignorelist=[],EmptyOnErro if ftype[x]==1 and \ not (ignorecvs and (len(list[x])>=3) and (("/"+list[x][-3:])=="/CVS")) and \ not (ignorecvs and (len(list[x])>=4) and (("/"+list[x][-4:])=="/.svn")): - ignored=listdir(mypath+"/"+list[x],recursive,filesonly,ignorecvs,ignorelist,EmptyOnError) - m,l,f = dircache[mypath+"/"+list[x]] + + l,f = cacheddir(mypath+"/"+list[x], + ignorecvs, + ignorelist, + EmptyOnError) + l=l[:] for y in range(0,len(l)): l[y]=list[x]+"/"+l[y] @@ -994,22 +1026,29 @@ def varexpand(mystring,mydict={}): continue elif (mystring[pos]=="$") and (mystring[pos-1]!="\\"): pos=pos+1 - if (pos+1)>=len(mystring): - cexpand[mystring]="" - return "" if mystring[pos]=="{": pos=pos+1 - terminus="}" + braced=True else: - terminus=string.whitespace + braced=False myvstart=pos - while mystring[pos] not in terminus: + validchars=string.ascii_letters+string.digits+"_" + while mystring[pos] in validchars: if (pos+1)>=len(mystring): - cexpand[mystring]="" - return "" + if braced: + cexpand[mystring]="" + return "" + else: + pos=pos+1 + break pos=pos+1 myvarname=mystring[myvstart:pos] - pos=pos+1 + if braced: + if mystring[pos]!="}": + cexpand[mystring]="" + return "" + else: + pos=pos+1 if len(myvarname)==0: cexpand[mystring]="" return "" @@ -1032,30 +1071,41 @@ def varexpand(mystring,mydict={}): # version is None and error is a string # def ExtractKernelVersion(base_dir): - pathname = os.path.join(base_dir, 'include/linux/version.h') + lines = [] + pathname = os.path.join(base_dir, 'Makefile') try: - lines = open(pathname, 'r').readlines() + f = open(pathname, 'r') except OSError, details: return (None, str(details)) except IOError, details: return (None, str(details)) + try: + for i in range(4): + lines.append(f.readline()) + except OSError, details: + return (None, str(details)) + except IOError, details: + return (None, str(details)) + lines = map(string.strip, lines) version = '' for line in lines: - items = string.split(line, ' ', 2) - if items[0] == '#define' and \ - items[1] == 'UTS_RELEASE': - version = items[2] # - may be wrapped in quotes - break + # split on the '=' then remove annoying whitespace + items = string.split(line, '=') + items = map(string.strip, items) + if items[0] == 'VERSION' or \ + items[0] == 'PATCHLEVEL': + version += items[1] + version += "." + elif items[0] == 'SUBLEVEL': + version += items[1] + elif items[0] == 'EXTRAVERSION' and \ + items[-1] != items[0]: + version += items[1] - if version == '': - return (None, "Unable to locate UTS_RELEASE in %s" % (pathname)) - - if version[0] == '"' and version[-1] == '"': - version = version[1:-1] return (version,None) aumtime=0 @@ -1090,8 +1140,10 @@ class config: if clone: self.incrementals = copy.deepcopy(clone.incrementals) self.profile_path = copy.deepcopy(clone.profile_path) - self.configs = copy.deepcopy(clone.configs) - self.defaults = copy.deepcopy(clone.defaults) + + self.module_priority = copy.deepcopy(clone.module_priority) + self.modules = copy.deepcopy(clone.modules) + self.packages = copy.deepcopy(clone.packages) self.virtuals = copy.deepcopy(clone.virtuals) @@ -1126,8 +1178,12 @@ class config: else: self.incrementals = copy.deepcopy(config_incrementals) - self.configs = {} - self.defaults = { + self.module_priority = ["user","default"] + self.modules = {} + self.modules["user"] = getconfig("/etc/portage/modules") + if self.modules["user"] == None: + self.modules["user"] = {} + self.modules["default"] = { "portdbapi.metadbmodule": "portage_db_flat.database", "portdbapi.auxdbmodule": "portage_db_flat.database", "eclass_cache.dbmodule": "portage_db_cpickle.database", @@ -1140,7 +1196,12 @@ class config: self.configdict={} # configlist will contain: [ globals, defaults, conf, pkg, auto, backupenv (incrementals), origenv ] - self.profiles=[abssymlink("/etc/make.profile")] + # The symlink might not exist or might not be a symlink. + try: + self.profiles=[abssymlink("/etc/make.profile")] + except: + self.profiles=["/etc/make.profile"] + mypath = self.profiles[0] while os.path.exists(mypath+"/parent"): mypath = os.path.normpath(os.path.dirname(mypath)+"///"+grabfile(mypath+"/parent")[0]) @@ -1232,6 +1293,10 @@ class config: self.regenerate() if mycpv: self.setcpv(mycpv) + + def load_best_module(self,property_string): + best_mod = best_from_dict(property_string,self.modules,self.module_priority) + return load_mod(best_mod) def lock(self): self.locked = 1 @@ -1470,6 +1535,10 @@ def spawn(mystring,mysettings,debug=0,free=0,droppriv=0,fd_pipes=None): mypid=os.fork() if mypid==0: + if fd_pipes: + os.dup2(fd_pipes[0], 0) # stdin -- (Read)/Write + os.dup2(fd_pipes[1], 1) # stdout -- Read/(Write) + os.dup2(fd_pipes[2], 2) # stderr -- Read/(Write) if droppriv: if portage_gid and portage_uid: #drop root privileges, become the 'portage' user @@ -3075,23 +3144,23 @@ def cpv_getkey(mycpv): else: return mysplit -def key_expand(mykey,mydb=None): +def key_expand(mykey,mydb=None,use_cache=1): mysplit=mykey.split("/") if len(mysplit)==1: if mydb and type(mydb)==types.InstanceType: for x in categories: - if mydb.cp_list(x+"/"+mykey): + if mydb.cp_list(x+"/"+mykey,use_cache=use_cache): return x+"/"+mykey if virts_p.has_key(mykey): return(virts_p[mykey][0]) return "null/"+mykey elif mydb: if type(mydb)==types.InstanceType: - if (not mydb.cp_list(mykey)) and virts and virts.has_key(mykey): + if (not mydb.cp_list(mykey,use_cache=use_cache)) and virts and virts.has_key(mykey): return virts[mykey][0] return mykey -def cpv_expand(mycpv,mydb=None): +def cpv_expand(mycpv,mydb=None,use_cache=1): myslash=mycpv.split("/") mysplit=pkgsplit(myslash[-1]) if len(myslash)>2: @@ -3105,7 +3174,7 @@ def cpv_expand(mycpv,mydb=None): mykey=mycpv if mydb: if type(mydb)==types.InstanceType: - if (not mydb.cp_list(mykey)) and virts and virts.has_key(mykey): + if (not mydb.cp_list(mykey,use_cache=use_cache)) and virts and virts.has_key(mykey): mykey=virts[mykey][0] #we only perform virtual expansion if we are passed a dbapi else: @@ -3119,7 +3188,7 @@ def cpv_expand(mycpv,mydb=None): matches=[] if mydb: for x in categories: - if mydb.cp_list(x+"/"+myp): + if mydb.cp_list(x+"/"+myp,use_cache=use_cache): matches.append(x+"/"+myp) if (len(matches)>1): raise ValueError, matches @@ -3162,7 +3231,7 @@ def dep_transform(mydep,oldkey,newkey): else: return origdep -def dep_expand(mydep,mydb=None): +def dep_expand(mydep,mydb=None,use_cache=1): if not len(mydep): return mydep if mydep[0]=="*": @@ -3178,7 +3247,7 @@ def dep_expand(mydep,mydb=None): elif mydep[:1] in "=<>~!": prefix=mydep[:1] mydep=mydep[1:] - return prefix+cpv_expand(mydep,mydb)+postfix + return prefix+cpv_expand(mydep,mydb,use_cache=use_cache)+postfix def dep_check(depstring,mydbapi,mysettings,use="yes",mode=None,myuse=None): """Takes a depend string and parses the condition.""" @@ -3639,7 +3708,7 @@ class dbapi: def __init__(self): pass - def cp_list(self,cp): + def cp_list(self,cp,use_cache=1): return def aux_get(self,mycpv,mylist): @@ -3648,11 +3717,11 @@ class dbapi: 'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com"] or [] if mycpv not found' pass - def match(self,origdep): + def match(self,origdep,use_cache=1): mydep=dep_expand(origdep,self) mykey=dep_getkey(mydep) mycat=mykey.split("/")[0] - return match_from_list(mydep,self.cp_list(mykey)) + return match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) def match2(self,mydep,mykey,mylist): writemsg("DEPRECATED: dbapi.match2\n") @@ -3668,11 +3737,10 @@ class dbapi: "This method will grab the next COUNTER value and record it back to the global file. Returns new counter value." cpath=myroot+"var/cache/edb/counter" changed=0 - min_counter = 0 if mycpv: mysplit = pkgsplit(mycpv) - for x in self.match(mysplit[0]): + for x in self.match(mysplit[0],use_cache=0): try: old_counter = long(self.aux_get(x,["COUNTER"])[0]) writemsg("COUNTER '%d' '%s'\n" % (old_counter, x),1) @@ -3750,7 +3818,7 @@ class fakedbapi(dbapi): def cpv_exists(self,mycpv): return self.cpvdict.has_key(mycpv) - def cp_list(self,mycp): + def cp_list(self,mycp,use_cache=1): if not self.cpdict.has_key(mycp): return [] else: @@ -3828,7 +3896,7 @@ class vardbapi(dbapi): cfile.close() elif os.path.exists(cdir): mys = pkgsplit(mycpv) - myl = self.match(mys[0]) + myl = self.match(mys[0],use_cache=0) print mys,myl if len(myl) == 1: try: @@ -3875,7 +3943,7 @@ class vardbapi(dbapi): def move_ent(self,mylist): origcp=mylist[1] newcp=mylist[2] - origmatches=self.match(origcp) + origmatches=self.match(origcp,use_cache=0) if not origmatches: return for mycpv in origmatches: @@ -3915,7 +3983,7 @@ class vardbapi(dbapi): origslot=mylist[2] newslot=mylist[3] - origmatches=self.match(pkg) + origmatches=self.match(pkg,use_cache=0) if not origmatches: return for mycpv in origmatches: @@ -3935,7 +4003,7 @@ class vardbapi(dbapi): slotfile.write(newslot+"\n") slotfile.close() - def cp_list(self,mycp): + def cp_list(self,mycp,use_cache=1): mysplit=mycp.split("/") if mysplit[0] == '*': mysplit[0] = mysplit[0][1:] @@ -3943,7 +4011,7 @@ class vardbapi(dbapi): mystat=os.stat(self.root+VDB_PATH+"/"+mysplit[0])[ST_MTIME] except OSError: mystat=0 - if self.cpcache.has_key(mycp): + if use_cache and self.cpcache.has_key(mycp): cpc=self.cpcache[mycp] if cpc[0]==mystat: return cpc[1] @@ -3963,19 +4031,22 @@ class vardbapi(dbapi): if len(mysplit) > 1: if ps[0]==mysplit[1]: returnme.append(mysplit[0]+"/"+x) - self.cpcache[mycp]=[mystat,returnme] + if use_cache: + self.cpcache[mycp]=[mystat,returnme] + elif self.cpcache.has_key(mycp): + del self.cpcache[mycp] return returnme - def cpv_all(self): + def cpv_all(self,use_cache=1): returnme=[] for x in categories: for y in listdir(self.root+VDB_PATH+"/"+x,EmptyOnError=1): returnme += [x+"/"+y] return returnme - def cp_all(self): + def cp_all(self,use_cache=1): returnme=[] - mylist = self.cpv_all() + mylist = self.cpv_all(use_cache=use_cache) for y in mylist: if y[0] == '*': y = y[1:] @@ -3991,13 +4062,18 @@ class vardbapi(dbapi): def checkblockers(self,origdep): pass - def match(self,origdep): + def match(self,origdep,use_cache=1): "caching match function" - mydep=dep_expand(origdep,self) + mydep=dep_expand(origdep,self,use_cache=use_cache) mykey=dep_getkey(mydep) mycat=mykey.split("/")[0] + if not use_cache: + if self.matchcache.has_key(mycat): + del self.mtdircache[mycat] + del self.matchcache[mycat] + return match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) try: - curmtime=os.stat(self.root+VDB_PATH+"/"+mycat) + curmtime=os.stat(self.root+VDB_PATH+"/"+mycat)[ST_MTIME] except: curmtime=0 @@ -4006,7 +4082,7 @@ class vardbapi(dbapi): self.mtdircache[mycat]=curmtime self.matchcache[mycat]={} if not self.matchcache[mycat].has_key(mydep): - mymatch=match_from_list(mydep,self.cp_list(mykey)) + mymatch=match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) self.matchcache[mycat][mydep]=mymatch return self.matchcache[mycat][mydep][:] @@ -4074,19 +4150,19 @@ class vartree(packagetree): myprovides[mykey] = [node] return myprovides - def dep_bestmatch(self,mydep): + def dep_bestmatch(self,mydep,use_cache=1): "compatibility method -- all matches, not just visible ones" #mymatch=best(match(dep_expand(mydep,self.dbapi),self.dbapi)) - mymatch=best(self.dbapi.match(dep_expand(mydep,self.dbapi))) + mymatch=best(self.dbapi.match(dep_expand(mydep,self.dbapi),use_cache=use_cache)) if mymatch==None: return "" else: return mymatch - def dep_match(self,mydep): + def dep_match(self,mydep,use_cache=1): "compatibility method -- we want to see all matches, not just visible ones" #mymatch=match(mydep,self.dbapi) - mymatch=self.dbapi.match(mydep) + mymatch=self.dbapi.match(mydep,use_cache=use_cache) if mymatch==None: return [] else: @@ -4105,8 +4181,8 @@ class vartree(packagetree): masked package for nodes in this nodes list.""" return self.dbapi.cp_all() - def exists_specific_cat(self,cpv): - cpv=key_expand(cpv,self.dbapi) + def exists_specific_cat(self,cpv,use_cache=1): + cpv=key_expand(cpv,self.dbapi,use_cache=use_cache) a=catpkgsplit(cpv) if not a: return 0 @@ -4124,8 +4200,8 @@ class vartree(packagetree): cat,package=fullpackage.split("/") return self.root+VDB_PATH+"/"+fullpackage+"/"+package+".ebuild" - def getnode(self,mykey): - mykey=key_expand(mykey,self.dbapi) + def getnode(self,mykey,use_cache=1): + mykey=key_expand(mykey,self.dbapi,use_cache=use_cache) if not mykey: return [] mysplit=mykey.split("/") @@ -4154,9 +4230,9 @@ class vartree(packagetree): pass return "" - def hasnode(self,mykey): + def hasnode(self,mykey,use_cache): """Does the particular node (cat/pkg key) exist?""" - mykey=key_expand(mykey,self.dbapi) + mykey=key_expand(mykey,self.dbapi,use_cache=use_cache) mysplit=mykey.split("/") mydirlist=listdir(self.root+VDB_PATH+"/"+mysplit[0],EmptyOnError=1) for x in mydirlist: @@ -4178,10 +4254,7 @@ class eclass_cache: self.settings = settings self.cachedir = self.settings["PORTAGE_CACHEDIR"] - try: - self.dbmodule = load_mod(self.settings.configs["eclass_cache.dbmodule"]) - except: - self.dbmodule = load_mod(self.settings.defaults["eclass_cache.dbmodule"]) + self.dbmodule = self.settings.load_best_module("eclass_cache.dbmodule") self.packages = {} # {"PV": {"eclass1": ["location", "_mtime_"]}} self.eclasses = {} # {"Name": ["location","_mtime_"]} @@ -4270,20 +4343,18 @@ class portdbapi(dbapi): self.root = root self.cachedir = self.mysettings["PORTAGE_CACHEDIR"] + + self.tmpfs = self.mysettings["PORTAGE_TMPFS"] + if not os.path.exists(self.tmpfs): + self.tmpfs = None self.eclassdb = eclass_cache(self.mysettings) - self.metadb = {} - try: - self.metadbmodule = load_mod(self.mysettings.configs["portdbapi.metadbmodule"]) - except: - self.metadbmodule = load_mod(self.mysettings.defaults["portdbapi.metadbmodule"]) + self.metadb = {} + self.metadbmodule = self.mysettings.load_best_module("portdbapi.metadbmodule") - self.auxdb={} - try: - self.auxdbmodule = load_mod(self.mysettings.configs["portdbapi.auxdbmodule"]) - except: - self.auxdbmodule = load_mod(self.mysettings.defaults["portdbapi.auxdbmodule"]) + self.auxdb = {} + self.auxdbmodule = self.mysettings.load_best_module("portdbapi.auxdbmodule") #if the portdbapi is "frozen", then we assume that we can cache everything (that no updates to it are happening) self.xcache={} @@ -4384,10 +4455,15 @@ class portdbapi(dbapi): if doregen or not self.eclassdb.is_current(cat,pkg,self.auxdb[cat][pkg]["INHERITED"].split()): stale=1 writemsg("doregen: %s %s\n" % (doregen,mycpv), 2) - writemsg("Generating cache entry(0) for: "+str(myebuild)+"\n",1) - mydbkey = self.cachedir+"/aux_db_key_temp" + + if self.tmpfs: + mydbkey = self.tmpfs+"/aux_db_key_temp" + else: + mydbkey = self.cachedir+"/aux_db_key_temp" + mylock = lockfile(mydbkey,unlinkfile=1) + myret=doebuild(myebuild,"depend","/",self.mysettings,dbkey=mydbkey) if myret: unlockfile(mylock) @@ -4485,7 +4561,7 @@ class portdbapi(dbapi): returnme.append(mye) return returnme - def cp_list(self,mycp): + def cp_list(self,mycp,use_cache=1): mysplit=mycp.split("/") returnme=[] list=listdir(self.root+"/"+mycp,EmptyOnError=1) @@ -4554,7 +4630,7 @@ class portdbapi(dbapi): self.xcache[level][mydep]=myval return myval - def match(self,mydep): + def match(self,mydep,use_cache=1): return self.xmatch("match-visible",mydep) def visible(self,mylist): @@ -5261,7 +5337,7 @@ class dblink: newworldlist=[] for x in worldlist: if dep_getkey(x)==mykey: - matches=db[self.myroot]["vartree"].dbapi.match(x) + matches=db[self.myroot]["vartree"].dbapi.match(x,use_cache=0) if not matches: #zap our world entry pass @@ -5361,6 +5437,7 @@ class dblink: # get current counter value (counter_tick also takes care of incrementing it) # XXX Need to make this destroot, but it needs to be initialized first. XXX + # XXX bis: leads to some invalidentry() call through cp_all(). counter = db["/"]["vartree"].dbapi.counter_tick(self.myroot,self.mycpv) # write local package counter for recording lcfile = open(self.dbtmpdir+"/COUNTER","w") @@ -5480,6 +5557,10 @@ class dblink: #update environment settings, library paths. DO NOT change symlinks. env_update(makelinks=0) + #dircache may break autoclean because it remembers the -MERGING-pkg file + global dircache + if dircache.has_key(self.dbcatdir): + del dircache[self.dbcatdir] print ">>>",self.mycpv,"merged." @@ -5900,14 +5981,20 @@ if not os.path.exists(root+"var/tmp"): os.umask(022) profiledir=None if os.path.exists("/etc/make.profile/make.defaults"): - profiledir="/etc/make.profile" + profiledir = "/etc/make.profile" if os.access("/etc/make.profile/deprecated", os.R_OK): deprecatedfile = open("/etc/make.profile/deprecated", "r") - newprofile=deprecatedfile.read() + dcontent = deprecatedfile.readlines() deprecatedfile.close() - writemsg(red("!!! Your current profile is deprecated and not supported anymore.\n")) + newprofile = dcontent[0] + writemsg(red("\n!!! Your current profile is deprecated and not supported anymore.\n")) writemsg(red("!!! Please upgrade to the following profile if possible:\n")) writemsg(8*" "+green(newprofile)+"\n") + if len(dcontent) > 1: + writemsg("To upgrade do the following steps:\n") + for myline in dcontent[1:]: + writemsg(myline) + writemsg("\n\n") db={} @@ -6131,6 +6218,13 @@ def do_upgrade(mykey): def portageexit(): global uid,portage_gid,portdb if secpass and not os.environ.has_key("SANDBOX_ACTIVE"): + # wait child process death + try: + while True: + os.wait() + except OSError: + #writemsg(">>> All child process are now dead.") + pass if mtimedb: # Store mtimedb mymfn=mtimedbfile diff --git a/src/sandbox-1.1/Makefile b/src/sandbox-1.1/Makefile index 1cdd83c..6115e27 100644 --- a/src/sandbox-1.1/Makefile +++ b/src/sandbox-1.1/Makefile @@ -10,7 +10,7 @@ # # Indent: indent -kr -i2 -ts2 -sob -l80 -ss -bs -psl # -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/Makefile,v 1.5 2003/07/27 12:31:06 azarah Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/Makefile,v 1.6 2004/02/04 22:40:21 carpaski Exp $ CC = gcc LD = ld @@ -30,13 +30,13 @@ sandbox: sandbox.o sandbox_futils.o getcwd.c sandbox.o: sandbox.c sandbox.h $(CC) $(CFLAGS) -Wall -c sandbox.c -sandbox_futils.o: sandbox_futils.c sandbox.h +sandbox_futils.o: localdecls.h sandbox_futils.c sandbox.h $(CC) $(CFLAGS) -Wall -c $(OBJ_DEFINES) sandbox_futils.c libsandbox.so: libsandbox.o sandbox_futils.o $(CC) $^ -shared -fPIC -ldl -lc -o $@ -nostdlib -lgcc -libsandbox.o: libsandbox.c localdecls.h canonicalize.c getcwd.c +libsandbox.o: localdecls.h libsandbox.c canonicalize.c getcwd.c $(CC) $(CFLAGS) -Wall -c $(OBJ_DEFINES) libsandbox.c localdecls.h: create-localdecls libctest.c |