}
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))
- return APT::PackageSet();
+ return APT::PackageSet(TASK);
- PackageSet pkgset;
+ PackageSet pkgset(TASK);
// 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)
- return PackageSet();
+ return PackageSet(REGEX);
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);
- return PackageSet();
+ return PackageSet(REGEX);
}
if (unlikely(Cache.GetPkgCache() == 0))
- return PackageSet();
+ return PackageSet(REGEX);
- PackageSet pkgset;
+ PackageSet pkgset(REGEX);
for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp)
{
if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0)
}
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) {
+ helper.canNotFindCandidateVer(Cache, P);
if (vertag == string::npos) {
verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
continue;
helper.showSelectedVersion(P, V, ver, verIsRel);
verset.insert(V);
}
+ if (pkgset.getConstructor() != PackageSet::UNKNOWN)
+ helper.showErrors(errors);
return verset;
}
/*}}}*/
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 /*{{{*/
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 /*{{{*/
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
- \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;
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;
\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;
\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;
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;
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,
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> { /*{{{*/
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,
\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);
+ 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 };