]>
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 pkgPolicy
*policy
= CacheFile
.GetPolicy();
61 policy
->GetCandidateVer(P
) != P
.CurrentVer())
63 pkgPolicy
*policy
= CacheFile
.GetPolicy();
64 output_set
.insert(policy
->GetCandidateVer(P
));
67 else if (_config
->FindB("APT::Cmd::Manual-Installed") == true)
70 ((*DepCache
)[P
].Flags
& pkgCache::Flag::Auto
) == false)
72 pkgPolicy
*policy
= CacheFile
.GetPolicy();
73 output_set
.insert(policy
->GetCandidateVer(P
));
78 pkgPolicy
*policy
= CacheFile
.GetPolicy();
79 if (policy
->GetCandidateVer(P
).IsGood())
80 output_set
.insert(policy
->GetCandidateVer(P
));
82 // no candidate, this may happen for packages in
83 // dpkg "deinstall ok config-file" state - we pick the first ver
84 // (which should be the only one)
85 output_set
.insert(P
.VersionList());