- // do the sweep
- for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p)
- {
- pkgDepCache::StateCache &state=Cache[p];
-
- if(!state.Marked)
- {
- // mark installed but not yet marked stuff as garbage
- if(p->CurrentVer != 0) {
- state.Garbage=true;
- std::cout << "Garbage: " << p.Name() << std::endl;
- }
-
-#if 0 // mvo: the below bits still needs to be ported
-
- // Be sure not to re-delete already deleted packages.
- if(delete_unused && (!p.CurrentVer().end() || state.Install()) &&
- !state.Delete())
- {
- bool do_delete=true;
-
- // If the package is being upgraded, check if we're
- // losing a versioned dep. If the dependency matches
- // the previous version and not the new version, keep
- // the package back instead of removing it.
- if(!p.CurrentVer().end() && state.Install())
- {
- const char *vs=p.CurrentVer().VerStr();
-
- // Check direct revdeps only. THIS ASSUMES NO
- // VERSIONED PROVIDES, but Debian probably won't
- // have them for ages if ever.
- for(pkgCache::DepIterator revdep=p.RevDependsList();
- !revdep.end(); ++revdep)
- {
- pkgCache::PkgIterator depender=revdep.ParentPkg();
- // Find which version of the depending package
- // will be installed.
- pkgCache::VerIterator instver=(*this)[depender].InstVerIter(*this);
-
- // Only pay attention to strong positive
- // dependencies whose parents will be installed.
- if(revdep.ParentVer()==instver &&
- (revdep->Type==pkgCache::Dep::Depends ||
- revdep->Type==pkgCache::Dep::PreDepends ||
- (revdep->Type==pkgCache::Dep::Recommends &&
- follow_recommends)))
- {
- // If the previous version matched, cancel the
- // deletion. (note that I assume that the new
- // version does NOT match; otherwise it would
- // not be unused!)
- if(_system->VS->CheckDep(vs,
- revdep->CompareOp,
- revdep.TargetVer()))
- {
- mark_keep(p, false, false, undo);
- do_delete=false;
- break;
- }
- }
- }
- }