From 8e9d8306017174a5422c657ebf651c796d5c3d8c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 31 Jul 2006 18:10:19 +0000 Subject: Fix depclean so that it cleans unneeded slots (unless they are exempted by the system or world sets). See bug #140591. This patch is from trunk r3913:3915. svn path=/main/branches/2.1/; revision=4066 --- bin/emerge | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'bin/emerge') diff --git a/bin/emerge b/bin/emerge index eafc07810..1b5de9765 100755 --- a/bin/emerge +++ b/bin/emerge @@ -22,6 +22,9 @@ import portage_locks import portage_exception from portage_const import PROFILE_PATH +if not hasattr(__builtins__, "set"): + from sets import Set as set + portage.global_updates( portage.settings, portage.db, portage.mtimedb["updates"]) @@ -3275,9 +3278,10 @@ elif "depclean"==myaction: print red("*** WARNING ***") print red("*** WARNING ***")+" "+bold("Make sure you have a backup.") + vartree = portage.db[portage.settings["ROOT"]]["vartree"] syslist=getlist("system") worldlist=getlist("world") - myvarlist=portage.vardbapi(portage.root).cp_all() + myvarlist = vartree.dbapi.cpv_all() if not syslist: print "\n!!! You have no system list.", @@ -3317,6 +3321,7 @@ elif "depclean"==myaction: sys.exit(1) reallist=[] + explicitly_required = set() for x in alldeps: myparts=portage.catpkgsplit(string.split(x)[2]) if not myparts: @@ -3332,31 +3337,23 @@ elif "depclean"==myaction: catpack=myparts[0]+"/"+myparts[1] if catpack not in reallist: reallist.append(catpack) + explicitly_required.add(x.split()[2]) + + + sys_world_unversioned = set() + from itertools import chain + for x in chain(syslist, worldlist): + sys_world_unversioned.add(portage.dep_getkey(x)) cleanlist=[] for x in myvarlist: - if x not in reallist: - if x not in cleanlist: + if x not in explicitly_required: + # We have to exempt all slots from the system and world sets since + # there's currently no way of knowing which slots the user may want + # to keep. + if portage.dep_getkey(x) not in sys_world_unversioned: cleanlist.append(x) - for x in syslist+worldlist: - myparts = portage.catpkgsplit(x) - if myparts: - if myparts[0][0] in ('<','>','='): - myparts[0] = myparts[0][1:] - if myparts[0][0] in ('<','>','='): - myparts[0] = myparts[0][1:] - catpack=myparts[0]+"/"+myparts[1] - else: - catpack=x - if catpack in cleanlist: - cleanlist.remove(catpack) - - #print "\n\n\nCleaning: " - #for x in cleanlist: - # print x - #print - if len(cleanlist): unmerge("unmerge", cleanlist) -- cgit v1.2.3-1-g7c22