From b9fd2198a9b4df8d8f77bafaa20fedb23837292f Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 25 May 2007 17:55:00 +0000 Subject: [PATCH] Merged from trunk 6608:6620 +------------------------------------------------------------------------+ | 6609 | Add more relevant package metadata to the Packages index, | | zmedico | including dependencies with USE conditionals collapsed. | |---------+--------------------------------------------------------------| | 6610 | Fix paren_normalize logic. | | zmedico | | |---------+--------------------------------------------------------------| | 6611 | Make PackageIndex.write() alphabetize the metadata keys. | | zmedico | | |---------+--------------------------------------------------------------| | 6612 | Remember to call the superclass constructor. | | zmedico | | |---------+--------------------------------------------------------------| | 6613 | Make PackageIndex.write() omit USE when appropriate. | | zmedico | | |---------+--------------------------------------------------------------| | 6615 | Fix the ignore-previously-merged option so that it compares | | zmedico | the original files, since mrgconf can be identical to | | | conf['current'] even when conf['new'] is different from the | | | archived .dist version (due to diff3 merging). | | | (prefix: use tabs instead of spaces to avoid IndentErrors) | |---------+--------------------------------------------------------------| | 6617 | Don't treat KEYWORDS="-*" like KEYWORDS="*", because it's | | zmedico | never been that way and the * behavior was already annoying | | | enough. | |---------+--------------------------------------------------------------| | 6618 | Skip fetching of metadata.dtd when mymode == "manifest". | | zmedico | | |---------+--------------------------------------------------------------| | 6620 | To ease the namespace transition, automatically translate | | zmedico | cache.* to portage.cache.* if an ImportError occurs. | +------------------------------------------------------------------------+ svn path=/main/branches/prefix/; revision=6622 --- bin/dispatch-conf | 3 ++- bin/repoman | 6 ++++-- pym/portage/__init__.py | 11 +++++++++-- pym/portage/dbapi/bintree.py | 23 ++++++++++++++++++++++ pym/portage/dbapi/porttree.py | 8 ++++++-- pym/portage/dep.py | 36 +++++++++++++++++++++++++++++++++++ pym/portage/getbinpkg.py | 15 ++++++++++----- 7 files changed, 90 insertions(+), 12 deletions(-) diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 5507b5663..972cf117c 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -142,7 +142,8 @@ class dispatch: if newconf == mrgconf and \ self.options.get('ignore-previously-merged') != 'yes' and \ - len(commands.getoutput(DIFF_CONTENTS % (conf['current'], mrgconf))) == 0: + os.path.exists(archive+'.dist') and \ + len(commands.getoutput(DIFF_CONTENTS % (archive+'.dist', conf['new']))) == 0: # The current update is identical to the archived .dist # version that has previously been merged. os.unlink(mrgconf) diff --git a/bin/repoman b/bin/repoman index 42d539d4c..699e74580 100755 --- a/bin/repoman +++ b/bin/repoman @@ -54,7 +54,7 @@ import codecs from portage.manifest import Manifest from portage.exception import ParseError -from portage.process import spawn +from portage.process import find_binary, spawn from portage.output import bold, darkgreen, darkred, green, nocolor, red, turquoise, yellow @@ -736,7 +736,9 @@ for x in qacats: fails[x]=[] xmllint_capable = False metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd') -if getstatusoutput('which xmllint')[0] != 0: +if mymode == "manifest": + pass +elif not find_binary('xmllint'): print red("!!! xmllint not found. Can't check metadata.xml.\n") if "--xmlparse" in myoptions or repolevel==3: print red("!!!")+" sorry, xmllint is needed. failing\n" diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 5eeb0da71..21f80e8bc 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1566,11 +1566,18 @@ class config: def load_best_module(self,property_string): best_mod = best_from_dict(property_string,self.modules,self.module_priority) + mod = None try: mod = load_mod(best_mod) except ImportError: - dump_traceback(red("Error: Failed to import module '%s'") % best_mod, noiselevel=0) - sys.exit(1) + if best_mod.startswith("cache."): + best_mod = "portage." + best_mod + try: + mod = load_mod(best_mod) + except ImportError: + pass + if mod is None: + raise return mod def lock(self): diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index fcceb5e0d..6976d4de5 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -636,6 +636,29 @@ class binarytree(object): d["MTIME"] = str(long(s.st_mtime)) d["SIZE"] = str(s.st_size) d["MD5"] = str(md5) + keys = ["USE", "IUSE", "DESCRIPTION", "LICENSE", "PROVIDE", \ + "RDEPEND", "DEPEND", "PDEPEND"] + from itertools import izip + d.update(izip(keys, self.dbapi.aux_get(cpv, keys))) + use = d["USE"].split() + iuse = set(d["IUSE"].split()) + use = [f for f in use if f in iuse] + del iuse, d["IUSE"] + use.sort() + d["USE"] = " ".join(use) + d["DESC"] = d["DESCRIPTION"] + del d["DESCRIPTION"] + from portage.dep import paren_reduce, use_reduce, \ + paren_normalize, paren_enclose + for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE": + deps = paren_reduce(d[k]) + deps = use_reduce(deps, uselist=use) + deps = paren_normalize(deps) + deps = paren_enclose(deps) + if deps: + d[k] = deps + else: + del d[k] pkgindex.packages[cpv] = d from portage.util import atomic_ofstream f = atomic_ofstream(os.path.join(self.pkgdir, "Packages")) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 77aa39e7a..86d70416f 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -136,6 +136,9 @@ class portdbapi(dbapi): pass def close_caches(self): + if not hasattr(self, "auxdb"): + # unhandled exception thrown from constructor + return for x in self.auxdb.keys(): self.auxdb[x].sync() self.auxdb.clear() @@ -676,8 +679,9 @@ class portdbapi(dbapi): if gp == "*" or (gp == "-*" and len(mygroups) == 1): writemsg("--- WARNING: Package '%s' uses '%s' keyword.\n" % (mycpv, gp), noiselevel=-1) - match=1 - break + if gp == "*": + match = 1 + break elif gp in pgroups: match=1 break diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 1e95fd1da..138f1b984 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -114,6 +114,42 @@ def paren_reduce(mystr,tokenize=1): mylist = mylist + [subsec] return mylist +class paren_normalize(list): + """Take a dependency structure as returned by paren_reduce or use_reduce + and generate an equivalent structure that has no redundant lists.""" + def __init__(self, src): + list.__init__(self) + self._zap_parens(src, self) + + def _zap_parens(self, src, dest, disjunction=False): + if not src: + return dest + i = iter(src) + for x in i: + if isinstance(x, basestring): + if x == '||': + x = self._zap_parens(i.next(), [], disjunction=True) + if len(x) == 1: + dest.append(x[0]) + else: + dest.append("||") + dest.append(x) + elif x.endswith("?"): + dest.append(x) + dest.append(self._zap_parens(i.next(), [])) + else: + dest.append(x) + else: + if disjunction: + x = self._zap_parens(x, []) + if len(x) == 1: + dest.append(x[0]) + else: + dest.append(x) + else: + self._zap_parens(x, dest) + return dest + def paren_enclose(mylist): """ Convert a list to a string with sublists enclosed with parens. diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 3364db8bb..320e95a00 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -616,10 +616,15 @@ class PackageIndex(object): import time self.header["TIMESTAMP"] = str(long(time.time())) self.header["PACKAGES"] = str(len(cpv_all)) - writepkgindex(pkgfile, self.header.iteritems()) + keys = self.header.keys() + keys.sort() + writepkgindex(pkgfile, [(k, self.header[k]) for k in keys]) for cpv in cpv_all: - metadata = self.packages[cpv] - if metadata["SLOT"] == "0": - metadata = metadata.copy() + metadata = self.packages[cpv].copy() + if metadata.get("SLOT") == "0": del metadata["SLOT"] - writepkgindex(pkgfile, metadata.iteritems()) + if metadata.get("USE") == "": + del metadata["USE"] + keys = metadata.keys() + keys.sort() + writepkgindex(pkgfile, [(k, metadata[k]) for k in keys]) -- 2.26.2