From 2339fbb2fc4f54161787afebb768d60afc3511ba Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Fri, 9 Apr 2010 19:29:22 +0200 Subject: Implement REPLACING_VERSIONS and REPLACED_BY_VERSION --- bin/isolated-functions.sh | 1 + pym/_emerge/EbuildProcess.py | 3 ++- pym/portage/dbapi/vartree.py | 6 ++++++ pym/portage/package/ebuild/config.py | 9 +++++++++ pym/portage/package/ebuild/doebuild.py | 15 +++++++++++++++ pym/portage/versions.py | 5 +++++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 9299f2c71..89e5e4b8b 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -566,6 +566,7 @@ save_ebuild_env() { PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \ RC_DEFAULT_INDENT RC_DOT_PATTERN RC_ENDCOL \ RC_INDENTATION READONLY_EBUILD_METADATA READONLY_PORTAGE_VARS \ + REPLACING_VERSIONS REPLACED_BY_VERSION \ ROOT ROOTPATH RPMDIR TEMP TMP TMPDIR USE_EXPAND \ WARN XARGS _RC_GET_KV_CACHE diff --git a/pym/_emerge/EbuildProcess.py b/pym/_emerge/EbuildProcess.py index 255f7c553..bf7af4b9d 100644 --- a/pym/_emerge/EbuildProcess.py +++ b/pym/_emerge/EbuildProcess.py @@ -23,6 +23,7 @@ class EbuildProcess(AbstractEbuildProcess): root_config = self.pkg.root_config tree = self.tree mydbapi = root_config.trees[tree].dbapi + vartree = root_config.trees["vartree"] settings = self.settings ebuild_path = settings["EBUILD"] debug = settings.get("PORTAGE_DEBUG") == "1" @@ -30,7 +31,7 @@ class EbuildProcess(AbstractEbuildProcess): rval = doebuild(ebuild_path, self.phase, root_config.root, settings, debug, - mydbapi=mydbapi, tree=tree, **kwargs) + mydbapi=mydbapi, tree=tree, vartree=vartree, **kwargs) return rval diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index e6e42b9f9..a306fb6d6 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3473,6 +3473,10 @@ class dblink(object): if retval: return retval + self.settings["REPLACING_VERSIONS"] = " ".join( + [portage.versions.cpv_getversion(other.mycpv) for other in others_in_slot] ) + self.settings.backup_changes("REPLACING_VERSIONS") + if slot_matches: # Used by self.isprotected(). max_dblnk = None @@ -3890,6 +3894,8 @@ class dblink(object): emerge_log(_(" === Unmerging... (%s)") % (dblnk.mycpv,)) others_in_slot.remove(dblnk) # dblnk will unmerge itself now dblnk._linkmap_broken = self._linkmap_broken + dblnk.settings["REPLACED_BY_VERSION"] = portage.versions.cpv_getversion(self.mycpv) + dblnk.settings.backup_changes("REPLACED_BY_VERSION") unmerge_rval = dblnk.unmerge(trimworld=0, ldpath_mtimes=prev_mtimes, others_in_slot=others_in_slot) diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 3d02cd0a8..a3998cc79 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -187,6 +187,7 @@ class config(object): "PORTAGE_TMPDIR", "PORTAGE_UPDATE_ENV", "PORTAGE_VERBOSE", "PORTAGE_WORKDIR_MODE", "PORTDIR", "PORTDIR_OVERLAY", "PREROOTPATH", "PROFILE_PATHS", + "REPLACING_VERSIONS", "REPLACED_BY_VERSION", "ROOT", "ROOTPATH", "T", "TMP", "TMPDIR", "USE_EXPAND", "USE_ORDER", "WORKDIR", "XARGS", @@ -2576,6 +2577,14 @@ class config(object): if phase == 'depend': mydict.pop('FILESDIR', None) + if phase not in ("pretend", "setup", "preinst", "postinst") or \ + eapi in ("0", "1", "2", "3"): + mydict.pop("REPLACING_VERSIONS", None) + + if phase not in ("prerm", "postrm") or \ + eapi in ("0", "1", "2", "3"): + mydict.pop("REPLACED_BY_VERSION", None) + return mydict def thirdpartymirrors(self): diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 3121a05cf..9cf16cfea 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -513,6 +513,21 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, tmpdir_orig = None try: + if mydo in ("pretend", "setup"): + if not vartree: + writemsg("Warning: vartree not given to doebuild. " + \ + "Cannot set REPLACING_VERSIONS in pkg_{pretend,setup}\n") + else: + vardb = vartree.dbapi + cpv = mysettings.mycpv + cp = portage.versions.cpv_getkey(cpv) + slot = mysettings.get("SLOT") + cpv_slot = cp + ":" + slot + mysettings["REPLACING_VERSIONS"] = " ".join( + set(portage.versions.cpv_getversion(match) \ + for match in vardb.match(cpv_slot) + vardb.match(cpv))) + mysettings.backup_changes("REPLACING_VERSIONS") + if mydo in ("digest", "manifest", "help"): # Temporarily exempt the depend phase from manifest checks, in case # aux_get calls trigger cache generation. diff --git a/pym/portage/versions.py b/pym/portage/versions.py index a4765ef1c..89ab6e180 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -335,6 +335,11 @@ def cpv_getkey(mycpv): else: return mysplit[0] +def cpv_getversion(mycpv): + """Returns the v (including revision) from an cpv.""" + cp = cpv_getkey(mycpv) + return mycpv[len(cp+"-"):] + def catsplit(mydep): return mydep.split("/", 1) -- cgit v1.2.3-1-g7c22