From: Fabian Groffen Date: Mon, 22 Feb 2010 13:01:13 +0000 (-0000) Subject: Merged from trunk -r15407:15417 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7adfe57950409302d35dd42e61f0ac2b0195f47d;p=portage.git Merged from trunk -r15407:15417 | 15409 | Add missing newline to the "CONFIG_PROTECT is empty" warning | | zmedico | message. | | 15410 | Move portage.cpv_getkey() to the portage.versions module. | | zmedico | | | 15411 | Add a note about --rebuilt-binaries. | | zmedico | | | 15412 | Handle CacheCorruption from self.db_ro in _setitem, | | zmedico | triggered by INHERITED containing non-existent eclass inside | | | metadata.database._parse_data. Thanks to Vlastimil Babka | | | for reporting. | | 15413 | Move portage.flatten to portage.dep.flatten. | | zmedico | | | 15414 | Show a deprecation warning when digestParseFile() is called. | | zmedico | | | 15415 | Show a deprecation warning when pkgmerge() is called. | | zmedico | | | 15416 | Show a deprecation warning when getvirtuals() is called. | | zmedico | | | 15417 | Move the portage.FetchlistDict class to the | | zmedico | portage.dbapi.porttree module. | svn path=/main/branches/prefix/; revision=15432 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b4908beb5..adff429db 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -21,6 +21,10 @@ portage-2.2 * "world" now includes separate "selected" and "system" sets, where the "selected" set includes packages listed in /var/lib/portage/world and nested sets that may be listed /var/lib/portage/world_sets. +* The new --rebuilt-binaries option will replace installed packages with binary + packages that have been rebuilt. Rebuilds are detected by comparison of + BUILD_TIME package metadata. This option is enabled automatically when using + binary packages (--usepkg or --getbinpkg) together with --update and --deep. portage-2.1.7 ================================== diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 91823d910..4b146cc96 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1125,6 +1125,7 @@ def config_protect_check(trees): msg = "!!! CONFIG_PROTECT is empty" if root != "/": msg += " for '%s'" % root + msg += "\n" writemsg_level(msg, level=logging.WARN, noiselevel=-1) def profile_check(trees, myaction): diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index c2c8e142b..983416559 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -85,7 +85,7 @@ try: 'uid,userland,userpriv_groups,wheelgid', 'portage.dep', 'portage.dep:best_match_to_list,dep_getcpv,dep_getkey,' + \ - 'get_operator,isjustname,isspecific,isvalidatom,' + \ + 'flatten,get_operator,isjustname,isspecific,isvalidatom,' + \ 'match_from_list,match_to_list', 'portage.eclass_cache', 'portage.env.loaders', @@ -110,7 +110,8 @@ try: 'stack_lists,unique_array,varexpand,writedict,writemsg,' + \ 'writemsg_stdout,write_atomic', 'portage.versions', - 'portage.versions:best,catpkgsplit,catsplit,endversion_keys,' + \ + 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,' + \ + 'cpv_getkey@getCPFromCPV,endversion_keys,' + \ 'suffix_value@endversion,pkgcmp,pkgsplit,vercmp,ververify', 'portage.xpak', ) @@ -673,17 +674,6 @@ def listdir(mypath, recursive=False, filesonly=False, ignorecvs=False, ignorelis return rlist -def flatten(mytokens): - """this function now turns a [1,[2,3]] list into - a [1,2,3] list and returns it.""" - newlist=[] - for x in mytokens: - if isinstance(x, list): - newlist.extend(flatten(x)) - else: - newlist.append(x) - return newlist - #beautiful directed graph object class digraph(object): @@ -3552,6 +3542,12 @@ class config(object): self.already_in_regenerate = 0 def get_virts_p(self, myroot=None): + + if myroot is not None: + warnings.warn("The 'myroot' parameter for " + \ + "portage.config.get_virts_p() is deprecated", + DeprecationWarning, stacklevel=2) + if self.virts_p: return self.virts_p virts = self.getvirtuals() @@ -3565,6 +3561,12 @@ class config(object): def getvirtuals(self, myroot=None): """myroot is now ignored because, due to caching, it has always been broken for all but the first call.""" + + if myroot is not None: + warnings.warn("The 'myroot' parameter for " + \ + "portage.config.getvirtuals() is deprecated", + DeprecationWarning, stacklevel=2) + myroot = self["ROOT"] if self.virtuals: return self.virtuals @@ -5495,6 +5497,9 @@ def digestParseFile(myfilename, mysettings=None): DEPRECATED: this function is now only a compability wrapper for portage.manifest.Manifest().""" + warnings.warn("portage.digestParseFile() is deprecated", + DeprecationWarning, stacklevel=2) + mysplit = myfilename.split(os.sep) if mysplit[-2] == "files" and mysplit[-1].startswith("digest-"): pkgdir = os.sep + os.sep.join(mysplit[:-2]).strip(os.sep) @@ -8471,27 +8476,6 @@ def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,use_cache=1): return None return deplist -def cpv_getkey(mycpv): - """Calls pkgsplit on a cpv and returns only the cp.""" - mysplit = versions.catpkgsplit(mycpv) - if mysplit is not None: - return mysplit[0] + '/' + mysplit[1] - - warnings.warn("portage.cpv_getkey() called with invalid cpv: '%s'" \ - % (mycpv,), DeprecationWarning, stacklevel=2) - - myslash = mycpv.split("/", 1) - mysplit = versions._pkgsplit(myslash[-1]) - if mysplit is None: - return None - mylen=len(myslash) - if mylen==2: - return myslash[0]+"/"+mysplit[0] - else: - return mysplit[0] - -getCPFromCPV = cpv_getkey - def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): """Given a string (packagename or virtual) expand it into a valid cat/package string. Virtuals use the mydb to determine which provided @@ -8501,8 +8485,8 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): mysplit = versions._pkgsplit(myslash[-1]) if settings is None: settings = globals()["settings"] - virts = settings.getvirtuals("/") - virts_p = settings.get_virts_p("/") + virts = settings.getvirtuals() + virts_p = settings.get_virts_p() if len(myslash)>2: # this is illegal case. mysplit=[] @@ -8803,49 +8787,18 @@ from portage.dbapi import dbapi from portage.dbapi.virtual import fakedbapi from portage.dbapi.bintree import bindbapi, binarytree from portage.dbapi.vartree import vardbapi, vartree, dblink -from portage.dbapi.porttree import close_portdbapi_caches, portdbapi, portagetree - -class FetchlistDict(portage.cache.mappings.Mapping): - """This provide a mapping interface to retrieve fetch lists. It's used - to allow portage.manifest.Manifest to access fetch lists via a standard - mapping interface rather than use the dbapi directly.""" - def __init__(self, pkgdir, settings, mydbapi): - """pkgdir is a directory containing ebuilds and settings is passed into - portdbapi.getfetchlist for __getitem__ calls.""" - self.pkgdir = pkgdir - self.cp = os.sep.join(pkgdir.split(os.sep)[-2:]) - self.settings = settings - self.mytree = os.path.realpath(os.path.dirname(os.path.dirname(pkgdir))) - self.portdb = mydbapi - def __getitem__(self, pkg_key): - """Returns the complete fetch list for a given package.""" - return list(self.portdb.getFetchMap(pkg_key, mytree=self.mytree)) - def __contains__(self, cpv): - return cpv in self.__iter__() - def has_key(self, pkg_key): - """Returns true if the given package exists within pkgdir.""" - return pkg_key in self - - def __iter__(self): - return iter(self.portdb.cp_list(self.cp, mytree=self.mytree)) - - def __len__(self): - """This needs to be implemented in order to avoid - infinite recursion in some cases.""" - return len(self.portdb.cp_list(self.cp, mytree=self.mytree)) - - def keys(self): - """Returns keys for all packages within pkgdir""" - return self.portdb.cp_list(self.cp, mytree=self.mytree) - - if sys.hexversion >= 0x3000000: - keys = __iter__ +from portage.dbapi.porttree import FetchlistDict, \ + close_portdbapi_caches, portagetree, portdbapi def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None): """will merge a .tbz2 file, returning a list of runtime dependencies that must be satisfied, or None if there was a merge error. This code assumes the package exists.""" + + warnings.warn("portage.pkgmerge() is deprecated", + DeprecationWarning, stacklevel=2) + global db if mydbapi is None: mydbapi = db[myroot]["bintree"].dbapi @@ -9025,9 +8978,14 @@ def deprecated_profile_check(settings=None): # gets virtual package settings def getvirtuals(myroot): + """ + Calls portage.settings.getvirtuals(). + @deprecated: Use portage.settings.getvirtuals(). + """ global settings - writemsg("--- DEPRECATED call to getvirtual\n") - return settings.getvirtuals(myroot) + warnings.warn("portage.getvirtuals() is deprecated", + DeprecationWarning, stacklevel=2) + return settings.getvirtuals() def commit_mtimedb(mydict=None, filename=None): if mydict is None: diff --git a/pym/portage/cache/metadata_overlay.py b/pym/portage/cache/metadata_overlay.py index 84c5a9741..7b4f70a9c 100644 --- a/pym/portage/cache/metadata_overlay.py +++ b/pym/portage/cache/metadata_overlay.py @@ -48,7 +48,10 @@ class database(template.database): return value def _setitem(self, name, values): - value_ro = self.db_ro.get(name, None) + try: + value_ro = self.db_ro.get(name) + except CacheCorruption: + value_ro = None if value_ro is not None and \ self._are_values_identical(value_ro, values): # we have matching values in the underlying db_ro diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 7cae96796..93f3b411b 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -4,7 +4,9 @@ from __future__ import print_function -__all__ = ["portdbapi", "close_portdbapi_caches", "portagetree"] +__all__ = [ + "close_portdbapi_caches", "FetchlistDict", "portagetree", "portdbapi" +] import portage portage.proxy.lazyimport.lazyimport(globals(), @@ -1240,3 +1242,44 @@ class portagetree(object): except Exception as e: pass return myslot + +class FetchlistDict(portage.cache.mappings.Mapping): + """ + This provide a mapping interface to retrieve fetch lists. It's used + to allow portage.manifest.Manifest to access fetch lists via a standard + mapping interface rather than use the dbapi directly. + """ + def __init__(self, pkgdir, settings, mydbapi): + """pkgdir is a directory containing ebuilds and settings is passed into + portdbapi.getfetchlist for __getitem__ calls.""" + self.pkgdir = pkgdir + self.cp = os.sep.join(pkgdir.split(os.sep)[-2:]) + self.settings = settings + self.mytree = os.path.realpath(os.path.dirname(os.path.dirname(pkgdir))) + self.portdb = mydbapi + + def __getitem__(self, pkg_key): + """Returns the complete fetch list for a given package.""" + return list(self.portdb.getFetchMap(pkg_key, mytree=self.mytree)) + + def __contains__(self, cpv): + return cpv in self.__iter__() + + def has_key(self, pkg_key): + """Returns true if the given package exists within pkgdir.""" + return pkg_key in self + + def __iter__(self): + return iter(self.portdb.cp_list(self.cp, mytree=self.mytree)) + + def __len__(self): + """This needs to be implemented in order to avoid + infinite recursion in some cases.""" + return len(self.portdb.cp_list(self.cp, mytree=self.mytree)) + + def keys(self): + """Returns keys for all packages within pkgdir""" + return self.portdb.cp_list(self.cp, mytree=self.mytree) + + if sys.hexversion >= 0x3000000: + keys = __iter__ diff --git a/pym/portage/dep.py b/pym/portage/dep.py index e2eeb6d5b..282fe749d 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -3,6 +3,16 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +__all__ = [ + 'Atom', 'best_match_to_list', 'cpvequal', + 'dep_getcpv', 'dep_getkey', 'dep_getslot', + 'dep_getusedeps', 'dep_opconvert', 'flatten', + 'get_operator', 'isjustname', 'isspecific', + 'isvalidatom', 'match_from_list', 'match_to_list', + 'paren_enclose', 'paren_normalize', 'paren_reduce', + 'remove_slot', 'strip_empty', 'use_reduce' +] + # DEPEND SYNTAX: # # 'use?' only affects the immediately following word! @@ -343,6 +353,28 @@ def dep_opconvert(deplist): x += 1 return retlist +def flatten(mylist): + """ + Recursively traverse nested lists and return a single list containing + all non-list elements that are found. + + Example usage: + >>> flatten([1, [2, 3, [4]]]) + [1, 2, 3, 4] + + @param mylist: A list containing nested lists and non-list elements. + @type mylist: List + @rtype: List + @return: A single list containing only non-list elements. + """ + newlist = [] + for x in mylist: + if isinstance(x, list): + newlist.extend(flatten(x)) + else: + newlist.append(x) + return newlist + class _use_dep(object): __slots__ = ("__weakref__", "conditional", diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 99ec90069..c070b8924 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -3,7 +3,14 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +__all__ = [ + 'best', 'catpkgsplit', 'catsplit', + 'cpv_getkey', 'pkgcmp', 'pkgsplit', + 'ververify', 'vercmp' +] + import re +import warnings # \w is [a-zA-Z0-9_] @@ -334,6 +341,26 @@ def pkgsplit(mypkg, silent=1): else: return (cat + '/' + pn, ver, rev) +def cpv_getkey(mycpv): + """Calls catpkgsplit on a cpv and returns only the cp.""" + mysplit = catpkgsplit(mycpv) + if mysplit is not None: + return mysplit[0] + '/' + mysplit[1] + + warnings.warn("portage.versions.cpv_getkey() " + \ + "called with invalid cpv: '%s'" % (mycpv,), + DeprecationWarning, stacklevel=2) + + myslash = mycpv.split("/", 1) + mysplit = _pkgsplit(myslash[-1]) + if mysplit is None: + return None + mylen = len(myslash) + if mylen == 2: + return myslash[0] + "/" + mysplit[0] + else: + return mysplit[0] + def catsplit(mydep): return mydep.split("/", 1)