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
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
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.
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
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' \
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
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
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
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*.
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))
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)
import fs_template
import cache_errors
-import os, stat
+import errno, os, stat
# store the current key order *here*.
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)
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")
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)
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
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."
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."
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):
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"