summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-07-29 11:37:05 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-07-29 11:37:05 +0200
commit1b8ba3ba050f01db27f1ddc0e5b280b2fccd9fb9 (patch)
tree4c95c5ad0b62ae2e3ad155a89f3997efe5109c28 /cmdline
parent15032eec2d508df3c63b532be22f488d240159a2 (diff)
parent3de4647b39216259678f40f4bf6e8122acd923b5 (diff)
merged lp:~donkult/apt/sid
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc238
-rw-r--r--cmdline/apt-get.cc2
-rw-r--r--cmdline/cacheset.cc515
-rw-r--r--cmdline/cacheset.h375
-rw-r--r--cmdline/makefile4
5 files changed, 108 insertions, 1026 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 338be7029..70732e4d0 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -17,6 +17,7 @@
#include <cassert>
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
#include <apt-pkg/init.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/sourcelist.h>
@@ -30,8 +31,6 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/sptr.h>
-#include "cacheset.h"
-
#include <config.h>
#include <apti18n.h>
@@ -552,72 +551,98 @@ bool DumpAvail(CommandLine &Cmd)
return !_error->PendingError();
}
/*}}}*/
-// Depends - Print out a dependency tree /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool Depends(CommandLine &CmdL)
+// ShowDepends - Helper for printing out a dependency tree /*{{{*/
+class CacheSetHelperDepends: public APT::CacheSetHelper {
+public:
+ APT::PackageSet virtualPkgs;
+
+ virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+ virtualPkgs.insert(Pkg);
+ return pkgCache::VerIterator(Cache, 0);
+ }
+
+ virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+ virtualPkgs.insert(Pkg);
+ return pkgCache::VerIterator(Cache, 0);
+ }
+
+ CacheSetHelperDepends() : CacheSetHelper(false) {}
+};
+bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
if (unlikely(Cache == NULL))
return false;
- SPtrArray<unsigned> Colours = new unsigned[Cache->Head().PackageCount];
- memset(Colours,0,sizeof(*Colours)*Cache->Head().PackageCount);
-
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
- Colours[Pkg->ID] = 1;
-
- bool Recurse = _config->FindB("APT::Cache::RecurseDepends",false);
- bool Installed = _config->FindB("APT::Cache::Installed",false);
- bool Important = _config->FindB("APT::Cache::Important",false);
- bool DidSomething;
- do
+ CacheSetHelperDepends helper;
+ APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+ if (verset.empty() == true && helper.virtualPkgs.empty() == true)
+ return false;
+ std::vector<bool> Shown(Cache->Head().PackageCount);
+
+ bool const Recurse = _config->FindB("APT::Cache::RecurseDepends", false);
+ bool const Installed = _config->FindB("APT::Cache::Installed", false);
+ bool const Important = _config->FindB("APT::Cache::Important", false);
+ bool const ShowDepType = _config->FindB("APT::Cache::ShowDependencyType", RevDepends == false);
+ bool const ShowPreDepends = _config->FindB("APT::Cache::ShowPre-Depends", true);
+ bool const ShowDepends = _config->FindB("APT::Cache::ShowDepends", true);
+ bool const ShowRecommends = _config->FindB("APT::Cache::ShowRecommends", Important == false);
+ bool const ShowSuggests = _config->FindB("APT::Cache::ShowSuggests", Important == false);
+ bool const ShowReplaces = _config->FindB("APT::Cache::ShowReplaces", Important == false);
+ bool const ShowConflicts = _config->FindB("APT::Cache::ShowConflicts", Important == false);
+ bool const ShowBreaks = _config->FindB("APT::Cache::ShowBreaks", Important == false);
+ bool const ShowEnhances = _config->FindB("APT::Cache::ShowEnhances", Important == false);
+ bool const ShowOnlyFirstOr = _config->FindB("APT::Cache::ShowOnlyFirstOr", false);
+
+ while (verset.empty() != true)
{
- DidSomething = false;
- for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
- {
- if (Colours[Pkg->ID] != 1)
- continue;
- Colours[Pkg->ID] = 2;
- DidSomething = true;
-
- pkgCache::VerIterator Ver = Pkg.VersionList();
- if (Ver.end() == true)
- {
- cout << '<' << Pkg.FullName(true) << '>' << endl;
- continue;
- }
-
+ pkgCache::VerIterator Ver = *verset.begin();
+ verset.erase(verset.begin());
+ pkgCache::PkgIterator Pkg = Ver.ParentPkg();
+ Shown[Pkg->ID] = true;
+
cout << Pkg.FullName(true) << endl;
-
- for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
+
+ if (RevDepends == true)
+ cout << "Reverse Depends:" << endl;
+ for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList();
+ D.end() == false; D++)
{
- // Important deps only
- if (Important == true)
- if (D->Type != pkgCache::Dep::PreDepends &&
- D->Type != pkgCache::Dep::Depends)
- continue;
-
- pkgCache::PkgIterator Trg = D.TargetPkg();
+ switch (D->Type) {
+ case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break;
+ case pkgCache::Dep::Depends: if (!ShowDepends) continue; break;
+ case pkgCache::Dep::Recommends: if (!ShowRecommends) continue; break;
+ case pkgCache::Dep::Suggests: if (!ShowSuggests) continue; break;
+ case pkgCache::Dep::Replaces: if (!ShowReplaces) continue; break;
+ case pkgCache::Dep::Conflicts: if (!ShowConflicts) continue; break;
+ case pkgCache::Dep::DpkgBreaks: if (!ShowBreaks) continue; break;
+ case pkgCache::Dep::Enhances: if (!ShowEnhances) continue; break;
+ }
+
+ pkgCache::PkgIterator Trg = RevDepends ? D.ParentPkg() : D.TargetPkg();
if((Installed && Trg->CurrentVer != 0) || !Installed)
{
- if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)
+ if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or && ShowOnlyFirstOr == false)
cout << " |";
else
cout << " ";
// Show the package
+ if (ShowDepType == true)
+ cout << D.DepType() << ": ";
if (Trg->VersionList == 0)
- cout << D.DepType() << ": <" << Trg.FullName(true) << ">" << endl;
+ cout << "<" << Trg.FullName(true) << ">" << endl;
else
- cout << D.DepType() << ": " << Trg.FullName(true) << endl;
+ cout << Trg.FullName(true) << endl;
- if (Recurse == true)
- Colours[D.TargetPkg()->ID]++;
+ if (Recurse == true && Shown[Trg->ID] == false)
+ {
+ Shown[Trg->ID] = true;
+ verset.insert(APT::VersionSet::FromPackage(CacheFile, Trg, APT::VersionSet::CANDIDATE, helper));
+ }
}
@@ -631,101 +656,40 @@ bool Depends(CommandLine &CmdL)
V->ParentPkg == D->Package)
continue;
cout << " " << V.ParentPkg().FullName(true) << endl;
-
- if (Recurse == true)
- Colours[D.ParentPkg()->ID]++;
+
+ if (Recurse == true && Shown[V.ParentPkg()->ID] == false)
+ {
+ Shown[V.ParentPkg()->ID] = true;
+ verset.insert(APT::VersionSet::FromPackage(CacheFile, V.ParentPkg(), APT::VersionSet::CANDIDATE, helper));
+ }
}
+
+ if (ShowOnlyFirstOr == true)
+ while ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) ++D;
}
- }
- }
- while (DidSomething == true);
-
+ }
+
+ for (APT::PackageSet::const_iterator Pkg = helper.virtualPkgs.begin();
+ Pkg != helper.virtualPkgs.end(); ++Pkg)
+ cout << '<' << Pkg.FullName(true) << '>' << endl;
+
return true;
}
/*}}}*/
-// RDepends - Print out a reverse dependency tree - mbc /*{{{*/
+// Depends - Print out a dependency tree /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool Depends(CommandLine &CmdL)
+{
+ return ShowDepends(CmdL, false);
+}
+ /*}}}*/
+// RDepends - Print out a reverse dependency tree /*{{{*/
// ---------------------------------------------------------------------
/* */
bool RDepends(CommandLine &CmdL)
{
- pkgCacheFile CacheFile;
- pkgCache *Cache = CacheFile.GetPkgCache();
- if (unlikely(Cache == NULL))
- return false;
-
- SPtrArray<unsigned> Colours = new unsigned[Cache->Head().PackageCount];
- memset(Colours,0,sizeof(*Colours)*Cache->Head().PackageCount);
-
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
- Colours[Pkg->ID] = 1;
-
- bool Recurse = _config->FindB("APT::Cache::RecurseDepends",false);
- bool Installed = _config->FindB("APT::Cache::Installed",false);
- bool DidSomething;
- do
- {
- DidSomething = false;
- for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
- {
- if (Colours[Pkg->ID] != 1)
- continue;
- Colours[Pkg->ID] = 2;
- DidSomething = true;
-
- pkgCache::VerIterator Ver = Pkg.VersionList();
- if (Ver.end() == true)
- {
- cout << '<' << Pkg.FullName(true) << '>' << endl;
- continue;
- }
-
- cout << Pkg.FullName(true) << endl;
-
- cout << "Reverse Depends:" << endl;
- for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
- {
- // Show the package
- pkgCache::PkgIterator Trg = D.ParentPkg();
-
- if((Installed && Trg->CurrentVer != 0) || !Installed)
- {
-
- if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)
- cout << " |";
- else
- cout << " ";
-
- if (Trg->VersionList == 0)
- cout << D.DepType() << ": <" << Trg.FullName(true) << ">" << endl;
- else
- cout << Trg.FullName(true) << endl;
-
- if (Recurse == true)
- Colours[D.ParentPkg()->ID]++;
-
- }
-
- // Display all solutions
- SPtrArray<pkgCache::Version *> List = D.AllTargets();
- pkgPrioSortList(*Cache,List);
- for (pkgCache::Version **I = List; *I != 0; I++)
- {
- pkgCache::VerIterator V(*Cache,*I);
- if (V != Cache->VerP + V.ParentPkg()->VersionList ||
- V->ParentPkg == D->Package)
- continue;
- cout << " " << V.ParentPkg().FullName(true) << endl;
-
- if (Recurse == true)
- Colours[D.ParentPkg()->ID]++;
- }
- }
- }
- }
- while (DidSomething == true);
-
- return true;
+ return ShowDepends(CmdL, true);
}
/*}}}*/
// xvcg - Generate a graph for xvcg /*{{{*/
@@ -1820,6 +1784,14 @@ int main(int argc,const char *argv[]) /*{{{*/
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
{0,"installed","APT::Cache::Installed",0},
+ {0,"pre-depends","APT::Cache::ShowPreDepends",0},
+ {0,"depends","APT::Cache::ShowDepends",0},
+ {0,"recommends","APT::Cache::ShowRecommends",0},
+ {0,"suggests","APT::Cache::ShowSuggests",0},
+ {0,"replaces","APT::Cache::ShowReplaces",0},
+ {0,"breaks","APT::Cache::ShowBreaks",0},
+ {0,"conflicts","APT::Cache::ShowConflicts",0},
+ {0,"enhances","APT::Cache::ShowEnhances",0},
{0,0,0,0}};
CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
{"add",&DoAdd},
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index a6dfd82ed..c0e74b37b 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -40,6 +40,7 @@
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/version.h>
#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/versionmatch.h>
@@ -48,7 +49,6 @@
#include <apti18n.h>
#include "acqprogress.h"
-#include "cacheset.h"
#include <set>
#include <locale.h>
diff --git a/cmdline/cacheset.cc b/cmdline/cacheset.cc
deleted file mode 100644
index 78c9d3f6c..000000000
--- a/cmdline/cacheset.cc
+++ /dev/null
@@ -1,515 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-/* ######################################################################
-
- Simple wrapper around a std::set to provide a similar interface to
- a set of cache structures as to the complete set of all structures
- in the pkgCache. Currently only Package is supported.
-
- ##################################################################### */
- /*}}}*/
-// Include Files /*{{{*/
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/versionmatch.h>
-
-#include <apti18n.h>
-
-#include "cacheset.h"
-
-#include <vector>
-
-#include <regex.h>
- /*}}}*/
-namespace APT {
-// FromTask - Return all packages in the cache from a specific task /*{{{*/
-PackageSet PackageSet::FromTask(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
- size_t const archfound = pattern.find_last_of(':');
- std::string arch = "native";
- if (archfound != std::string::npos) {
- arch = pattern.substr(archfound+1);
- pattern.erase(archfound);
- }
-
- if (pattern[pattern.length() -1] != '^')
- return APT::PackageSet(TASK);
- pattern.erase(pattern.length()-1);
-
- if (unlikely(Cache.GetPkgCache() == 0 || Cache.GetDepCache() == 0))
- return APT::PackageSet(TASK);
-
- PackageSet pkgset(TASK);
- // get the records
- pkgRecords Recs(Cache);
-
- // build regexp for the task
- regex_t Pattern;
- char S[300];
- snprintf(S, sizeof(S), "^Task:.*[, ]%s([, ]|$)", pattern.c_str());
- if(regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE) != 0) {
- _error->Error("Failed to compile task regexp");
- return pkgset;
- }
-
- for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp) {
- pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
- if (Pkg.end() == true)
- continue;
- pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache);
- if(ver.end() == true)
- continue;
-
- pkgRecords::Parser &parser = Recs.Lookup(ver.FileList());
- const char *start, *end;
- parser.GetRec(start,end);
- unsigned int const length = end - start;
- char buf[length];
- strncpy(buf, start, length);
- buf[length-1] = '\0';
- if (regexec(&Pattern, buf, 0, 0, 0) != 0)
- continue;
-
- pkgset.insert(Pkg);
- }
- regfree(&Pattern);
-
- if (pkgset.empty() == true)
- return helper.canNotFindTask(Cache, pattern);
-
- helper.showTaskSelection(pkgset, pattern);
- return pkgset;
-}
- /*}}}*/
-// FromRegEx - Return all packages in the cache matching a pattern /*{{{*/
-PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
- static const char * const isregex = ".?+*|[^$";
- if (pattern.find_first_of(isregex) == std::string::npos)
- return PackageSet(REGEX);
-
- size_t archfound = pattern.find_last_of(':');
- std::string arch = "native";
- if (archfound != std::string::npos) {
- arch = pattern.substr(archfound+1);
- if (arch.find_first_of(isregex) == std::string::npos)
- pattern.erase(archfound);
- else
- arch = "native";
- }
-
- regex_t Pattern;
- int Res;
- if ((Res = regcomp(&Pattern, pattern.c_str() , REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0) {
- char Error[300];
- regerror(Res, &Pattern, Error, sizeof(Error));
- _error->Error(_("Regex compilation error - %s"), Error);
- return PackageSet(REGEX);
- }
-
- if (unlikely(Cache.GetPkgCache() == 0))
- return PackageSet(REGEX);
-
- PackageSet pkgset(REGEX);
- for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp)
- {
- if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0)
- continue;
- pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
- if (Pkg.end() == true) {
- if (archfound == std::string::npos) {
- std::vector<std::string> archs = APT::Configuration::getArchitectures();
- for (std::vector<std::string>::const_iterator a = archs.begin();
- a != archs.end() && Pkg.end() != true; ++a)
- Pkg = Grp.FindPkg(*a);
- }
- if (Pkg.end() == true)
- continue;
- }
-
- pkgset.insert(Pkg);
- }
- regfree(&Pattern);
-
- if (pkgset.empty() == true)
- return helper.canNotFindRegEx(Cache, pattern);
-
- helper.showRegExSelection(pkgset, pattern);
- return pkgset;
-}
- /*}}}*/
-// FromName - Returns the package defined by this string /*{{{*/
-pkgCache::PkgIterator PackageSet::FromName(pkgCacheFile &Cache,
- std::string const &str, CacheSetHelper &helper) {
- std::string pkg = str;
- size_t archfound = pkg.find_last_of(':');
- std::string arch;
- if (archfound != std::string::npos) {
- arch = pkg.substr(archfound+1);
- pkg.erase(archfound);
- }
-
- if (Cache.GetPkgCache() == 0)
- return pkgCache::PkgIterator(Cache, 0);
-
- pkgCache::PkgIterator Pkg(Cache, 0);
- if (arch.empty() == true) {
- pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg);
- if (Grp.end() == false)
- Pkg = Grp.FindPreferredPkg();
- } else
- Pkg = Cache.GetPkgCache()->FindPkg(pkg, arch);
-
- if (Pkg.end() == true)
- return helper.canNotFindPkgName(Cache, str);
- return Pkg;
-}
- /*}}}*/
-// GroupedFromCommandLine - Return all versions specified on commandline/*{{{*/
-std::map<unsigned short, PackageSet> PackageSet::GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<PackageSet::Modifier> const &mods,
- unsigned short const &fallback, CacheSetHelper &helper) {
- std::map<unsigned short, PackageSet> pkgsets;
- for (const char **I = cmdline; *I != 0; ++I) {
- unsigned short modID = fallback;
- std::string str = *I;
- bool modifierPresent = false;
- for (std::list<PackageSet::Modifier>::const_iterator mod = mods.begin();
- mod != mods.end(); ++mod) {
- size_t const alength = strlen(mod->Alias);
- switch(mod->Pos) {
- case PackageSet::Modifier::POSTFIX:
- if (str.compare(str.length() - alength, alength,
- mod->Alias, 0, alength) != 0)
- continue;
- str.erase(str.length() - alength);
- modID = mod->ID;
- break;
- case PackageSet::Modifier::PREFIX:
- continue;
- case PackageSet::Modifier::NONE:
- continue;
- }
- modifierPresent = true;
- break;
- }
- if (modifierPresent == true) {
- bool const errors = helper.showErrors(false);
- pkgCache::PkgIterator Pkg = FromName(Cache, *I, helper);
- helper.showErrors(errors);
- if (Pkg.end() == false) {
- pkgsets[fallback].insert(Pkg);
- continue;
- }
- }
- pkgsets[modID].insert(PackageSet::FromString(Cache, str, helper));
- }
- return pkgsets;
-}
- /*}}}*/
-// FromCommandLine - Return all packages specified on commandline /*{{{*/
-PackageSet PackageSet::FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) {
- PackageSet pkgset;
- for (const char **I = cmdline; *I != 0; ++I) {
- PackageSet pset = FromString(Cache, *I, helper);
- pkgset.insert(pset.begin(), pset.end());
- }
- return pkgset;
-}
- /*}}}*/
-// FromString - Return all packages matching a specific string /*{{{*/
-PackageSet PackageSet::FromString(pkgCacheFile &Cache, std::string const &str, CacheSetHelper &helper) {
- _error->PushToStack();
-
- PackageSet pkgset;
- pkgCache::PkgIterator Pkg = FromName(Cache, str, helper);
- if (Pkg.end() == false)
- pkgset.insert(Pkg);
- else {
- pkgset = FromTask(Cache, str, helper);
- if (pkgset.empty() == true) {
- pkgset = FromRegEx(Cache, str, helper);
- if (pkgset.empty() == true)
- pkgset = helper.canNotFindPackage(Cache, str);
- }
- }
-
- if (pkgset.empty() == false)
- _error->RevertToStack();
- else
- _error->MergeWithStack();
- return pkgset;
-}
- /*}}}*/
-// GroupedFromCommandLine - Return all versions specified on commandline/*{{{*/
-std::map<unsigned short, VersionSet> VersionSet::GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<VersionSet::Modifier> const &mods,
- unsigned short const &fallback, CacheSetHelper &helper) {
- std::map<unsigned short, VersionSet> versets;
- for (const char **I = cmdline; *I != 0; ++I) {
- unsigned short modID = fallback;
- VersionSet::Version select = VersionSet::NEWEST;
- std::string str = *I;
- bool modifierPresent = false;
- for (std::list<VersionSet::Modifier>::const_iterator mod = mods.begin();
- mod != mods.end(); ++mod) {
- if (modID == fallback && mod->ID == fallback)
- select = mod->SelectVersion;
- size_t const alength = strlen(mod->Alias);
- switch(mod->Pos) {
- case VersionSet::Modifier::POSTFIX:
- if (str.compare(str.length() - alength, alength,
- mod->Alias, 0, alength) != 0)
- continue;
- str.erase(str.length() - alength);
- modID = mod->ID;
- select = mod->SelectVersion;
- break;
- case VersionSet::Modifier::PREFIX:
- continue;
- case VersionSet::Modifier::NONE:
- continue;
- }
- modifierPresent = true;
- break;
- }
-
- if (modifierPresent == true) {
- bool const errors = helper.showErrors(false);
- VersionSet const vset = VersionSet::FromString(Cache, std::string(*I), select, helper, true);
- helper.showErrors(errors);
- if (vset.empty() == false) {
- versets[fallback].insert(vset);
- continue;
- }
- }
- versets[modID].insert(VersionSet::FromString(Cache, str, select , helper));
- }
- return versets;
-}
- /*}}}*/
-// FromCommandLine - Return all versions specified on commandline /*{{{*/
-APT::VersionSet VersionSet::FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
- APT::VersionSet::Version const &fallback, CacheSetHelper &helper) {
- VersionSet verset;
- for (const char **I = cmdline; *I != 0; ++I)
- verset.insert(VersionSet::FromString(Cache, *I, fallback, helper));
- return verset;
-}
- /*}}}*/
-// FromString - Returns all versions spedcified by a string /*{{{*/
-APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg,
- APT::VersionSet::Version const &fallback, CacheSetHelper &helper,
- bool const &onlyFromName) {
- std::string ver;
- bool verIsRel = false;
- size_t const vertag = pkg.find_last_of("/=");
- if (vertag != string::npos) {
- ver = pkg.substr(vertag+1);
- verIsRel = (pkg[vertag] == '/');
- pkg.erase(vertag);
- }
- PackageSet pkgset;
- if (onlyFromName == false)
- pkgset = PackageSet::FromString(Cache, pkg, helper);
- else {
- pkgset.insert(PackageSet::FromName(Cache, pkg, helper));
- }
-
- VersionSet verset;
- bool errors = true;
- if (pkgset.getConstructor() != PackageSet::UNKNOWN)
- errors = helper.showErrors(false);
- for (PackageSet::const_iterator P = pkgset.begin();
- P != pkgset.end(); ++P) {
- if (vertag == string::npos) {
- verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
- continue;
- }
- pkgCache::VerIterator V;
- if (ver == "installed")
- V = getInstalledVer(Cache, P, helper);
- else if (ver == "candidate")
- V = getCandidateVer(Cache, P, helper);
- else {
- pkgVersionMatch Match(ver, (verIsRel == true ? pkgVersionMatch::Release :
- pkgVersionMatch::Version));
- V = Match.Find(P);
- if (V.end() == true) {
- if (verIsRel == true)
- _error->Error(_("Release '%s' for '%s' was not found"),
- ver.c_str(), P.FullName(true).c_str());
- else
- _error->Error(_("Version '%s' for '%s' was not found"),
- ver.c_str(), P.FullName(true).c_str());
- continue;
- }
- }
- if (V.end() == true)
- continue;
- helper.showSelectedVersion(P, V, ver, verIsRel);
- verset.insert(V);
- }
- if (pkgset.getConstructor() != PackageSet::UNKNOWN)
- helper.showErrors(errors);
- return verset;
-}
- /*}}}*/
-// FromPackage - versions from package based on fallback /*{{{*/
-VersionSet VersionSet::FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
- VersionSet::Version const &fallback, CacheSetHelper &helper) {
- VersionSet verset;
- pkgCache::VerIterator V;
- bool showErrors;
- switch(fallback) {
- case VersionSet::ALL:
- if (P->VersionList != 0)
- for (V = P.VersionList(); V.end() != true; ++V)
- verset.insert(V);
- else
- verset.insert(helper.canNotFindAllVer(Cache, P));
- break;
- case VersionSet::CANDANDINST:
- verset.insert(getInstalledVer(Cache, P, helper));
- verset.insert(getCandidateVer(Cache, P, helper));
- break;
- case VersionSet::CANDIDATE:
- verset.insert(getCandidateVer(Cache, P, helper));
- break;
- case VersionSet::INSTALLED:
- verset.insert(getInstalledVer(Cache, P, helper));
- break;
- case VersionSet::CANDINST:
- showErrors = helper.showErrors(false);
- V = getCandidateVer(Cache, P, helper);
- if (V.end() == true)
- V = getInstalledVer(Cache, P, helper);
- helper.showErrors(showErrors);
- if (V.end() == false)
- verset.insert(V);
- else
- verset.insert(helper.canNotFindInstCandVer(Cache, P));
- break;
- case VersionSet::INSTCAND:
- showErrors = helper.showErrors(false);
- V = getInstalledVer(Cache, P, helper);
- if (V.end() == true)
- V = getCandidateVer(Cache, P, helper);
- helper.showErrors(showErrors);
- if (V.end() == false)
- verset.insert(V);
- else
- verset.insert(helper.canNotFindInstCandVer(Cache, P));
- break;
- case VersionSet::NEWEST:
- if (P->VersionList != 0)
- verset.insert(P.VersionList());
- else
- verset.insert(helper.canNotFindNewestVer(Cache, P));
- break;
- }
- return verset;
-}
- /*}}}*/
-// getCandidateVer - Returns the candidate version of the given package /*{{{*/
-pkgCache::VerIterator VersionSet::getCandidateVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
- pkgCache::VerIterator Cand;
- if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false)
- {
- if (unlikely(Cache.GetPolicy() == 0))
- return pkgCache::VerIterator(Cache);
- Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
- } else {
- Cand = Cache[Pkg].CandidateVerIter(Cache);
- }
- if (Cand.end() == true)
- return helper.canNotFindCandidateVer(Cache, Pkg);
- return Cand;
-}
- /*}}}*/
-// getInstalledVer - Returns the installed version of the given package /*{{{*/
-pkgCache::VerIterator VersionSet::getInstalledVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
- if (Pkg->CurrentVer == 0)
- return helper.canNotFindInstalledVer(Cache, Pkg);
- return Pkg.CurrentVer();
-}
- /*}}}*/
-// canNotFindPkgName - handle the case no package has this name /*{{{*/
-pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
- std::string const &str) {
- if (ShowError == true)
- _error->Error(_("Unable to locate package %s"), str.c_str());
- return pkgCache::PkgIterator(Cache, 0);
-}
- /*}}}*/
-// canNotFindTask - handle the case no package is found for a task /*{{{*/
-PackageSet CacheSetHelper::canNotFindTask(pkgCacheFile &Cache, std::string pattern) {
- if (ShowError == true)
- _error->Error(_("Couldn't find task '%s'"), pattern.c_str());
- return PackageSet();
-}
- /*}}}*/
-// canNotFindRegEx - handle the case no package is found by a regex /*{{{*/
-PackageSet CacheSetHelper::canNotFindRegEx(pkgCacheFile &Cache, std::string pattern) {
- if (ShowError == true)
- _error->Error(_("Couldn't find any package by regex '%s'"), pattern.c_str());
- return PackageSet();
-}
- /*}}}*/
-// canNotFindPackage - handle the case no package is found from a string/*{{{*/
-PackageSet CacheSetHelper::canNotFindPackage(pkgCacheFile &Cache, std::string const &str) {
- return PackageSet();
-}
- /*}}}*/
-// canNotFindAllVer /*{{{*/
-VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select versions from package '%s' as it purely virtual"), Pkg.FullName(true).c_str());
- return VersionSet();
-}
- /*}}}*/
-// canNotFindInstCandVer /*{{{*/
-VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
- return VersionSet();
-}
- /*}}}*/
-// canNotFindInstCandVer /*{{{*/
-VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
- return VersionSet();
-}
- /*}}}*/
-// canNotFindNewestVer /*{{{*/
-pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
- return pkgCache::VerIterator(Cache, 0);
-}
- /*}}}*/
-// canNotFindCandidateVer /*{{{*/
-pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
- return pkgCache::VerIterator(Cache, 0);
-}
- /*}}}*/
-// canNotFindInstalledVer /*{{{*/
-pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg) {
- if (ShowError == true)
- _error->Error(_("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str());
- return pkgCache::VerIterator(Cache, 0);
-}
- /*}}}*/
-}
diff --git a/cmdline/cacheset.h b/cmdline/cacheset.h
deleted file mode 100644
index c8c3dd096..000000000
--- a/cmdline/cacheset.h
+++ /dev/null
@@ -1,375 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-/** \file cacheset.h
- Wrappers around std::set to have set::iterators which behave
- similar to the Iterators of the cache structures.
-
- Provides also a few helper methods which work with these sets */
- /*}}}*/
-#ifndef APT_CACHESET_H
-#define APT_CACHESET_H
-// Include Files /*{{{*/
-#include <iostream>
-#include <fstream>
-#include <list>
-#include <map>
-#include <set>
-#include <string>
-
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/pkgcache.h>
- /*}}}*/
-namespace APT {
-class PackageSet;
-class VersionSet;
-class CacheSetHelper { /*{{{*/
-/** \class APT::CacheSetHelper
- Simple base class with a lot of virtual methods which can be overridden
- to alter the behavior or the output of the CacheSets.
-
- This helper is passed around by the static methods in the CacheSets and
- used every time they hit an error condition or something could be
- printed out.
-*/
-public: /*{{{*/
- CacheSetHelper(bool const &ShowError = true) : ShowError(ShowError) {};
- virtual ~CacheSetHelper() {};
-
- virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {};
- virtual void showRegExSelection(PackageSet const &pkgset, string const &pattern) {};
- virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
- string const &ver, bool const &verIsRel) {};
-
- virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str);
- virtual PackageSet canNotFindTask(pkgCacheFile &Cache, std::string pattern);
- virtual PackageSet canNotFindRegEx(pkgCacheFile &Cache, std::string pattern);
- virtual PackageSet canNotFindPackage(pkgCacheFile &Cache, std::string const &str);
- virtual VersionSet canNotFindAllVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
- virtual VersionSet canNotFindInstCandVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg);
- virtual VersionSet canNotFindCandInstVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg);
- virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg);
- virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg);
- virtual pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg);
-
- bool showErrors() const { return ShowError; };
- bool showErrors(bool const &newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); };
- /*}}}*/
-protected:
- bool ShowError;
-}; /*}}}*/
-class PackageSet : public std::set<pkgCache::PkgIterator> { /*{{{*/
-/** \class APT::PackageSet
-
- Simple wrapper around a std::set to provide a similar interface to
- a set of packages as to the complete set of all packages in the
- pkgCache. */
-public: /*{{{*/
- /** \brief smell like a pkgCache::PkgIterator */
- class const_iterator : public std::set<pkgCache::PkgIterator>::const_iterator {/*{{{*/
- public:
- const_iterator(std::set<pkgCache::PkgIterator>::const_iterator x) :
- std::set<pkgCache::PkgIterator>::const_iterator(x) {}
-
- operator pkgCache::PkgIterator(void) { return **this; }
-
- inline const char *Name() const {return (**this).Name(); }
- inline std::string FullName(bool const &Pretty) const { return (**this).FullName(Pretty); }
- inline std::string FullName() const { return (**this).FullName(); }
- inline const char *Section() const {return (**this).Section(); }
- inline bool Purge() const {return (**this).Purge(); }
- inline const char *Arch() const {return (**this).Arch(); }
- inline pkgCache::GrpIterator Group() const { return (**this).Group(); }
- inline pkgCache::VerIterator VersionList() const { return (**this).VersionList(); }
- inline pkgCache::VerIterator CurrentVer() const { return (**this).CurrentVer(); }
- inline pkgCache::DepIterator RevDependsList() const { return (**this).RevDependsList(); }
- inline pkgCache::PrvIterator ProvidesList() const { return (**this).ProvidesList(); }
- inline pkgCache::PkgIterator::OkState State() const { return (**this).State(); }
- inline const char *CandVersion() const { return (**this).CandVersion(); }
- inline const char *CurVersion() const { return (**this).CurVersion(); }
- inline pkgCache *Cache() const { return (**this).Cache(); };
- inline unsigned long Index() const {return (**this).Index();};
- // we have only valid iterators here
- inline bool end() const { return false; };
-
- friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, (*i)); }
-
- inline pkgCache::Package const * operator->() const {
- return &***this;
- };
- };
- // 103. set::iterator is required to be modifiable, but this allows modification of keys
- typedef APT::PackageSet::const_iterator iterator;
- /*}}}*/
-
- using std::set<pkgCache::PkgIterator>::insert;
- inline void insert(pkgCache::PkgIterator const &P) { if (P.end() == false) std::set<pkgCache::PkgIterator>::insert(P); };
- inline void insert(PackageSet const &pkgset) { insert(pkgset.begin(), pkgset.end()); };
-
- /** \brief returns all packages in the cache who belong to the given task
-
- A simple helper responsible for search for all members of a task
- in the cache. Optional it prints a a notice about the
- packages chosen cause of the given task.
- \param Cache the packages are in
- \param pattern name of the task
- \param helper responsible for error and message handling */
- static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
- static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string const &pattern) {
- CacheSetHelper helper;
- return APT::PackageSet::FromTask(Cache, pattern, helper);
- }
-
- /** \brief returns all packages in the cache whose name matchs a given pattern
-
- A simple helper responsible for executing a regular expression on all
- package names in the cache. Optional it prints a a notice about the
- packages chosen cause of the given package.
- \param Cache the packages are in
- \param pattern regular expression for package names
- \param helper responsible for error and message handling */
- static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
- static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string const &pattern) {
- CacheSetHelper helper;
- return APT::PackageSet::FromRegEx(Cache, pattern, helper);
- }
-
- /** \brief returns all packages specified by a string
-
- \param Cache the packages are in
- \param string String the package name(s) should be extracted from
- \param helper responsible for error and message handling */
- static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
- static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string) {
- CacheSetHelper helper;
- return APT::PackageSet::FromString(Cache, string, helper);
- }
-
- /** \brief returns a package specified by a string
-
- \param Cache the package is in
- \param string String the package name should be extracted from
- \param helper responsible for error and message handling */
- static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
- static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string) {
- CacheSetHelper helper;
- return APT::PackageSet::FromName(Cache, string, helper);
- }
-
- /** \brief returns all packages specified on the commandline
-
- Get all package names from the commandline and executes regex's if needed.
- No special package command is supported, just plain names.
- \param Cache the packages are in
- \param cmdline Command line the package names should be extracted from
- \param helper responsible for error and message handling */
- static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper);
- static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
- CacheSetHelper helper;
- return APT::PackageSet::FromCommandLine(Cache, cmdline, helper);
- }
-
- struct Modifier {
- enum Position { NONE, PREFIX, POSTFIX };
- unsigned short ID;
- const char * const Alias;
- Position Pos;
- Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {};
- };
-
- /** \brief group packages by a action modifiers
-
- At some point it is needed to get from the same commandline
- different package sets grouped by a modifier. Take
- apt-get install apt awesome-
- as an example.
- \param Cache the packages are in
- \param cmdline Command line the package names should be extracted from
- \param mods list of modifiers the method should accept
- \param fallback the default modifier group for a package
- \param helper responsible for error and message handling */
- static std::map<unsigned short, PackageSet> GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<PackageSet::Modifier> const &mods,
- unsigned short const &fallback, CacheSetHelper &helper);
- static std::map<unsigned short, PackageSet> GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<PackageSet::Modifier> const &mods,
- unsigned short const &fallback) {
- CacheSetHelper helper;
- return APT::PackageSet::GroupedFromCommandLine(Cache, cmdline,
- mods, fallback, helper);
- }
-
- enum Constructor { UNKNOWN, REGEX, TASK };
- Constructor getConstructor() const { return ConstructedBy; };
-
- PackageSet() : ConstructedBy(UNKNOWN) {};
- PackageSet(Constructor const &by) : ConstructedBy(by) {};
- /*}}}*/
-private: /*{{{*/
- Constructor ConstructedBy;
- /*}}}*/
-}; /*}}}*/
-class VersionSet : public std::set<pkgCache::VerIterator> { /*{{{*/
-/** \class APT::VersionSet
-
- Simple wrapper around a std::set to provide a similar interface to
- a set of versions as to the complete set of all versions in the
- pkgCache. */
-public: /*{{{*/
- /** \brief smell like a pkgCache::VerIterator */
- class const_iterator : public std::set<pkgCache::VerIterator>::const_iterator {/*{{{*/
- public:
- const_iterator(std::set<pkgCache::VerIterator>::const_iterator x) :
- std::set<pkgCache::VerIterator>::const_iterator(x) {}
-
- operator pkgCache::VerIterator(void) { return **this; }
-
- inline pkgCache *Cache() const { return (**this).Cache(); };
- inline unsigned long Index() const {return (**this).Index();};
- // we have only valid iterators here
- inline bool end() const { return false; };
-
- inline pkgCache::Version const * operator->() const {
- return &***this;
- };
-
- inline int CompareVer(const pkgCache::VerIterator &B) const { return (**this).CompareVer(B); };
- inline const char *VerStr() const { return (**this).VerStr(); };
- inline const char *Section() const { return (**this).Section(); };
- inline const char *Arch() const { return (**this).Arch(); };
- inline const char *Arch(bool const pseudo) const { return (**this).Arch(pseudo); };
- inline pkgCache::PkgIterator ParentPkg() const { return (**this).ParentPkg(); };
- inline pkgCache::DescIterator DescriptionList() const { return (**this).DescriptionList(); };
- inline pkgCache::DescIterator TranslatedDescription() const { return (**this).TranslatedDescription(); };
- inline pkgCache::DepIterator DependsList() const { return (**this).DependsList(); };
- inline pkgCache::PrvIterator ProvidesList() const { return (**this).ProvidesList(); };
- inline pkgCache::VerFileIterator FileList() const { return (**this).FileList(); };
- inline bool Downloadable() const { return (**this).Downloadable(); };
- inline const char *PriorityType() const { return (**this).PriorityType(); };
- inline string RelStr() const { return (**this).RelStr(); };
- inline bool Automatic() const { return (**this).Automatic(); };
- inline bool Pseudo() const { return (**this).Pseudo(); };
- inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); };
- };
- /*}}}*/
- // 103. set::iterator is required to be modifiable, but this allows modification of keys
- typedef APT::VersionSet::const_iterator iterator;
-
- using std::set<pkgCache::VerIterator>::insert;
- inline void insert(pkgCache::VerIterator const &V) { if (V.end() == false) std::set<pkgCache::VerIterator>::insert(V); };
- inline void insert(VersionSet const &verset) { insert(verset.begin(), verset.end()); };
-
- /** \brief specifies which version(s) will be returned if non is given */
- enum Version {
- /** All versions */
- ALL,
- /** Candidate and installed version */
- CANDANDINST,
- /** Candidate version */
- CANDIDATE,
- /** Installed version */
- INSTALLED,
- /** Candidate or if non installed version */
- CANDINST,
- /** Installed or if non candidate version */
- INSTCAND,
- /** Newest version */
- NEWEST
- };
-
- /** \brief returns all versions specified on the commandline
-
- Get all versions from the commandline, uses given default version if
- non specifically requested and executes regex's if needed on names.
- \param Cache the packages and versions are in
- \param cmdline Command line the versions should be extracted from
- \param helper responsible for error and message handling */
- static APT::VersionSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
- APT::VersionSet::Version const &fallback, CacheSetHelper &helper);
- static APT::VersionSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
- APT::VersionSet::Version const &fallback) {
- CacheSetHelper helper;
- return APT::VersionSet::FromCommandLine(Cache, cmdline, fallback, helper);
- }
- static APT::VersionSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
- return APT::VersionSet::FromCommandLine(Cache, cmdline, CANDINST);
- }
-
- static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg,
- APT::VersionSet::Version const &fallback, CacheSetHelper &helper,
- bool const &onlyFromName = false);
- static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg,
- APT::VersionSet::Version const &fallback) {
- CacheSetHelper helper;
- return APT::VersionSet::FromString(Cache, pkg, fallback, helper);
- }
- static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg) {
- return APT::VersionSet::FromString(Cache, pkg, CANDINST);
- }
-
- /** \brief returns all versions specified for the package
-
- \param Cache the package and versions are in
- \param P the package in question
- \param fallback the version(s) you want to get
- \param helper the helper used for display and error handling */
- static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
- VersionSet::Version const &fallback, CacheSetHelper &helper);
- static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
- APT::VersionSet::Version const &fallback) {
- CacheSetHelper helper;
- return APT::VersionSet::FromPackage(Cache, P, fallback, helper);
- }
- static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) {
- return APT::VersionSet::FromPackage(Cache, P, CANDINST);
- }
-
- struct Modifier {
- enum Position { NONE, PREFIX, POSTFIX };
- unsigned short ID;
- const char * const Alias;
- Position Pos;
- VersionSet::Version SelectVersion;
- Modifier (unsigned short const &id, const char * const alias, Position const &pos,
- VersionSet::Version const &select) : ID(id), Alias(alias), Pos(pos),
- SelectVersion(select) {};
- };
-
- static std::map<unsigned short, VersionSet> GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<VersionSet::Modifier> const &mods,
- unsigned short const &fallback, CacheSetHelper &helper);
- static std::map<unsigned short, VersionSet> GroupedFromCommandLine(
- pkgCacheFile &Cache, const char **cmdline,
- std::list<VersionSet::Modifier> const &mods,
- unsigned short const &fallback) {
- CacheSetHelper helper;
- return APT::VersionSet::GroupedFromCommandLine(Cache, cmdline,
- mods, fallback, helper);
- }
- /*}}}*/
-protected: /*{{{*/
-
- /** \brief returns the candidate version of the package
-
- \param Cache to be used to query for information
- \param Pkg we want the candidate version from this package */
- static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
-
- /** \brief returns the installed version of the package
-
- \param Cache to be used to query for information
- \param Pkg we want the installed version from this package */
- static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
- pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
- /*}}}*/
-}; /*}}}*/
-}
-#endif
diff --git a/cmdline/makefile b/cmdline/makefile
index 4ffe49ee0..917ccc96a 100644
--- a/cmdline/makefile
+++ b/cmdline/makefile
@@ -9,14 +9,14 @@ include ../buildlib/defaults.mak
PROGRAM=apt-cache
SLIBS = -lapt-pkg $(INTLLIBS)
LIB_MAKES = apt-pkg/makefile
-SOURCE = apt-cache.cc cacheset.cc
+SOURCE = apt-cache.cc
include $(PROGRAM_H)
# The apt-get program
PROGRAM=apt-get
SLIBS = -lapt-pkg -lutil $(INTLLIBS)
LIB_MAKES = apt-pkg/makefile
-SOURCE = apt-get.cc acqprogress.cc cacheset.cc
+SOURCE = apt-get.cc acqprogress.cc
include $(PROGRAM_H)
# The apt-config program