-
-// mark a single package in Mark-and-Sweep
-void pkgMarkPackage(pkgDepCache &Cache,
- const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver,
- bool follow_recommends,
- bool follow_suggests)
-{
- pkgDepCache::StateCache &state=Cache[pkg];
- pkgCache::VerIterator candver=state.CandidateVerIter(Cache);
- pkgCache::VerIterator instver=state.InstVerIter(Cache);
-
-#if 0
- // If a package was garbage-collected but is now being marked, we
- // should re-select it
- // For cases when a pkg is set to upgrade and this trigger the
- // removal of a no-longer used dependency. if the pkg is set to
- // keep again later it will result in broken deps
- if(state.Delete() && state.RemoveReason=pkgDepCache::Unused)
- {
- if(ver==candver)
- mark_install(pkg, false, false, NULL);
- else if(ver==pkg.CurrentVer())
- MarkKeep(pkg);
-
- instver=state.InstVerIter(*this);
- }
-#endif
-
- // Ignore versions other than the InstVer, and ignore packages
- // that are already going to be removed or just left uninstalled.
- if(!(ver==instver && !instver.end()))
- return;
-
- // if we are marked already we are done
- if(state.Marked)
- return;
-
- //std::cout << "Setting Marked for: " << pkg.Name() << std::endl;
- state.Marked=true;
-
- if(!ver.end())
- {
- for(pkgCache::DepIterator d=ver.DependsList(); !d.end(); ++d)
- {
- if(d->Type==pkgCache::Dep::Depends ||
- d->Type==pkgCache::Dep::PreDepends ||
- (follow_recommends &&
- d->Type==pkgCache::Dep::Recommends) ||
- (follow_suggests &&
- d->Type==pkgCache::Dep::Suggests))
- {
- // Try all versions of this package.
- for(pkgCache::VerIterator V=d.TargetPkg().VersionList();
- !V.end(); ++V)
- {
- if(_system->VS->CheckDep(V.VerStr(),d->CompareOp, d.TargetVer()))
- {
- pkgMarkPackage(Cache, V.ParentPkg(), V,
- follow_recommends, follow_suggests);
- }
- }
- // Now try virtual packages
- for(pkgCache::PrvIterator prv=d.TargetPkg().ProvidesList();
- !prv.end(); ++prv)
- {
- if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp,
- d.TargetVer()))
- {
- pkgMarkPackage(Cache, prv.OwnerPkg(), prv.OwnerVer(),
- follow_recommends, follow_suggests);
- }
- }
- }
- }
- }
-}
-
-
-// Helper for APT::NeverAutoRemove, always include the packages matching
-// this regexp into the root-set
-inline bool
-pkgMarkAlwaysInclude(pkgCache::PkgIterator p, vector<regex_t*> alwaysMark)