X-Git-Url: http://git.hcoop.net/ntk/apt.git/blobdiff_plain/d059cc2668f284a7db77a15d1d742326d464e963..c42ab00a22d37c559f412a696ad36c368cf270d5:/apt-private/private-cacheset.cc diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc dissimilarity index 68% index 159e1d8f..eb77be27 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -1,90 +1,90 @@ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, - LocalitySortedVersionSet &output_set, - OpProgress &progress) -{ - Matcher null_matcher = Matcher(); - return GetLocalitySortedVersionSet(CacheFile, output_set, - null_matcher, progress); -} - -bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, - LocalitySortedVersionSet &output_set, - Matcher &matcher, - OpProgress &progress) -{ - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgDepCache *DepCache = CacheFile.GetDepCache(); - - int Done=0; - progress.SubProgress(Cache->Head().PackageCount, _("Sorting")); - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) - { - if (Done%500 == 0) - progress.Progress(Done); - Done++; - - if ((matcher)(P) == false) - continue; - - // exclude virtual pkgs - if (P.VersionList() == 0) - continue; - pkgDepCache::StateCache &state = (*DepCache)[P]; - if (_config->FindB("APT::Cmd::Installed") == true) - { - if (P.CurrentVer() != NULL) - { - output_set.insert(P.CurrentVer()); - } - } - else if (_config->FindB("APT::Cmd::Upgradable") == true) - { - pkgPolicy *policy = CacheFile.GetPolicy(); - if(P.CurrentVer() && - state.Upgradable() && - policy->GetCandidateVer(P) != P.CurrentVer()) - { - pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); - } - } - else if (_config->FindB("APT::Cmd::Manual-Installed") == true) - { - if (P.CurrentVer() && - ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false) - { - pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); - } - } - else - { - pkgPolicy *policy = CacheFile.GetPolicy(); - if (policy->GetCandidateVer(P).IsGood()) - output_set.insert(policy->GetCandidateVer(P)); - else - // no candidate, this may happen for packages in - // dpkg "deinstall ok config-file" state - we pick the first ver - // (which should be the only one) - output_set.insert(P.VersionList()); - } - } - progress.Done(); - return true; -} +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, + APT::VersionContainerInterface * const vci, + OpProgress * const progress) +{ + Matcher null_matcher = Matcher(); + return GetLocalitySortedVersionSet(CacheFile, vci, + null_matcher, progress); +} + +bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, + APT::VersionContainerInterface * const vci, + Matcher &matcher, + OpProgress * const progress) +{ + pkgCache *Cache = CacheFile.GetPkgCache(); + pkgDepCache *DepCache = CacheFile.GetDepCache(); + APT::CacheSetHelper helper(false); + + int Done=0; + if (progress != NULL) + progress->SubProgress(Cache->Head().PackageCount, _("Sorting")); + + bool const insertCurrentVer = _config->FindB("APT::Cmd::Installed", false); + bool const insertUpgradable = _config->FindB("APT::Cmd::Upgradable", false); + bool const insertManualInstalled = _config->FindB("APT::Cmd::Manual-Installed", false); + + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) + { + if (progress != NULL) + { + if (Done % 500 == 0) + progress->Progress(Done); + ++Done; + } + + // exclude virtual pkgs + if (P->VersionList == 0) + continue; + + if ((matcher)(P) == false) + continue; + + pkgDepCache::StateCache &state = (*DepCache)[P]; + if (insertCurrentVer == true) + { + if (P->CurrentVer != 0) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::INSTALLED, helper); + } + else if (insertUpgradable == true) + { + if(P.CurrentVer() && state.Upgradable()) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); + } + else if (insertManualInstalled == true) + { + if (P.CurrentVer() && + ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); + } + else + { + if (vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper) == false) + { + // no candidate, this may happen for packages in + // dpkg "deinstall ok config-file" state - we pick the first ver + // (which should be the only one) + vci->insert(P.VersionList()); + } + } + } + if (progress != NULL) + progress->Done(); + return true; +}