--- emerge.orig 2005-02-07 18:56:00.000000000 -0700 +++ emerge.new 2005-02-07 23:38:40.521975872 -0700 @@ -611,21 +611,23 @@ if "--update" in myopts: add.extend(["selective","empty"]) if "--emptytree" in myopts: - add.extend(["empty"]) - sub.extend(["selective"]) + add.append("empty") + sub.append("selective") if "--nodeps" in myopts: - sub.extend(["recurse"]) + sub.append("recurse") if "--noreplace" in myopts: - add.extend(["selective"]) + add.append("selective") if "--deep" in myopts: - add.extend(["deep"]) + add.append("deep") if "--selective" in myopts: - add.extend(["selective"]) + add.append("selective") if myaction in ["world","system"]: - add.extend(["selective"]) + add.append("selective") + if myaction == "system": + add.append("rebuild") elif myaction in ["depclean"]: - add.extend(["empty"]) - sub.extend(["selective"]) + add.append("empty") + sub.append("selective") for x in add: if (x not in myparams) and (x not in sub): myparams.append(x) @@ -903,16 +905,38 @@ merging=1 if addme: - # this is where we add the node to the list of packages to merge + # this is where we add the node to the list of packages to merge + if "rebuild" in myparams: + + # in rebuild mode, we will ignore that the package exists if it has a non-empty REBUILD file in its + # /var/db/pkg/ directory. This way, a non-empty REBUILD file will cause the package to be rebuilt. + + dorebuild=vardbapi.aux_get(mykey, ["REBUILD"]) + if dorebuild == []: + #package really not on system (aux_get returns [] if its own cpv_exists() call fails + exists = 0 + elif dorebuild[0] == "": + #REBUILD flag is not there, so we view it + exists = 1 + else: + #REBUILD flag is there, so we pretend package isn't installed + exists = 0 + else: + #perform this call once to improve performance + exists = vardbapi.cpv_exists(mykey) + + + # this is where we add the node to the list of packages to merge if not myparent: + # command-line specified or part of a world list... - if ("self" not in myparams) or (("selective" in myparams) and vardbapi.cpv_exists(mykey)): - # the package is on the system, so don't merge it. + if ("self" not in myparams) or (("selective" in myparams) and exists): merging=0 - elif ("selective" in myparams) and vardbapi.cpv_exists(mykey): + + elif ("selective" in myparams) and exists: merging=0 - if (merging==0 and "--newuse" in myopts and vardbapi.cpv_exists(mykey)): + if (merging==0 and "--newuse" in myopts and exists): iuses=string.split(portage.portdb.aux_get(mykey, ["IUSE"])[0]) old_use=string.split(vardbapi.aux_get(mykey, ["USE"])[0]) now_use=string.split(self.pkgsettings["USE"])