Implement REPLACING_VERSIONS and REPLACED_BY_VERSION
authorSebastian Luther <SebastianLuther@gmx.de>
Fri, 9 Apr 2010 17:29:22 +0000 (19:29 +0200)
committerZac Medico <zmedico@gentoo.org>
Sat, 10 Apr 2010 21:06:48 +0000 (14:06 -0700)
bin/isolated-functions.sh
pym/_emerge/EbuildProcess.py
pym/portage/dbapi/vartree.py
pym/portage/package/ebuild/config.py
pym/portage/package/ebuild/doebuild.py
pym/portage/versions.py

index 9299f2c71b47536de0d95a26c6ff0c676ed8492b..89e5e4b8bcb3b5c96bb51e12e5767f801ddabe12 100644 (file)
@@ -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
 
index 255f7c5530a2211967ea4809b15f20bc9ebdfc52..bf7af4b9d31fad828a449e9edb7deea9fe231e04 100644 (file)
@@ -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
 
index e6e42b9f9b21fa4ed900f22d67b08ff6ffca5a58..a306fb6d661807ea17105da100084b5e6870dc83 100644 (file)
@@ -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)
 
index 3d02cd0a8ecbf1c89fb3098aa080ecac2bbbbbe5..a3998cc79a52d95bec67536d4866a8e3b3f65d83 100644 (file)
@@ -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):
index 3121a05cf0bbd166c815d75f54c5917919cfd753..9cf16cfea8d48971adcdee3cd4bd8ea97536181e 100644 (file)
@@ -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.
index a4765ef1c92c25ba0b015acf4cfab775c7d2111c..89ab6e180eb215844c9b884863e8c891f4b0ba75 100644 (file)
@@ -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)