From eda6e4874e4a208b2e9c46f0b5f0719231a90886 Mon Sep 17 00:00:00 2001 From: Kito Date: Sun, 19 Mar 2006 01:27:57 +0000 Subject: [PATCH] merge with trunk rev 2936:2947 svn path=/main/branches/prefix/; revision=2948 --- bin/dobin | 2 +- bin/dosbin | 2 +- bin/ebuild.sh | 3 ++- bin/emerge-webrsync | 6 +++--- bin/misc-functions.sh | 8 ++++---- pym/cache/flat_hash.py | 14 ++++++------- pym/cache/flat_list.py | 12 ++++------- pym/emergehelp.py | 4 ++-- pym/portage.py | 46 +++++++++++++++++++++++++----------------- 9 files changed, 51 insertions(+), 46 deletions(-) diff --git a/bin/dobin b/bin/dobin index 65ca298af..331cec7fe 100755 --- a/bin/dobin +++ b/bin/dobin @@ -16,7 +16,7 @@ ret=0 for x in "$@" ; do if [[ -e ${x} ]] ; then - install -m 0755 -o ${PORTAGE_INST_UID} -g ${PORTAGE_INST_GID} "${x}" "${D}${DESTTREE}/bin" + install -m 0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/bin" else echo "!!! ${0##*/}: ${x} does not exist" 1>&2 false diff --git a/bin/dosbin b/bin/dosbin index 0c3d52639..46c1ce2f4 100755 --- a/bin/dosbin +++ b/bin/dosbin @@ -16,7 +16,7 @@ ret=0 for x in "$@" ; do if [[ -e ${x} ]] ; then - install -m 0755 -o ${PORTAGE_INST_UID} -g ${PORTAGE_INST_GID} "${x}" "${D}${DESTTREE}/sbin" + install -m 0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/sbin" else echo "!!! ${0##*/}: ${x} does not exist" 1>&2 false diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 10479ded8..5b5976712 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1351,7 +1351,8 @@ inherit() { shift done - ((--ECLASS_DEPTH)) + ((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0. + return 0 } # Exports stub functions that call the eclass's functions, thereby making them default. diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 3c1f1d50b..882f66061 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -52,7 +52,7 @@ fi sync_local() { echo Syncing local tree... if type -p tarsync &> /dev/null; then - if ! tarsync "${FILE}" "${PORTDIR}" -v -s 1 -o ${PORTAGE_INST_UID} -g ${PORTAGE_INST_GID} -e /distfiles -e /packages -e /local; then + if ! tarsync "${FILE}" "${PORTDIR}" -v -s 1 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} -e /distfiles -e /packages -e /local; then echo "tarsync failed; tarball is corrupt?" exit 1; fi @@ -65,7 +65,7 @@ sync_local() { fi rm -f $FILE # Make sure user and group file ownership is ${PORTAGE_INST_UID}:${PORTAGE_INST_GID} - chown -R ${PORTAGE_INST_UID}:${PORTAGE_INST_GID} portage + chown -R ${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0} portage cd portage rsync -av --progress --stats --delete --delete-after \ --exclude='/distfiles' --exclude='/packages' \ @@ -124,7 +124,7 @@ while (( $attempts < 40 )) ; do echo " === snapshot $FILE is correct, using it" sync_local echo - echo " === Snapshot has beed sync'd" + echo " === Snapshot has been sync'd" echo exit 0 else diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 88d81dbc5..21983f4ae 100644 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -220,14 +220,14 @@ install_qa_check() { find "${D}/" -user @portageuser@ | while read file; do count=$(( $count + 1 )) if [ -L "${file}" ]; then - lchown ${PORTAGE_INST_UID} "${file}" + lchown ${PORTAGE_INST_UID:-0} "${file}" else s=$(stat_perms "$file") if [ -z "${s}" ]; then ewarn "failed stat_perm'ing $file. User intervention during install isn't wise..." continue fi - chown ${PORTAGE_INST_UID} "$file" + chown ${PORTAGE_INST_UID:-0} "$file" chmod "$s" "$file" fi done @@ -239,14 +239,14 @@ install_qa_check() { find "${D}/" -group @portagegroup@ | while read file; do count=$(( $count + 1 )) if [ -L "${file}" ]; then - lchgrp ${PORTAGE_INST_GID} "${file}" + lchgrp ${PORTAGE_INST_GID:-0} "${file}" else s=$(stat_perms "$file") if [ -z "${s}" ]; then echo "failed stat_perm'ing '$file' . User intervention during install isn't wise..." continue fi - chgrp ${PORTAGE_INST_GID} "$file" + chgrp ${PORTAGE_INST_GID:-0} "$file" chmod "$s" "$file" fi done diff --git a/pym/cache/flat_hash.py b/pym/cache/flat_hash.py index 1bdc7cd5b..8ebd70f7d 100644 --- a/pym/cache/flat_hash.py +++ b/pym/cache/flat_hash.py @@ -5,7 +5,7 @@ import fs_template import cache_errors -import os, stat +import errno, os, stat from mappings import LazyLoad, ProtectedDict from template import reconstruct_eclasses # store the current key order *here*. @@ -70,16 +70,16 @@ class database(fs_template.FsBased): s = cpv.rfind("/") fp = os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) try: myf=open(fp, "w") - except IOError, ie: - if ie.errno == 2: + except (IOError, OSError), e: + if errno.ENOENT == e.errno: try: self._ensure_dirs(cpv) myf=open(fp,"w") except (OSError, IOError),e: raise cache_errors.CacheCorruption(cpv, e) - except OSError, e: - raise cache_errors.CacheCorruption(cpv, e) - + else: + raise cache_errors.CacheCorruption(cpv, e) + for k, v in values.items(): if k != "_mtime_" and (k == "_eclasses_" or k in self._known_keys): myf.writelines("%s=%s\n" % (k, v)) @@ -101,7 +101,7 @@ class database(fs_template.FsBased): try: os.remove(os.path.join(self.location,cpv)) except OSError, e: - if e.errno == 2: + if errno.ENOENT == e.errno: raise KeyError(cpv) else: raise cache_errors.CacheCorruption(cpv, e) diff --git a/pym/cache/flat_list.py b/pym/cache/flat_list.py index 944f7406d..135b31e39 100644 --- a/pym/cache/flat_list.py +++ b/pym/cache/flat_list.py @@ -1,6 +1,6 @@ import fs_template import cache_errors -import os, stat +import errno, os, stat # store the current key order *here*. class database(fs_template.FsBased): @@ -31,11 +31,7 @@ class database(fs_template.FsBased): for k,v in zip(self.auxdbkey_order, myf): d[k] = v.rstrip("\n") except (OSError, IOError),e: - if isinstance(e,IOError) and e.errno == 2: -# print "caught for %s" % cpv, e -# l=os.listdir(os.path.dirname(os.path.join(self._base,cpv))) -# l.sort() -# print l + if errno.ENOENT == e.errno: raise KeyError(cpv) raise cache_errors.CacheCorruption(cpv, e) @@ -52,7 +48,7 @@ class database(fs_template.FsBased): fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) try: myf=open(fp, "w") except (OSError, IOError), e: - if e.errno == 2: + if errno.ENOENT == e.errno: try: self._ensure_dirs(cpv) myf=open(fp,"w") @@ -79,7 +75,7 @@ class database(fs_template.FsBased): try: os.remove(os.path.join(self._base,cpv)) except OSError, e: - if e.errno == 2: + if errno.ENOENT == e.errno: raise KeyError(cpv) else: raise cache_errors.CacheCorruption(cpv, e) diff --git a/pym/emergehelp.py b/pym/emergehelp.py index 2936dd628..bab788fe6 100644 --- a/pym/emergehelp.py +++ b/pym/emergehelp.py @@ -180,7 +180,7 @@ def help(myaction,myopts,havecolor=1): print " used in combination with --pretend all the SRC_URIs will be" print " displayed multiple mirrors per line, one line per file." print - print " "+green("--fetch-all-uri") + print " "+green("--fetch-all-uri")+" ("+green("-F")+" short option)" print " Same as --fetchonly except that all package files, including those" print " not required to build the package, will be processed." print @@ -222,7 +222,7 @@ def help(myaction,myopts,havecolor=1): print " "+green("--nospinner") print " Disables the spinner regardless of terminal type." print - print " "+green("--oneshot") + print " "+green("--oneshot")+" ("+green("-1")+" short option)" print " Emerge as normal, but don't add packages to the world profile." print " This package will only be updated if it is depended upon by" print " another package." diff --git a/pym/portage.py b/pym/portage.py index d931e967d..0d71ec03e 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1642,21 +1642,23 @@ def spawn(mystring,mysettings,debug=0,free=0,droppriv=0,sesandbox=0,fd_pipes=Non free=((droppriv and "usersandbox" not in features) or \ (not droppriv and "sandbox" not in features and "usersandbox" not in features)) + if free: + keywords["opt_name"] += " bash" + else: + keywords["opt_name"] += " sandbox" + if sesandbox: con = selinux.getcontext() con = string.replace(con, mysettings["PORTAGE_T"], mysettings["PORTAGE_SANDBOX_T"]) selinux.setexec(con) - if not free: - keywords["opt_name"] += " sandbox" - return portage_exec.spawn_sandbox(mystring,env=env,**keywords) - else: - keywords["opt_name"] += " bash" - return portage_exec.spawn_bash(mystring,env=env,**keywords) - + retval = portage_exec.spawn_bash(mystring, env=env, **keywords) + if sesandbox: selinux.setexec(None) + return retval + def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",use_locks=1, try_mirrors=1): "fetch files. Will use digest file if available." @@ -4738,23 +4740,25 @@ class portdbapi(dbapi): return self.findname2(mycpv)[0] def findname2(self,mycpv): - "returns file location for this particular package and in_overlay flag" + """ + Returns the location of the CPV, and what overlay it was in. + Searches overlays first, then PORTDIR; this allows us to return the first + matching file. As opposed to starting in portdir and then doing overlays + second, we would have to exhaustively search the overlays until we found + the file we wanted. + """ if not mycpv: return "",0 mysplit=mycpv.split("/") - psplit=pkgsplit(mysplit[1]) - ret=None + + mytrees = self.porttrees[:] + mytrees.reverse() if psplit: - for x in self.porttrees: + for x in mytrees: file=x+"/"+mysplit[0]+"/"+psplit[0]+"/"+mysplit[1]+".ebuild" if os.access(file, os.R_OK): - # when found - ret=[file, x] - if ret: - return ret[0], ret[1] - - # when not found + return[file, x] return None, 0 def aux_get(self, mycpv, mylist): @@ -5170,10 +5174,14 @@ class portdbapi(dbapi): for mycpv in mylist: #we need to update this next line when we have fully integrated the new db api auxerr=0 + keys = None try: keys, eapi = db["/"]["porttree"].dbapi.aux_get(mycpv, ["KEYWORDS", "EAPI"]) - except (KeyError,IOError,TypeError): - continue + except KeyError: + pass + except portage_exception.PortageException, e: + writemsg("!!! Error: aux_get('%s', ['KEYWORDS', 'EAPI'])\n" % mycpv) + writemsg("!!! %s\n" % str(e)) if not keys: # KEYWORDS="" #print "!!! No KEYWORDS for "+str(mycpv)+" -- Untested Status" -- 2.26.2