Lines 3182-3214
Link Here
|
3182 |
# Kill packages that aren't explicitly merged or are required as a |
3182 |
# Kill packages that aren't explicitly merged or are required as a |
3183 |
# dependency of another package. World file is explicit. |
3183 |
# dependency of another package. World file is explicit. |
3184 |
|
3184 |
|
3185 |
warn_prefix = colorize("BAD", "*** WARNING *** ") |
|
|
3186 |
print |
3187 |
print warn_prefix + "--depclean is known to be broken. It is highly recommended" |
3188 |
print warn_prefix + "that "+good("`emerge --update --newuse --deep world`")+" be ran before" |
3189 |
print warn_prefix + "commencing. However, using --depclean may still break link" |
3190 |
print warn_prefix + "level consistency within your system. "+good("`revdep-rebuild`") |
3191 |
print warn_prefix + "from app-portage/gentoolkit can help to detect breakage." |
3192 |
print warn_prefix |
3193 |
print warn_prefix + "Also study the list of packages to be cleaned for any" |
3194 |
print warn_prefix + "obvious mistakes. Packages can be manually added to the" |
3195 |
print warn_prefix + "world list by running "+good("`emerge --noreplace <atom>`")+"." |
3196 |
print warn_prefix |
3197 |
print warn_prefix + "It is normal for packages that are masked or listed in" |
3198 |
print warn_prefix + "package.provided to be removed by depclean. These are the most" |
3199 |
print warn_prefix + "likely reasons that depclean will remove a package even though" |
3200 |
print warn_prefix + "it is in the world or system package set. In order to" |
3201 |
print warn_prefix + "troubleshoot these types of problems, it is often helpful to" |
3202 |
print warn_prefix + "look at the output of "+good("`grep -r <atom> /etc/portage`")+"." |
3203 |
print warn_prefix |
3204 |
print warn_prefix + bold("Make sure you have a backup.") |
3205 |
|
3206 |
xterm_titles = "notitles" not in settings.features |
3185 |
xterm_titles = "notitles" not in settings.features |
3207 |
pordb = trees[settings["ROOT"]]["porttree"].dbapi |
3186 |
portdb = trees[settings["ROOT"]]["porttree"].dbapi |
3208 |
vartree = trees[settings["ROOT"]]["vartree"] |
3187 |
vartree = trees[settings["ROOT"]]["vartree"] |
|
|
3188 |
vardb = vartree.dbapi |
3209 |
syslist = getlist(settings, "system") |
3189 |
syslist = getlist(settings, "system") |
3210 |
worldlist = getlist(settings, "world") |
3190 |
worldlist = getlist(settings, "world") |
3211 |
myvarlist = vartree.dbapi.cpv_all() |
3191 |
fakedb = portage.fakedbapi(settings=settings) |
|
|
3192 |
emptydb = portage.fakedbapi(settings=settings) |
3193 |
myvarlist = vardb.cpv_all() |
3212 |
|
3194 |
|
3213 |
if not syslist: |
3195 |
if not syslist: |
3214 |
print "\n!!! You have no system list.", |
3196 |
print "\n!!! You have no system list.", |
Lines 3218-3293
Link Here
|
3218 |
print "\n!!! You have no installed package database (%s)." % portage.VDB_PATH, |
3200 |
print "\n!!! You have no installed package database (%s)." % portage.VDB_PATH, |
3219 |
|
3201 |
|
3220 |
if not (syslist and worldlist and myvarlist): |
3202 |
if not (syslist and worldlist and myvarlist): |
3221 |
print "\n!!! Proceeding will break your installation.\n" |
3203 |
print "\n!!! Proceeding "+(syslist and myvarlist and "may" or "will") |
3222 |
countdown(int(settings["EMERGE_WARNING_DELAY"]), ">>> Depclean") |
3204 |
print " break your installation.\n" |
|
|
3205 |
if "--pretend" not in myopts: |
3206 |
countdown(int(settings["EMERGE_WARNING_DELAY"]), ">>> Depclean") |
3223 |
|
3207 |
|
3224 |
if not "--pretend" in myopts: #just check pretend, since --ask implies pretend |
3208 |
if not "--pretend" in myopts: #just check pretend, since --ask implies pretend |
3225 |
emergelog(xterm_titles, " >>> depclean") |
3209 |
emergelog(xterm_titles, " >>> depclean") |
3226 |
|
3210 |
|
3227 |
myparams = create_depgraph_params(myopts, "depclean") |
3211 |
remaining_atoms = worldlist + syslist |
3228 |
mydepgraph = depgraph(settings, trees, |
3212 |
unresolveable = [] |
3229 |
myopts, myparams, spinner) |
3213 |
|
3230 |
|
3214 |
if "--quiet" not in myopts: |
3231 |
if not ("--quiet" in myopts): |
|
|
3232 |
print "\nCalculating dependencies ", |
3215 |
print "\nCalculating dependencies ", |
3233 |
if not mydepgraph.xcreate("world"): |
|
|
3234 |
print "\n!!! Failed to create deptree." |
3235 |
sys.exit(1) |
3236 |
if not ("--quiet" in myopts): |
3237 |
print "\b\b... done!" |
3238 |
|
3216 |
|
3239 |
if ("--usepkgonly" in myopts) and mydepgraph.missingbins: |
3217 |
while remaining_atoms: |
3240 |
sys.stderr.write(red("The following binaries are not available for merging...\n")) |
3218 |
atom = remaining_atoms.pop() |
3241 |
for x in mydepgraph.missingbins: |
3219 |
if atom in unresolveable: |
3242 |
sys.stderr.write(" "+str(x)+"\n") |
|
|
3243 |
sys.stderr.write("\nThese are required by '--usepkgonly' -- Terminating.\n\n") |
3244 |
sys.exit(1) |
3245 |
|
3246 |
alldeps=mydepgraph.digraph.allnodes() |
3247 |
|
3248 |
if not alldeps: |
3249 |
print "!!! You have no dependencies. Impossible. Bug." |
3250 |
sys.exit(1) |
3251 |
|
3252 |
reallist = set() |
3253 |
explicitly_required = set() |
3254 |
for x in alldeps: |
3255 |
myparts=portage.catpkgsplit(string.split(x)[2]) |
3256 |
if not myparts: |
3257 |
sys.stderr.write( |
3258 |
red("!!! There appears to be a problem with the following package:\n")+ |
3259 |
red("!!! "+str(string.split(x)[2])+"\n\n")+ |
3260 |
"!!! Please ensure that blocking/conflicting packages are not merged."+ |
3261 |
"!!! 'emerge -p "+str(string.split(x)[2])+"\n\n") |
3262 |
if ("--pretend" not in myopts) and ("--ask" not in myopts): |
3263 |
countdown(int(settings["EMERGE_WARNING_DELAY"]), |
3264 |
"*** Continuing") |
3265 |
continue |
3220 |
continue |
|
|
3221 |
pkgs = vardb.match(atom) |
3222 |
if not pkgs: |
3223 |
if not atom.startswith("!"): |
3224 |
unresolveable.append(atom) |
3225 |
continue |
3226 |
# Could put slot checking here to ensure that there aren't two |
3227 |
# packages with the same slot... |
3228 |
for pkg in pkgs: |
3229 |
if fakedb.cpv_exists(pkg): |
3230 |
continue |
3231 |
spinner.update() |
3232 |
fakedb.cpv_inject(pkg) |
3233 |
mydb = portdb.xmatch("match-visible", "="+pkg) and portdb or vardb |
3234 |
depstr = " ".join(mydb.aux_get(pkg, ["DEPEND", "RDEPEND", "PDEPEND"])) |
3235 |
usedef = vardb.aux_get(pkg, ["USE"])[0].split() |
3236 |
(success, atoms) = portage.dep_check(depstr, emptydb, settings, |
3237 |
myuse=usedef, trees=trees, myroot=settings["ROOT"]) |
3238 |
if not success: |
3239 |
print depstr |
3240 |
print "Something's probably wrong with ^^^" |
3241 |
print "("+str(atoms)+"?)" |
3242 |
print "Bye!" |
3243 |
return |
3244 |
remaining_atoms.extend(atoms) |
3245 |
|
3246 |
if "--quiet" not in myopts: |
3247 |
print "\b\b... done!" |
3266 |
|
3248 |
|
3267 |
catpack=myparts[0]+"/"+myparts[1] |
3249 |
if unresolveable: |
3268 |
reallist.add(catpack) |
3250 |
print "The following are required but not installed:" |
3269 |
explicitly_required.add(x.split()[2]) |
3251 |
print "* "+"\n* ".join(unresolveable) |
|
|
3252 |
return |
3270 |
|
3253 |
|
3271 |
|
3254 |
cleanlist = [pkg for pkg in vardb.cpv_all() if not fakedb.cpv_exists(pkg)] |
3272 |
sys_world_unversioned = set() |
|
|
3273 |
from itertools import chain |
3274 |
for x in chain(syslist, worldlist): |
3275 |
mycp = portage.dep_getkey(x) |
3276 |
try: |
3277 |
# include any old-style virtual providers that may exist |
3278 |
sys_world_unversioned.update(settings.getvirtuals()[mycp]) |
3279 |
except KeyError: |
3280 |
pass |
3281 |
sys_world_unversioned.add(mycp) |
3282 |
|
3283 |
cleanlist=[] |
3284 |
for x in myvarlist: |
3285 |
if x not in explicitly_required: |
3286 |
# We have to exempt all slots from the system and world sets since |
3287 |
# there's currently no way of knowing which slots the user may want |
3288 |
# to keep. |
3289 |
if portage.dep_getkey(x) not in sys_world_unversioned: |
3290 |
cleanlist.append(x) |
3291 |
|
3255 |
|
3292 |
if len(cleanlist): |
3256 |
if len(cleanlist): |
3293 |
unmerge(settings, myopts, vartree, "unmerge", cleanlist, ldpath_mtimes) |
3257 |
unmerge(settings, myopts, vartree, "unmerge", cleanlist, ldpath_mtimes) |
Lines 3296-3303
Link Here
|
3296 |
print "Packages installed: "+str(len(myvarlist)) |
3260 |
print "Packages installed: "+str(len(myvarlist)) |
3297 |
print "Packages in world: "+str(len(worldlist)) |
3261 |
print "Packages in world: "+str(len(worldlist)) |
3298 |
print "Packages in system: "+str(len(syslist)) |
3262 |
print "Packages in system: "+str(len(syslist)) |
3299 |
print "Unique package names: "+str(len(reallist)) |
3263 |
print "Unique package names: "+str(len(myvarlist)) |
3300 |
print "Required packages: "+str(len(alldeps)) |
3264 |
print "Required packages: "+str(len(fakedb.cpv_all())) |
3301 |
if "--pretend" in myopts: |
3265 |
if "--pretend" in myopts: |
3302 |
print "Number to remove: "+str(len(cleanlist)) |
3266 |
print "Number to remove: "+str(len(cleanlist)) |
3303 |
else: |
3267 |
else: |