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"])
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.",
sys.exit(1)
reallist=[]
+ explicitly_required = set()
for x in alldeps:
myparts=portage.catpkgsplit(string.split(x)[2])
if not myparts:
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)