From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C8154138CA3 for ; Wed, 4 Mar 2015 21:37:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 35B5BE089E; Wed, 4 Mar 2015 21:37:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ED3A0E08BD for ; Wed, 4 Mar 2015 21:37:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ADDE73406FE for ; Wed, 4 Mar 2015 21:37:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0AD5F130C3 for ; Wed, 4 Mar 2015 21:37:52 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1425504727.34055adae6bd90fc64f18421e2cec5f8da6f7c33.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/resolver/, pym/_emerge/, pym/portage/, pym/portage/dbapi/, ... X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/Package.py pym/_emerge/resolver/output.py pym/portage/cache/index/pkg_desc_index.py pym/portage/dbapi/__init__.py pym/portage/dbapi/vartree.py pym/portage/versions.py X-VCS-Directories: pym/_emerge/resolver/ pym/_emerge/ pym/portage/ pym/portage/cache/index/ pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 34055adae6bd90fc64f18421e2cec5f8da6f7c33 X-VCS-Branch: master Date: Wed, 4 Mar 2015 21:37:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 4b3e984b-5b86-4cfc-9388-590b56478b4f X-Archives-Hash: 599b79b2c0db69a552a1da3d2a393812 commit: 34055adae6bd90fc64f18421e2cec5f8da6f7c33 Author: Zac Medico gentoo org> AuthorDate: Tue Feb 17 22:56:47 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Mar 4 21:32:07 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=34055ada binpkg-multi-instance 1 of 7 Extend the _pkg_str class with build_id, build_time, file_size, and mtime attributes. These will be used to distinguish binary package instances that have the same cpv. Package sorting accounts for build_time, which will be used to prefer newer builds over older builds when their versions are identical. pym/_emerge/Package.py | 51 +++++++++++++++++++++---------- pym/_emerge/resolver/output.py | 21 ++++++++++--- pym/portage/cache/index/pkg_desc_index.py | 1 + pym/portage/dbapi/__init__.py | 10 ++++-- pym/portage/dbapi/vartree.py | 8 +++-- pym/portage/versions.py | 28 +++++++++++++++-- 6 files changed, 93 insertions(+), 26 deletions(-) diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index e8a13cb..975335d 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -41,12 +41,12 @@ class Package(Task): "_validated_atoms", "_visible") metadata_keys = [ - "BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "EAPI", - "HDEPEND", "INHERITED", "IUSE", "KEYWORDS", - "LICENSE", "PDEPEND", "PROVIDE", "RDEPEND", - "repository", "PROPERTIES", "RESTRICT", "SLOT", "USE", - "_mtime_", "DEFINED_PHASES", "REQUIRED_USE", "PROVIDES", - "REQUIRES"] + "BUILD_ID", "BUILD_TIME", "CHOST", "COUNTER", "DEFINED_PHASES", + "DEPEND", "EAPI", "HDEPEND", "INHERITED", "IUSE", "KEYWORDS", + "LICENSE", "MD5", "PDEPEND", "PROVIDE", "PROVIDES", + "RDEPEND", "repository", "REQUIRED_USE", + "PROPERTIES", "REQUIRES", "RESTRICT", "SIZE", + "SLOT", "USE", "_mtime_"] _dep_keys = ('DEPEND', 'HDEPEND', 'PDEPEND', 'RDEPEND') _buildtime_keys = ('DEPEND', 'HDEPEND') @@ -114,13 +114,14 @@ class Package(Task): return self._metadata["EAPI"] @property + def build_id(self): + return self.cpv.build_id + + @property def build_time(self): if not self.built: raise AttributeError('build_time') - try: - return long(self._metadata['BUILD_TIME']) - except (KeyError, ValueError): - return 0 + return self.cpv.build_time @property def defined_phases(self): @@ -509,9 +510,15 @@ class Package(Task): else: cpv_color = "PKG_NOMERGE" + build_id_str = "" + if isinstance(self.cpv.build_id, long) and self.cpv.build_id > 0: + build_id_str = "-%s" % self.cpv.build_id + s = "(%s, %s" \ - % (portage.output.colorize(cpv_color, self.cpv + _slot_separator + \ - self.slot + "/" + self.sub_slot + _repo_separator + self.repo) , self.type_name) + % (portage.output.colorize(cpv_color, self.cpv + + build_id_str + _slot_separator + self.slot + "/" + + self.sub_slot + _repo_separator + self.repo), + self.type_name) if self.type_name == "installed": if self.root_config.settings['ROOT'] != "/": @@ -755,29 +762,41 @@ class Package(Task): def __lt__(self, other): if other.cp != self.cp: return self.cp < other.cp - if portage.vercmp(self.version, other.version) < 0: + result = portage.vercmp(self.version, other.version) + if result < 0: return True + if result == 0 and self.built and other.built: + return self.build_time < other.build_time return False def __le__(self, other): if other.cp != self.cp: return self.cp <= other.cp - if portage.vercmp(self.version, other.version) <= 0: + result = portage.vercmp(self.version, other.version) + if result <= 0: return True + if result == 0 and self.built and other.built: + return self.build_time <= other.build_time return False def __gt__(self, other): if other.cp != self.cp: return self.cp > other.cp - if portage.vercmp(self.version, other.version) > 0: + result = portage.vercmp(self.version, other.version) + if result > 0: return True + if result == 0 and self.built and other.built: + return self.build_time > other.build_time return False def __ge__(self, other): if other.cp != self.cp: return self.cp >= other.cp - if portage.vercmp(self.version, other.version) >= 0: + result = portage.vercmp(self.version, other.version) + if result >= 0: return True + if result == 0 and self.built and other.built: + return self.build_time >= other.build_time return False def with_use(self, use): diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index 7df0302..400617d 100644 --- a/pym/_emerge/resolver/output.py +++ b/pym/_emerge/resolver/output.py @@ -424,6 +424,18 @@ class Display(object): pkg_str += _repo_separator + pkg.repo return pkg_str + def _append_build_id(self, pkg_str, pkg, pkg_info): + """Potentially appends repository to package string. + + @param pkg_str: string + @param pkg: _emerge.Package.Package instance + @param pkg_info: dictionary + @rtype string + """ + if pkg.type_name == "binary" and pkg.cpv.build_id is not None: + pkg_str += "-%s" % pkg.cpv.build_id + return pkg_str + def _set_non_root_columns(self, pkg, pkg_info): """sets the indent level and formats the output @@ -431,7 +443,7 @@ class Display(object): @param pkg_info: dictionary @rtype string """ - ver_str = pkg_info.ver + ver_str = self._append_build_id(pkg_info.ver, pkg, pkg_info) if self.conf.verbosity == 3: ver_str = self._append_slot(ver_str, pkg, pkg_info) ver_str = self._append_repository(ver_str, pkg, pkg_info) @@ -470,7 +482,7 @@ class Display(object): @rtype string Modifies self.verboseadd """ - ver_str = pkg_info.ver + ver_str = self._append_build_id(pkg_info.ver, pkg, pkg_info) if self.conf.verbosity == 3: ver_str = self._append_slot(ver_str, pkg, pkg_info) ver_str = self._append_repository(ver_str, pkg, pkg_info) @@ -507,7 +519,7 @@ class Display(object): @param pkg_info: dictionary @rtype the updated addl """ - pkg_str = pkg.cpv + pkg_str = self._append_build_id(pkg.cpv, pkg, pkg_info) if self.conf.verbosity == 3: pkg_str = self._append_slot(pkg_str, pkg, pkg_info) pkg_str = self._append_repository(pkg_str, pkg, pkg_info) @@ -868,7 +880,8 @@ class Display(object): if self.conf.columns: myprint = self._set_non_root_columns(pkg, pkg_info) else: - pkg_str = pkg.cpv + pkg_str = self._append_build_id( + pkg.cpv, pkg, pkg_info) if self.conf.verbosity == 3: pkg_str = self._append_slot(pkg_str, pkg, pkg_info) pkg_str = self._append_repository(pkg_str, pkg, pkg_info) diff --git a/pym/portage/cache/index/pkg_desc_index.py b/pym/portage/cache/index/pkg_desc_index.py index a2e45da..dbcbb83 100644 --- a/pym/portage/cache/index/pkg_desc_index.py +++ b/pym/portage/cache/index/pkg_desc_index.py @@ -26,6 +26,7 @@ class pkg_node(_unicode): self.__dict__['cp'] = cp self.__dict__['repo'] = repo self.__dict__['version'] = version + self.__dict__['build_time'] = None def __new__(cls, cp, version, repo=None): return _unicode.__new__(cls, cp + "-" + version) diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index 34dfaa7..044faec 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -31,7 +31,8 @@ class dbapi(object): _use_mutable = False _known_keys = frozenset(x for x in auxdbkeys if not x.startswith("UNUSED_0")) - _pkg_str_aux_keys = ("EAPI", "KEYWORDS", "SLOT", "repository") + _pkg_str_aux_keys = ("BUILD_TIME", "EAPI", "BUILD_ID", + "KEYWORDS", "SLOT", "repository") def __init__(self): pass @@ -57,7 +58,12 @@ class dbapi(object): @staticmethod def _cmp_cpv(cpv1, cpv2): - return vercmp(cpv1.version, cpv2.version) + result = vercmp(cpv1.version, cpv2.version) + if (result == 0 and cpv1.build_time is not None and + cpv2.build_time is not None): + result = ((cpv1.build_time > cpv2.build_time) - + (cpv1.build_time < cpv2.build_time)) + return result @staticmethod def _cpv_sort_ascending(cpv_list): diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index cf31c8e..277c2f1 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -173,7 +173,8 @@ class vardbapi(dbapi): self.vartree = vartree self._aux_cache_keys = set( ["BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "DESCRIPTION", - "EAPI", "HDEPEND", "HOMEPAGE", "IUSE", "KEYWORDS", + "EAPI", "HDEPEND", "HOMEPAGE", + "BUILD_ID", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository", "RESTRICT" , "SLOT", "USE", "DEFINED_PHASES", "PROVIDES", "REQUIRES" @@ -425,7 +426,10 @@ class vardbapi(dbapi): continue if len(mysplit) > 1: if ps[0] == mysplit[1]: - returnme.append(_pkg_str(mysplit[0]+"/"+x)) + cpv = "%s/%s" % (mysplit[0], x) + metadata = dict(zip(self._aux_cache_keys, + self.aux_get(cpv, self._aux_cache_keys))) + returnme.append(_pkg_str(cpv, metadata=metadata)) self._cpv_sort_ascending(returnme) if use_cache: self.cpcache[mycp] = [mystat, returnme[:]] diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 2c9fe5b..1ca9a36 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -18,6 +18,7 @@ if sys.hexversion < 0x3000000: _unicode = unicode else: _unicode = str + long = int import portage portage.proxy.lazyimport.lazyimport(globals(), @@ -361,11 +362,13 @@ class _pkg_str(_unicode): """ def __new__(cls, cpv, metadata=None, settings=None, eapi=None, - repo=None, slot=None): + repo=None, slot=None, build_time=None, build_id=None, + file_size=None, mtime=None): return _unicode.__new__(cls, cpv) def __init__(self, cpv, metadata=None, settings=None, eapi=None, - repo=None, slot=None): + repo=None, slot=None, build_time=None, build_id=None, + file_size=None, mtime=None): if not isinstance(cpv, _unicode): # Avoid TypeError from _unicode.__init__ with PyPy. cpv = _unicode_decode(cpv) @@ -375,10 +378,19 @@ class _pkg_str(_unicode): slot = metadata.get('SLOT', slot) repo = metadata.get('repository', repo) eapi = metadata.get('EAPI', eapi) + build_time = metadata.get('BUILD_TIME', build_time) + file_size = metadata.get('SIZE', file_size) + build_id = metadata.get('BUILD_ID', build_id) + mtime = metadata.get('_mtime_', mtime) if settings is not None: self.__dict__['_settings'] = settings if eapi is not None: self.__dict__['eapi'] = eapi + + self.__dict__['build_time'] = self._long(build_time, 0) + self.__dict__['file_size'] = self._long(file_size, None) + self.__dict__['build_id'] = self._long(build_id, None) + self.__dict__['mtime'] = self._long(mtime, None) self.__dict__['cpv_split'] = catpkgsplit(cpv, eapi=eapi) if self.cpv_split is None: raise InvalidData(cpv) @@ -419,6 +431,18 @@ class _pkg_str(_unicode): raise AttributeError("_pkg_str instances are immutable", self.__class__, name, value) + @staticmethod + def _long(var, default): + if var is not None: + try: + var = long(var) + except ValueError: + if var: + var = -1 + else: + var = default + return var + @property def stable(self): try: