]>
git.saurik.com Git - apt.git/blob - 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>
6 #include "private-cacheset.h"
8 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
9 LocalitySortedVersionSet
&output_set
,
12 Matcher null_matcher
= Matcher();
13 return GetLocalitySortedVersionSet(CacheFile
, output_set
,
14 null_matcher
, progress
);
17 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
18 LocalitySortedVersionSet
&output_set
,
22 pkgCache
*Cache
= CacheFile
.GetPkgCache();
23 pkgDepCache
*DepCache
= CacheFile
.GetDepCache();
26 progress
.SubProgress(Cache
->Head().PackageCount
, _("Sorting"));
27 for (pkgCache::PkgIterator P
= Cache
->PkgBegin(); P
.end() == false; ++P
)
30 progress
.Progress(Done
);
33 if ((matcher
)(P
) == false)
36 // exclude virtual pkgs
37 if (P
.VersionList() == 0)
39 pkgDepCache::StateCache
&state
= (*DepCache
)[P
];
40 if (_config
->FindB("APT::Cmd::Installed") == true)
42 if (P
.CurrentVer() != NULL
)
44 output_set
.insert(P
.CurrentVer());
47 else if (_config
->FindB("APT::Cmd::Upgradable") == true)
49 if(P
.CurrentVer() && state
.Upgradable())
51 pkgPolicy
*policy
= CacheFile
.GetPolicy();
52 output_set
.insert(policy
->GetCandidateVer(P
));
55 else if (_config
->FindB("APT::Cmd::Manual-Installed") == true)
58 ((*DepCache
)[P
].Flags
& pkgCache::Flag::Auto
) == false)
60 pkgPolicy
*policy
= CacheFile
.GetPolicy();
61 output_set
.insert(policy
->GetCandidateVer(P
));
66 pkgPolicy
*policy
= CacheFile
.GetPolicy();
67 output_set
.insert(policy
->GetCandidateVer(P
));