summaryrefslogtreecommitdiffstats
path: root/bin/emerge
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-07-31 18:10:19 +0000
committerZac Medico <zmedico@gentoo.org>2006-07-31 18:10:19 +0000
commit8e9d8306017174a5422c657ebf651c796d5c3d8c (patch)
tree4f5aad92fbf9b09130d0d9006aadbb4766250c05 /bin/emerge
parent2663cbfe67b9933e502721f882d8f7717c3811e5 (diff)
downloadportage-8e9d8306017174a5422c657ebf651c796d5c3d8c.tar.gz
portage-8e9d8306017174a5422c657ebf651c796d5c3d8c.tar.bz2
portage-8e9d8306017174a5422c657ebf651c796d5c3d8c.zip
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
Diffstat (limited to 'bin/emerge')
-rwxr-xr-xbin/emerge39
1 files changed, 18 insertions, 21 deletions
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)