]> git.saurik.com Git - apt.git/blob - apt-private/private-cacheset.cc
Remove invalid "-f" option for apt-get check
[apt.git] / apt-private / private-cacheset.cc
1 #include <apt-pkg/cachefile.h>
2 #include <apt-pkg/pkgcache.h>
3 #include <apt-pkg/depcache.h>
4 #include <apt-pkg/strutl.h>
5
6 #include "private-cacheset.h"
7
8 bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
9 LocalitySortedVersionSet &output_set,
10 OpProgress &progress)
11 {
12 Matcher null_matcher = Matcher();
13 return GetLocalitySortedVersionSet(CacheFile, output_set,
14 null_matcher, progress);
15 }
16
17 bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
18 LocalitySortedVersionSet &output_set,
19 Matcher &matcher,
20 OpProgress &progress)
21 {
22 pkgCache *Cache = CacheFile.GetPkgCache();
23 pkgDepCache *DepCache = CacheFile.GetDepCache();
24
25 int Done=0;
26 progress.SubProgress(Cache->Head().PackageCount, _("Sorting"));
27 for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
28 {
29 if (Done%500 == 0)
30 progress.Progress(Done);
31 Done++;
32
33 if ((matcher)(P) == false)
34 continue;
35
36 // exclude virtual pkgs
37 if (P.VersionList() == 0)
38 continue;
39 pkgDepCache::StateCache &state = (*DepCache)[P];
40 if (_config->FindB("APT::Cmd::Installed") == true)
41 {
42 if (P.CurrentVer() != NULL)
43 {
44 output_set.insert(P.CurrentVer());
45 }
46 }
47 else if (_config->FindB("APT::Cmd::Upgradable") == true)
48 {
49 if(P.CurrentVer() && state.Upgradable())
50 {
51 pkgPolicy *policy = CacheFile.GetPolicy();
52 output_set.insert(policy->GetCandidateVer(P));
53 }
54 }
55 else
56 {
57 pkgPolicy *policy = CacheFile.GetPolicy();
58 output_set.insert(policy->GetCandidateVer(P));
59 }
60 }
61 progress.Done();
62 return true;
63 }