]>
git.saurik.com Git - apt.git/blob - apt-private/private-cacheset.cc
3 #include <apt-pkg/cachefile.h>
4 #include <apt-pkg/pkgcache.h>
5 #include <apt-pkg/depcache.h>
6 #include <apt-pkg/cacheiterators.h>
7 #include <apt-pkg/configuration.h>
8 #include <apt-pkg/progress.h>
9 #include <apt-pkg/policy.h>
11 #include <apt-private/private-cacheset.h>
17 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
18 LocalitySortedVersionSet
&output_set
,
21 Matcher null_matcher
= Matcher();
22 return GetLocalitySortedVersionSet(CacheFile
, output_set
,
23 null_matcher
, progress
);
26 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
27 LocalitySortedVersionSet
&output_set
,
31 pkgCache
*Cache
= CacheFile
.GetPkgCache();
32 pkgDepCache
*DepCache
= CacheFile
.GetDepCache();
35 progress
.SubProgress(Cache
->Head().PackageCount
, _("Sorting"));
36 for (pkgCache::PkgIterator P
= Cache
->PkgBegin(); P
.end() == false; ++P
)
39 progress
.Progress(Done
);
42 if ((matcher
)(P
) == false)
45 // exclude virtual pkgs
46 if (P
.VersionList() == 0)
48 pkgDepCache::StateCache
&state
= (*DepCache
)[P
];
49 if (_config
->FindB("APT::Cmd::Installed") == true)
51 if (P
.CurrentVer() != NULL
)
53 output_set
.insert(P
.CurrentVer());
56 else if (_config
->FindB("APT::Cmd::Upgradable") == true)
58 if(P
.CurrentVer() && state
.Upgradable())
60 pkgPolicy
*policy
= CacheFile
.GetPolicy();
61 output_set
.insert(policy
->GetCandidateVer(P
));
64 else if (_config
->FindB("APT::Cmd::Manual-Installed") == true)
67 ((*DepCache
)[P
].Flags
& pkgCache::Flag::Auto
) == false)
69 pkgPolicy
*policy
= CacheFile
.GetPolicy();
70 output_set
.insert(policy
->GetCandidateVer(P
));
75 pkgPolicy
*policy
= CacheFile
.GetPolicy();
76 output_set
.insert(policy
->GetCandidateVer(P
));