From: Fabian Groffen Date: Sun, 19 Apr 2009 07:12:23 +0000 (-0000) Subject: Merged from trunk -r13350:13355 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=8b06e23be82dcc4038bce6de441bcc55da780a07;p=portage.git Merged from trunk -r13350:13355 | 13351 | Fix typo from previous commit. | | zmedico | | | 13352 | Add support for repos.conf 'aliases' attribute which allows | | zmedico | alias substitution in metadata/layout.conf repository | | | references. | | 13353 | Bug #266493 - Never return a long from vercmp() since that | | zmedico | can trigger an OverflowError if it's returned by a __cmp__ | | | implementation. Thanks to Douglas Anderson | | | for the initial patch. I've modified it to use the (a > b) - | | | (a < b) construct as suggested in the py3k docs, since cmp() | | | is no longer supported in py3k. | | 13354 | Simplify pkgcmp(). Thanks to Douglas Anderson | | zmedico | for this patch from bug #266493. | | 13355 | Fix lockfile() docstring to correctly document the | | zmedico | wantnewlockfile behavior. Thanks to Arfrever for reporting. | svn path=/main/branches/prefix/; revision=13368 --- diff --git a/man/portage.5 b/man/portage.5 index 35cfdd777..0ac8be92f 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -554,23 +554,26 @@ configuration settings which are specified here do not apply to tools such as \fBrepoman\fR(1) and \fBegencache\fR(1) since their operations are inherently \fBnot\fR \fIsite\-specific\fR. \fBWARNING:\fR Use of \fBrepos.conf\fR is generally not recommended since resulting changes in -eclass inheritance (especially due ot \fBeclass\-overrides\fR) may trigger +eclass inheritance (especially due to \fBeclass\-overrides\fR) may trigger performance issues under some circumstances (see \fBbug #124041\fR). .I Example: .nf +[DEFAULT] # make all repositories inherit eclasses from the java\-overlay and # java\-experimental repositories, with eclasses from java\-experimental # taking precedence over those from java\-overlay -[DEFAULT] eclass\-overrides = java\-overlay java\-experimental -# disable all eclass overrides for ebuilds from the gentoo repository [gentoo] +# disable all eclass overrides for ebuilds from the gentoo repository eclass\-overrides = +# when processing metadata/layout.conf from other repositories, substitute +# 'gentoo' in place of references to repositories named 'foo' and 'bar' +aliases = foo bar -# override the metadata/layout.conf masters setting from the kde-testing repo [kde-testing] +# override the metadata/layout.conf masters setting from the kde-testing repo masters = gentoo kde .fi .RE diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 1576cefa9..1a2f2879a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1002,10 +1002,15 @@ def _lazy_iuse_regex(iuse_implicit): return regex class _local_repo_config(object): - __slots__ = ('eclass_overrides', 'masters', 'name',) + __slots__ = ('aliases', 'eclass_overrides', 'masters', 'name',) def __init__(self, name, repo_opts): self.name = name + aliases = repo_opts.get('aliases') + if aliases is not None: + aliases = tuple(aliases.split()) + self.aliases = aliases + eclass_overrides = repo_opts.get('eclass-overrides') if eclass_overrides is not None: eclass_overrides = tuple(eclass_overrides.split()) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 246a0d6f1..c07cf4ff2 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -200,8 +200,23 @@ class portdbapi(dbapi): eclass_dbs = {porttree_root : self.eclassdb} local_repo_configs = self.mysettings._local_repo_configs default_loc_repo_config = None + repo_aliases = {} if local_repo_configs is not None: default_loc_repo_config = local_repo_configs.get('DEFAULT') + for repo_name, loc_repo_conf in local_repo_configs.iteritems(): + if loc_repo_conf.aliases is not None: + for alias in loc_repo_conf.aliases: + overridden_alias = repo_aliases.get(alias) + if overridden_alias is not None: + writemsg_level(("!!! Alias '%s' " + \ + "created for '%s' overrides " + \ + "'%s' alias in " + \ + "'%s'\n") % (alias, repo_name, + overridden_alias, + self.mysettings._local_repo_conf_path), + level=logging.WARNING, noiselevel=-1) + repo_aliases[alias] = repo_name + for path in self.porttrees: if path in self._repo_info: continue @@ -228,6 +243,7 @@ class portdbapi(dbapi): masters = layout_data.get('masters', '').split() for master_name in masters: + master_name = repo_aliases.get(master_name, master_name) master_path = self.treemap.get(master_name) if master_path is None: writemsg_level(("Unavailable repository '%s' " + \ diff --git a/pym/portage/locks.py b/pym/portage/locks.py index b3138af46..8c5148c02 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -29,8 +29,10 @@ def unlockdir(mylock): def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, waiting_msg=None, flags=0): - """Creates all dirs upto, the given dir. Creates a lockfile - for the given directory as the file: directoryname+'.portage_lockfile'.""" + """ + If wantnewlockfile is True then this creates a lockfile in the parent + directory as the file: '.' + basename + '.portage_lockfile'. + """ import fcntl if not mypath: diff --git a/pym/portage/versions.py b/pym/portage/versions.py index c27e13076..7af4de27e 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -125,9 +125,12 @@ def vercmp(ver1, ver2, silent=1): vercmp_cache[mykey] = 1 return 1 elif list1[i] != list2[i]: - vercmp_cache[mykey] = list1[i] - list2[i] - return list1[i] - list2[i] - + a = list1[i] + b = list2[i] + rval = (a > b) - (a < b) + vercmp_cache[mykey] = rval + return rval + # main version is equal, so now compare the _suffix part list1 = match1.group(6).split("_")[1:] list2 = match2.group(6).split("_")[1:] @@ -143,7 +146,11 @@ def vercmp(ver1, ver2, silent=1): else: s2 = suffix_regexp.match(list2[i]).groups() if s1[0] != s2[0]: - return suffix_value[s1[0]] - suffix_value[s2[0]] + a = suffix_value[s1[0]] + b = suffix_value[s2[0]] + rval = (a > b) - (a < b) + vercmp_cache[mykey] = rval + return rval if s1[1] != s2[1]: # it's possible that the s(1|2)[1] == '' # in such a case, fudge it. @@ -155,16 +162,18 @@ def vercmp(ver1, ver2, silent=1): r2 = int(s2[1]) except ValueError: r2 = 0 - if r1 - r2: - return r1 - r2 - - # the suffix part is equal to, so finally check the revision + rval = (r1 > r2) - (r1 < r2) + if rval: + vercmp_cache[mykey] = rval + return rval + + # The suffix part is equal too, so finally check the revision # PREFIX hack: a revision starting with 0 is an 'inter-revision', # which means that it is possible to create revisions on revisions. # An example is -r01.1 which is the first revision of -r1. Note # that a period (.) is used to separate the real revision and the # secondary revision number. This trick is in use to allow revision - # bumps in ebuilds synced from the main tree for prefix changes, + # bumps in ebuilds synced from the main tree for Prefix changes, # while still staying in the main tree versioning scheme. if match1.group(10): if match1.group(10)[0] == '0' and '.' in match1.group(10): @@ -189,8 +198,9 @@ def vercmp(ver1, ver2, silent=1): if r1 == r2 and (r3 != 0 or r4 != 0): r1 = r3 r2 = r4 - vercmp_cache[mykey] = r1 - r2 - return r1 - r2 + rval = (r1 > r2) - (r1 < r2) + vercmp_cache[mykey] = rval + return rval def pkgcmp(pkg1, pkg2): """ @@ -216,15 +226,7 @@ def pkgcmp(pkg1, pkg2): """ if pkg1[0] != pkg2[0]: return None - mycmp = vercmp("-".join(pkg1[1:]), "-".join(pkg2[1:])) - if mycmp is None: - return mycmp - if mycmp > 0: - return 1 - if mycmp < 0: - return -1 - return 0 - + return vercmp("-".join(pkg1[1:]), "-".join(pkg2[1:])) pkgcache={}