]> git.saurik.com Git - apt.git/blame - apt-private/private-cacheset.cc
make apt search case-insensitive by default
[apt.git] / apt-private / private-cacheset.cc
CommitLineData
453b82a3
DK
1#include <config.h>
2
b9179170
MV
3#include <apt-pkg/cachefile.h>
4#include <apt-pkg/pkgcache.h>
5#include <apt-pkg/depcache.h>
453b82a3
DK
6#include <apt-pkg/cacheiterators.h>
7#include <apt-pkg/configuration.h>
8#include <apt-pkg/progress.h>
9#include <apt-pkg/policy.h>
10
11#include <apt-private/private-cacheset.h>
12
13#include <stddef.h>
b9179170 14
453b82a3 15#include <apti18n.h>
b9179170
MV
16
17bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
18 LocalitySortedVersionSet &output_set,
19 OpProgress &progress)
20{
21 Matcher null_matcher = Matcher();
22 return GetLocalitySortedVersionSet(CacheFile, output_set,
23 null_matcher, progress);
24}
25
26bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
27 LocalitySortedVersionSet &output_set,
28 Matcher &matcher,
29 OpProgress &progress)
30{
31 pkgCache *Cache = CacheFile.GetPkgCache();
32 pkgDepCache *DepCache = CacheFile.GetDepCache();
33
34 int Done=0;
35 progress.SubProgress(Cache->Head().PackageCount, _("Sorting"));
36 for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
37 {
38 if (Done%500 == 0)
39 progress.Progress(Done);
40 Done++;
41
42 if ((matcher)(P) == false)
43 continue;
44
45 // exclude virtual pkgs
46 if (P.VersionList() == 0)
47 continue;
48 pkgDepCache::StateCache &state = (*DepCache)[P];
49 if (_config->FindB("APT::Cmd::Installed") == true)
50 {
51 if (P.CurrentVer() != NULL)
52 {
53 output_set.insert(P.CurrentVer());
54 }
55 }
56 else if (_config->FindB("APT::Cmd::Upgradable") == true)
57 {
58 if(P.CurrentVer() && state.Upgradable())
59 {
60 pkgPolicy *policy = CacheFile.GetPolicy();
61 output_set.insert(policy->GetCandidateVer(P));
62 }
63 }
3bdf7da5
MV
64 else if (_config->FindB("APT::Cmd::Manual-Installed") == true)
65 {
66 if (P.CurrentVer() &&
67 ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false)
68 {
69 pkgPolicy *policy = CacheFile.GetPolicy();
70 output_set.insert(policy->GetCandidateVer(P));
71 }
72 }
b9179170
MV
73 else
74 {
75 pkgPolicy *policy = CacheFile.GetPolicy();
76 output_set.insert(policy->GetCandidateVer(P));
77 }
78 }
79 progress.Done();
80 return true;
81}