cd "${PORTAGE_BUILDDIR}"/build-info
set -f
- local f
+ local f x
+ IFS=$' \t\n\r'
for f in ASFLAGS CATEGORY CBUILD CC CFLAGS CHOST CTARGET CXX \
CXXFLAGS DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \
FEATURES INHERITED IUSE LDFLAGS LIBCFLAGS LIBCXXFLAGS \
LICENSE PDEPEND PF PKGUSE PROPERTIES PROVIDE RDEPEND RESTRICT SLOT \
KEYWORDS HOMEPAGE SRC_URI DESCRIPTION; do
- [ -n "${!f}" ] && echo $(echo "${!f}" | \
- tr '\n,\r,\t' ' , , ' | sed s/' \+'/' '/g) > ${f}
+ x=$(echo -n ${!f})
+ [[ -n $x ]] && echo "$x" > $f
done
echo "${EPREFIX}" > EPREFIX
echo "${USE}" > USE
"clean", "config", "depclean",
"info", "list-sets", "metadata",
"prune", "regen", "search",
-"sync", "unmerge",
+"sync", "unmerge", "version",
])
options=[
"--ask", "--alphabetical",
"--tree",
"--update",
"--usepkg", "--usepkgonly",
-"--verbose", "--version"
+"--verbose",
]
shortmapping={
try:
f = open(self._cache_filename, mode='rb')
mypickle = pickle.Unpickler(f)
+ try:
+ mypickle.find_global = None
+ except AttributeError:
+ # TODO: If py3k, override Unpickler.find_class().
+ pass
self._cache_data = mypickle.load()
f.close()
del f
xinfo = xinfo.replace("null/", "")
masked_packages = []
missing_use = []
+ masked_pkg_instances = set()
missing_licenses = []
have_eapi_mask = False
pkgsettings = self.pkgsettings[root]
# Filter out any such false matches here.
if not atom_set.findAtomForPackage(pkg):
continue
- if atom.use and not mreasons:
+ if mreasons:
+ masked_pkg_instances.add(pkg)
+ if atom.use:
missing_use.append(pkg)
- continue
+ if not mreasons:
+ continue
masked_packages.append(
(root_config, pkgsettings, cpv, metadata, mreasons))
mreasons.append("Change USE: %s" % " ".join(changes))
missing_use_reasons.append((pkg, mreasons))
- if missing_iuse_reasons and not missing_use_reasons:
- missing_use_reasons = missing_iuse_reasons
- elif missing_use_reasons:
+ unmasked_use_reasons = [(pkg, mreasons) for (pkg, mreasons) \
+ in missing_use_reasons if pkg not in masked_pkg_instances]
+
+ unmasked_iuse_reasons = [(pkg, mreasons) for (pkg, mreasons) \
+ in missing_iuse_reasons if pkg not in masked_pkg_instances]
+
+ show_missing_use = False
+ if unmasked_use_reasons:
# Only show the latest version.
- del missing_use_reasons[1:]
+ show_missing_use = unmasked_use_reasons[:1]
+ elif unmasked_iuse_reasons:
+ if missing_use_reasons:
+ # All packages with required IUSE are masked,
+ # so display a normal masking message.
+ pass
+ else:
+ show_missing_use = unmasked_iuse_reasons
- if missing_use_reasons:
+ if show_missing_use:
print "\nemerge: there are no ebuilds built with USE flags to satisfy "+green(xinfo)+"."
print "!!! One of the following packages is required to complete your request:"
- for pkg, mreasons in missing_use_reasons:
+ for pkg, mreasons in show_missing_use:
print "- "+pkg.cpv+" ("+", ".join(mreasons)+")"
elif masked_packages:
if "--buildpkgonly" in myopts:
graph_copy = mydepgraph.digraph.clone()
removed_nodes = set()
- for node in list(graph_copy.order):
+ for node in graph_copy:
if not isinstance(node, Package) or \
node.operation == "nomerge":
removed_nodes.add(node)
if "--buildpkgonly" in myopts:
graph_copy = mydepgraph.digraph.clone()
removed_nodes = set()
- for node in list(graph_copy.order):
+ for node in graph_copy:
if not isinstance(node, Package) or \
node.operation == "nomerge":
removed_nodes.add(node)
if v is not None:
myopts[myopt] = v
+ if myoptions.searchdesc:
+ myoptions.search = True
+
for action_opt in actions:
v = getattr(myoptions, action_opt.replace("-", "_"))
if v:
mysettings = trees[myroot]["vartree"].settings
mysettings.unlock()
adjust_config(myopts, mysettings)
- if "--pretend" not in myopts:
+ if '--pretend' not in myopts and myaction in \
+ (None, 'clean', 'depclean', 'prune', 'unmerge'):
mysettings["PORTAGE_COUNTER_HASH"] = \
trees[myroot]["vartree"].dbapi._counter_hash()
mysettings.backup_changes("PORTAGE_COUNTER_HASH")
if "--buildpkg" not in myopts:
myopts["--buildpkg"] = True
- # Also allow -S to invoke search action (-sS)
- if ("--searchdesc" in myopts):
- if myaction and myaction != "search":
- myfiles.append(myaction)
- if "--search" not in myopts:
- myopts["--search"] = True
- myaction = "search"
-
# Always try and fetch binary packages if FEATURES=getbinpkg
if ("getbinpkg" in settings.features):
myopts["--getbinpkg"] = True
if not sys.stdout.isatty() or ("--nospinner" in myopts):
spinner.update = spinner.update_basic
- if "--version" in myopts:
+ if myaction == 'version':
print getportageversion(settings["PORTDIR"], settings["ROOT"],
settings.profile_path, settings["CHOST"],
trees[settings["ROOT"]]["vartree"].dbapi)
#getting categories from an external file now
categories = [grabfile(os.path.join(x, "categories")) for x in locations]
- self.categories = stack_lists(categories, incremental=1)
+ self.categories = tuple(sorted(
+ stack_lists(categories, incremental=1)))
del categories
archlist = [grabfile(os.path.join(x, "arch.list")) for x in locations]
try:
f = open(filename, 'rb')
mypickle = pickle.Unpickler(f)
+ try:
+ mypickle.find_global = None
+ except AttributeError:
+ # TODO: If py3k, override Unpickler.find_class().
+ pass
d = mypickle.load()
f.close()
del f
del self[k]
return (k, v)
- def update(self, other=None, **kwargs):
+ def update(self, *args, **kwargs):
+ if len(args) > 1:
+ raise TypeError(
+ "expected at most 1 positional argument, got " + \
+ repr(len(args)))
+ other = None
+ if args:
+ other = args[0]
if other is None:
pass
elif hasattr(other, 'iteritems'):
self[key] = default
return default
- def update(self, other=None, **kwargs):
+ def update(self, *args, **kwargs):
+ if len(args) > 1:
+ raise TypeError(
+ "expected at most 1 positional argument, got " + \
+ repr(len(args)))
+ other = None
+ if args:
+ other = args[0]
if other is None:
pass
elif hasattr(other, 'iteritems'):
# because it calls reconstruct_eclasses() internally.
d["_eclasses_"] = reconstruct_eclasses(None, d["_eclasses_"])
- for x in self._known_keys:
- d.setdefault(x, '')
-
return d
def _setitem(self, cpv, values):
column_index +=1
if k not in internal_columns:
d[k] = result[0][column_index]
- # XXX: The resolver chokes on unicode strings so we convert them here.
- for k in d.keys():
- try:
- d[k]=str(d[k]) # convert unicode strings to normal
- except UnicodeEncodeError, e:
- pass #writemsg("%s: %s\n" % (cpv, str(e)))
- for x in self._known_keys:
- d.setdefault(x,'')
+
return d
def _setitem(self, cpv, values):
for cpv in self._remotepkgs:
self.dbapi.cpv_inject(cpv)
self.populated = 1
- if getbinpkgsonly:
+ if True:
# Remote package instances override local package
# if they are not identical.
hash_names = ["SIZE"] + self._pkgindex_hashes
break
if identical:
del self._remotepkgs[cpv]
+ else:
+ # Override the local package in the aux_get cache.
+ self.dbapi._aux_cache[cpv] = remote_metadata
else:
# Local package instances override remote instances.
for cpv in metadata:
from portage import settings
self.mysettings = config(clone=settings)
self._iuse_implicit = self.mysettings._get_implicit_iuse()
- self._categories = tuple(sorted(set(self.mysettings.categories)))
+ self._categories = 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
try:
f = open(self._aux_cache_filename, mode='rb', **open_kwargs)
mypickle = pickle.Unpickler(f)
+ try:
+ mypickle.find_global = None
+ except AttributeError:
+ # TODO: If py3k, override Unpickler.find_class().
+ pass
aux_cache = mypickle.load()
f.close()
del f
@return: The use reduced depend array
"""
# Quick validity checks
- for x in range(len(deparray)):
- if deparray[x] in ["||","&&"]:
+ for x, y in enumerate(deparray):
+ if y == '||':
if len(deparray) - 1 == x or not isinstance(deparray[x+1], list):
raise portage.exception.InvalidDependString(deparray[x]+" missing atom list in \""+paren_enclose(deparray)+"\"")
if deparray and deparray[-1] and deparray[-1][-1] == "?":
if head[-1:] == "?": # Use reduce next group on fail.
# Pull any other use conditions and the following atom or list into a separate array
newdeparray = [head]
- while isinstance(newdeparray[-1], str) and newdeparray[-1][-1] == "?":
+ while isinstance(newdeparray[-1], basestring) and \
+ newdeparray[-1][-1:] == "?":
if mydeparray:
newdeparray.append(mydeparray.pop(0))
else:
out = sys.stdout
try:
metadatafile = open(metadatafilename, 'rb')
- metadata = pickle.load(metadatafile)
+ mypickle = pickle.Unpickler(metadatafile)
+ try:
+ mypickle.find_global = None
+ except AttributeError:
+ # TODO: If py3k, override Unpickler.find_class().
+ pass
+ metadata = mypickle.load()
out.write("Loaded metadata pickle.\n")
out.flush()
metadatafile.close()
--- /dev/null
+# Copyright 2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from portage.tests import TestCase
+from portage.exception import InvalidDependString
+from portage.dep import paren_reduce, use_reduce
+import portage.dep
+portage.dep._dep_check_strict = True
+
+class UseReduce(TestCase):
+
+ def testUseReduce(self):
+
+ tests = (
+ ('|| ( x y )', True ),
+ ('|| x', False ),
+ ('foo? ( x y )', True ),
+ ('foo? ( bar? x y )', False ),
+ ('foo? x', False ),
+ )
+
+ for dep_str, valid in tests:
+ try:
+ use_reduce(paren_reduce(dep_str), matchall=True)
+ except InvalidDependString:
+ self.assertEqual(valid, False)
+ else:
+ self.assertEqual(valid, True)