e.g. FromString to tell the caller if the string was an exact match
or found by regex or task. The two later ones can match packages for
which we want to ignore failures in the VersionSet
}
if (pattern[pattern.length() -1] != '^')
}
if (pattern[pattern.length() -1] != '^')
- return APT::PackageSet();
+ return APT::PackageSet(TASK);
pattern.erase(pattern.length()-1);
if (unlikely(Cache.GetPkgCache() == 0 || Cache.GetDepCache() == 0))
pattern.erase(pattern.length()-1);
if (unlikely(Cache.GetPkgCache() == 0 || Cache.GetDepCache() == 0))
- return APT::PackageSet();
+ return APT::PackageSet(TASK);
+ PackageSet pkgset(TASK);
// get the records
pkgRecords Recs(Cache);
// get the records
pkgRecords Recs(Cache);
PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
static const char * const isregex = ".?+*|[^$";
if (pattern.find_first_of(isregex) == std::string::npos)
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";
size_t archfound = pattern.find_last_of(':');
std::string arch = "native";
char Error[300];
regerror(Res, &Pattern, Error, sizeof(Error));
_error->Error(_("Regex compilation error - %s"), Error);
char Error[300];
regerror(Res, &Pattern, Error, sizeof(Error));
_error->Error(_("Regex compilation error - %s"), Error);
+ return PackageSet(REGEX);
}
if (unlikely(Cache.GetPkgCache() == 0))
}
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)
for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp)
{
if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0)
+ bool errors = true;
+ if (pkgset.getConstructor() != PackageSet::UNKNOWN)
+ errors = helper.showErrors(false);
for (PackageSet::const_iterator P = pkgset.begin();
P != pkgset.end(); ++P) {
for (PackageSet::const_iterator P = pkgset.begin();
P != pkgset.end(); ++P) {
+ helper.canNotFindCandidateVer(Cache, P);
if (vertag == string::npos) {
verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
continue;
if (vertag == string::npos) {
verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
continue;
helper.showSelectedVersion(P, V, ver, verIsRel);
verset.insert(V);
}
helper.showSelectedVersion(P, V, ver, verIsRel);
verset.insert(V);
}
+ if (pkgset.getConstructor() != PackageSet::UNKNOWN)
+ helper.showErrors(errors);
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());
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);
+ return pkgCache::VerIterator(Cache, 0);
}
/*}}}*/
// canNotFindCandidateVer /*{{{*/
}
/*}}}*/
// canNotFindCandidateVer /*{{{*/
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());
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);
+ return pkgCache::VerIterator(Cache, 0);
}
/*}}}*/
// canNotFindInstalledVer /*{{{*/
}
/*}}}*/
// canNotFindInstalledVer /*{{{*/
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());
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);
+ return pkgCache::VerIterator(Cache, 0);
packages chosen cause of the given task.
\param Cache the packages are in
\param pattern name of the task
packages chosen cause of the given task.
\param Cache the packages are in
\param pattern name of the task
- \param out stream to print the notice to */
+ \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;
static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string const &pattern) {
CacheSetHelper helper;
packages chosen cause of the given package.
\param Cache the packages are in
\param pattern regular expression for package names
packages chosen cause of the given package.
\param Cache the packages are in
\param pattern regular expression for package names
- \param out stream to print the notice to */
+ \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;
static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string const &pattern) {
CacheSetHelper helper;
\param Cache the packages are in
\param string String the package name(s) should be extracted from
\param Cache the packages are in
\param string String the package name(s) should be extracted from
- \param out stream to print various notices to */
+ \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;
static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string) {
CacheSetHelper helper;
\param Cache the package is in
\param string String the package name should be extracted from
\param Cache the package is in
\param string String the package name should be extracted from
- \param out stream to print various notices to */
+ \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;
static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string) {
CacheSetHelper helper;
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
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 out stream to print various notices to */
+ \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;
static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper);
static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
CacheSetHelper helper;
Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(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,
static std::map<unsigned short, PackageSet> GroupedFromCommandLine(
pkgCacheFile &Cache, const char **cmdline,
std::list<PackageSet::Modifier> const &mods,
return APT::PackageSet::GroupedFromCommandLine(Cache, cmdline,
mods, fallback, 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 VersionSet : public std::set<pkgCache::VerIterator> { /*{{{*/
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
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 out stream to print various notices to */
+ \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,
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,
\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 */
\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 VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
+ static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
VersionSet::Version const &fallback, CacheSetHelper &helper);
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 };
struct Modifier {
enum Position { NONE, PREFIX, POSTFIX };