portage._doebuild_manifest_exempt_depend -= 1
tmpsettings = portage.config(clone=portage.settings)
-if "test" in pargs and "test" not in tmpsettings.features:
- print "Forcing test."
+if "test" in pargs:
+ # This variable is a signal to config.regenerate() to
+ # indicate that the test phase should be enabled regardless
+ # of problems such as masked "test" USE flag.
tmpsettings["EBUILD_FORCE_TEST"] = "1"
tmpsettings.backup_changes("EBUILD_FORCE_TEST")
- tmpsettings.features.append("test")
- tmpsettings["FEATURES"] = " ".join(tmpsettings.features)
- tmpsettings.backup_changes("FEATURES")
+ if "test" not in tmpsettings.features:
+ tmpsettings.features.append("test")
+ tmpsettings.features.sort()
+ tmpsettings["FEATURES"] = " ".join(tmpsettings.features)
+ tmpsettings.backup_changes("FEATURES")
build_dir_phases = set(["setup", "unpack", "compile",
"test", "install", "package", "rpm"])
SANDBOX_PREDICT="${SANDBOX_PREDICT}:/proc/self/maps:/dev/console:/dev/random"
export SANDBOX_PREDICT="${SANDBOX_PREDICT}:${PORTAGE_PYM_PATH}:${PORTAGE_DEPCACHEDIR}"
export SANDBOX_WRITE="${SANDBOX_WRITE}:/dev/shm:/dev/stdout:/dev/stderr:${PORTAGE_TMPDIR}"
-export SANDBOX_READ="${SANDBOX_READ}:/dev/shm:/dev/stdin:${PORTAGE_TMPDIR}"
+export SANDBOX_READ="${SANDBOX_READ}:/:/dev/shm:/dev/stdin:${PORTAGE_TMPDIR}"
# Don't use sandbox's BASH_ENV for new shells because it does
# 'source /etc/profile' which can interfere with the build
# environment by modifying our PATH.
fi
if ! hasq test $FEATURES && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
vecho ">>> Test phase [not enabled]: ${CATEGORY}/${PF}"
- elif ! hasq test ${USE} && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
- ewarn "Skipping make test/check since USE=test is masked."
- vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
elif hasq test $RESTRICT; then
ewarn "Skipping make test/check due to ebuild restriction."
vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
# portage config variables and variables set directly by portage
unset BAD BRACKET BUILD_PREFIX COLS \
DISTCC_DIR DISTDIR DOC_SYMLINKS_DIR \
- EBUILD_EXIT_STATUS_FILE EBUILD_MASTER_PID \
+ EBUILD_EXIT_STATUS_FILE EBUILD_FORCE_TEST EBUILD_MASTER_PID \
ECLASSDIR ECLASS_DEPTH ENDCOL FAKEROOTKEY \
GOOD HILITE HOME IMAGE \
LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
# Smart FileSystem Permissions
if hasq sfperms $FEATURES; then
local i
-#note not space-safe
- for i in $(find "${ED}" -type f -perm -4000); do
+ find "${ED}" -type f -perm -4000 -print0 | \
+ while read -d $'\0' i ; do
if [ -n "$(find "$i" -perm -2000)" ] ; then
ebegin ">>> SetUID and SetGID: [chmod o-r] /${i#${D}}"
chmod o-r "$i"
eend $?
fi
done
-#note not space-safe
- for i in $(find "${ED}" -type f -perm -2000); do
+ find "${ED}" -type f -perm -2000 -print0 | \
+ while read -d $'\0' i ; do
if [ -n "$(find "$i" -perm -4000)" ] ; then
# This case is already handled
# by the SetUID check above.
mysettings=self.settings, all=True)[1]
try:
mysum[0] = mf.getDistfilesSize(fetchlist)
- mystr = str(mysum[0] / 1024)
- mycount = len(mystr)
- while (mycount > 3):
- mycount -= 3
- mystr = mystr[:mycount] + "," + mystr[mycount:]
- mysum[0] = mystr + " kB"
except KeyError, e:
mysum[0] = "Unknown (missing digest for %s)" % \
str(e)
if db is not vardb and \
db.cpv_exists(mycpv):
available = True
+ if not myebuild and hasattr(db, "bintree"):
+ myebuild = db.bintree.getname(mycpv)
+ try:
+ mysum[0] = os.stat(myebuild).st_size
+ except OSError:
+ myebuild = None
break
+ if myebuild:
+ mystr = str(mysum[0] / 1024)
+ mycount = len(mystr)
+ while (mycount > 3):
+ mycount -= 3
+ mystr = mystr[:mycount] + "," + mystr[mycount:]
+ mysum[0] = mystr + " kB"
+
if self.verbose:
if available:
print " ", darkgreen("Latest version available:"),myversion
try:
dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys())
except CacheError, e:
- print "Error listing cache entries for " + \
- "'%s': %s, continuing..." % (mytree, e)
+ portage.writemsg("Error listing cache entries for " + \
+ "'%s': %s, continuing...\n" % (mytree, e), noiselevel=-1)
del e
dead_nodes = None
break
for y in mymatches:
try:
foo = portdb.aux_get(y,["DEPEND"])
- except SystemExit, e:
- # sys.exit is an exception... And consequently, we can't catch it.
- raise
- except Exception, e:
- print "Error processing %(cpv)s, continuing... (%(e)s)" % {"cpv":y,"e":str(e)}
+ except (KeyError, portage.exception.PortageException), e:
+ portage.writemsg(
+ "Error processing %(cpv)s, continuing... (%(e)s)\n" % \
+ {"cpv":y,"e":str(e)}, noiselevel=-1)
if dead_nodes:
for mytree in portdb.porttrees:
if portdb.findname2(y, mytree=mytree)[0]:
# in it's bashrc (causing major leakage).
_environ_whitelist += [
"BASH_ENV", "BUILD_PREFIX", "D",
- "DISTDIR", "DOC_SYMLINKS_DIR", "EBUILD_EXIT_STATUS_FILE",
- "EBUILD", "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM",
+ "DISTDIR", "DOC_SYMLINKS_DIR", "EBUILD",
+ "EBUILD_EXIT_STATUS_FILE", "EBUILD_FORCE_TEST",
+ "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM",
"FEATURES", "FILESDIR", "HOME", "PATH",
"PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR",
"PORTAGE_ACTUAL_DISTDIR", "PORTAGE_ARCHLIST",
self[var] = "0"
self.backup_changes(var)
+ # initialize self.features
self.regenerate()
- self.features = portage.util.unique_array(self["FEATURES"].split())
if local_config:
self._accept_license = \
myflags.update(self.useforce)
+ iuse = self.configdict["pkg"].get("IUSE","").split()
+ iuse = [ x.lstrip("+-") for x in iuse ]
# FEATURES=test should imply USE=test
- if "test" in self.configlist[-1].get("FEATURES","").split():
- myflags.add("test")
- if self.get("EBUILD_FORCE_TEST") == "1":
- self.usemask.discard("test")
+ if not hasattr(self, "features"):
+ self.features = list(sorted(set(
+ self.configlist[-1].get("FEATURES","").split())))
+ self["FEATURES"] = " ".join(self.features)
+ ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
+ if ebuild_force_test and \
+ self.get("EBUILD_PHASE") == "test" and \
+ not hasattr(self, "_ebuild_force_test_msg_shown"):
+ self._ebuild_force_test_msg_shown = True
+ writemsg("Forcing test.\n", noiselevel=-1)
+ if "test" in self.features and "test" in iuse:
+ if "test" in self.usemask and not ebuild_force_test:
+ # "test" is in IUSE and USE=test is masked, so execution
+ # of src_test() probably is not reliable. Therefore,
+ # temporarily disable FEATURES=test just for this package.
+ self["FEATURES"] = " ".join(x for x in self.features \
+ if x != "test")
+ myflags.discard("test")
+ else:
+ myflags.add("test")
+ if ebuild_force_test:
+ self.usemask.discard("test")
usesplit = [ x for x in myflags if \
x not in self.usemask]
# Use the calculated USE flags to regenerate the USE_EXPAND flags so
# that they are consistent.
- iuse = self.configdict["pkg"].get("IUSE","").split()
- iuse = [ x.lstrip("+-") for x in iuse ]
for var in use_expand:
prefix = var.lower() + "_"
prefix_len = len(prefix)
# * Masked flags, such as those from {,package}use.mask
# * Forced flags, such as those from {,package}use.force
# * build and bootstrap flags used by bootstrap.sh
- # * The "test" flag that's enabled by FEATURES=test
# Do this even when there's no package since setcpv() can
# optimize away regenerate() calls.
# build and bootstrap flags used by bootstrap.sh
iuse_implicit.add("build")
iuse_implicit.add("bootstrap")
- iuse_implicit.add("test")
# prefix flag is used in Prefix
iuse_implicit.add("prefix")
if env_stat:
mysettings._filter_calling_env = True
else:
- for var in "ARCH", "USERLAND":
- if mysettings.get(var):
+ for var in "ARCH", "USERLAND", "XARGS":
+ value = mysettings.get(var)
+ if value and value.strip():
+ continue
+ if var == "USERLAND" and userland:
+ mysettings["USERLAND"] = userland
continue
msg = ("%s is not set... " % var) + \
("Are you missing the '%setc/make.profile' symlink? " % \
virts_p = settings.get_virts_p("/")
if len(mysplit)==1:
if hasattr(mydb, "cp_list"):
- for x in settings.categories:
+ for x in mydb.categories:
if mydb.cp_list(x+"/"+mykey,use_cache=use_cache):
return x+"/"+mykey
if virts_p.has_key(mykey):
myp=mycpv
mykey=None
matches=[]
- if mydb:
- for x in settings.categories:
+ if mydb and hasattr(mydb, "categories"):
+ for x in mydb.categories:
if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
matches.append(x+"/"+myp)
if len(matches) > 1:
userland = None
lchown = getattr(os, "lchown", None)
-os.environ.setdefault("XARGS", "xargs")
+os.environ.setdefault("XARGS", "xargs -r")
os.environ["XARGS"]="xargs -r"
# "fix" for lchown on Darwin
class dbapi(object):
_category_re = re.compile(r'^\w[-.+\w]*$')
_pkg_dir_name_re = re.compile(r'^\w[-+\w]*$')
+ _categories = None
def __init__(self):
pass
+ @property
+ def categories(self):
+ """
+ Use self.cp_all() to generate a category list. Mutable instances
+ can delete the self._categories attribute in cases when the cached
+ categories become invalid and need to be regenerated.
+ """
+ if self._categories is not None:
+ return self._categories
+ categories = set()
+ cat_pattern = re.compile(r'(.*)/.*')
+ for cp in self.cp_all():
+ categories.add(cat_pattern.match(cp).group(1))
+ self._categories = list(categories)
+ self._categories.sort()
+ return self._categories
+
def close_caches(self):
pass
else:
from portage import settings
self.mysettings = config(clone=settings)
- self._categories = set(self.mysettings.categories)
# This is strictly for use in aux_get() doebuild calls when metadata
# is generated by the depend phase. It's safest to use a clone for
# this purpose because doebuild makes many changes to the config
class vardbapi(dbapi):
def __init__(self, root, categories=None, settings=None, vartree=None):
+ """
+ The categories parameter is unused since the dbapi class
+ now has a categories property that is generated from the
+ available packages.
+ """
self.root = root[:]
#cache for category directory mtimes
if settings is None:
from portage import settings
self.settings = settings
- # The categories list is now automatically generated
- # from a regular expression.
- self.categories = None
if vartree is None:
from portage import db
vartree = db[root]["vartree"]
writemsg("!!! Initializing COUNTER to " + \
"value of %d\n" % counter, noiselevel=-1)
- if counter != real_counter:
- changed = True
- writemsg("!!! Initializing COUNTER to " + \
- "value of %d\n" % real_counter, noiselevel=-1)
-
# Never trust the counter file, since having a
# corrupt value that is too low there can trigger
# incorrect AUTOCLEAN behavior due to newly installed
The caller must ensure that lockdb() and unlockdb() are called
before and after this method.
"""
-
+ if self.vartree.dbapi._categories is not None:
+ self.vartree.dbapi._categories = None
# When others_in_slot is supplied, the security check has already been
# done for this slot, so it shouldn't be repeated until the next
# replacement or unmerge operation.
we won't be able to later if they get unmerged (happens
when namespace changes).
"""
+ if self.vartree.dbapi._categories is not None:
+ self.vartree.dbapi._categories = None
if self.myroot == "/" and \
"sys-apps" == self.cat and \
"portage" == pkgsplit(self.pkg)[0] and \
self._match_cache = {}
def _clear_cache(self):
+ if self._categories is not None:
+ self._categories = None
if self._match_cache:
self._match_cache = {}