if pkgsettings.get("AUTOCLEAN", "yes") == "yes":
xsplit=portage.pkgsplit(x[2])
emergelog(xterm_titles, " >>> AUTOCLEAN: " + xsplit[0])
- retval = unmerge_overlapping(x[2], x[1],
- pkgsettings, vartree,
- ldpath_mtimes)
+ retval = unmerge(pkgsettings, self.myopts, vartree,
+ "clean", [xsplit[0]], ldpath_mtimes)
if not retval:
emergelog(xterm_titles,
" --- AUTOCLEAN: Nothing unmerged.")
else:
sys.exit(0)
-def unmerge_overlapping(pkg_key, myroot, mysettings, vartree, ldpath_mtimes):
- """Unmerge any packages that overlap with the given package (overlapping
- packages fill the same SLOT). Unlike emerge's unmerge() function, this
- function does not assume that packages are to be unmerged from the target
- ROOT. This function is only needed in the case where ROOT!=/ and the
- previous version of a build time dependency (that has been upgraded) needs
- to be cleaned from / (instead of the target ROOT). When the incorrect
- assumptions in unmerge() have been fixed, this function can be removed."""
-
- overlapping = []
- ommitted_versions = []
- mydbapi = vartree.dbapi
- myslot = mydbapi.aux_get(pkg_key, ["SLOT"])[0]
- mycp = portage.pkgsplit(pkg_key)[0]
- xterm_titles = "notitles" not in mysettings.features
- for other_pkg in mydbapi.cp_list(mycp):
- if other_pkg == pkg_key:
- continue
- other_slot = mydbapi.aux_get(other_pkg, ["SLOT"])[0]
- if myslot == other_slot:
- overlapping.append(other_pkg)
- else:
- ommitted_versions.append(other_pkg)
- if overlapping:
- def get_version(pkg_key):
- cp, pv, rev = portage.pkgsplit(pkg_key)
- if rev == "r0":
- return pv
- else:
- return "%s-%s" % (pv, rev)
- selected_versions = " ".join(map(get_version, overlapping))
- protected_version = get_version(pkg_key)
- if ommitted_versions:
- ommitted_versions = colorize("GOOD", " ".join(map(get_version, ommitted_versions)))
- else:
- ommitted_versions = "none"
- portage.writemsg_stdout("\n %s\n" % bold(mycp), noiselevel=-1)
- portage.writemsg_stdout("selected: ".rjust(14) + \
- colorize("UNMERGE_WARN", selected_versions) + "\n", noiselevel=-1)
- portage.writemsg_stdout("protected: ".rjust(14) + \
- colorize("GOOD", protected_version) + "\n", noiselevel=-1)
- portage.writemsg_stdout("omitted: ".rjust(14) + \
- ommitted_versions + "\n", noiselevel=-1)
- portage.writemsg_stdout("\n>>>" + colorize("UNMERGE_WARN", "'Selected'") + \
- " packages are slated for removal.\n", noiselevel=0)
- portage.writemsg_stdout(">>>" + colorize("GOOD", "'Protected'") + \
- " and " + colorize("GOOD", "'omitted'") + \
- " packages will not be removed.\n\n",
- noiselevel=0)
- countdown(int(mysettings["CLEAN_DELAY"]), ">>> Unmerging")
- for other_pkg in overlapping:
- portage.writemsg_stdout(">>> Unmerging %s...\n" % other_pkg ,
- noiselevel=-1)
- emergelog(xterm_titles, "=== Unmerging... (%s)" % other_pkg)
- mysplit = other_pkg.split("/")
- retval = portage.unmerge(mysplit[0], mysplit[1], myroot,
- mysettings, mytrimworld=False, vartree=vartree,
- ldpath_mtimes=ldpath_mtimes)
- if retval:
- emergelog(xterm_titles, " !!! unmerge FAILURE: " + other_pkg)
- else:
- emergelog(xterm_titles, " >>> unmerge success: " + other_pkg)
- return 1
- return 0
-
def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
ldpath_mtimes, raise_on_missing=True):
candidate_catpkgs=[]