summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-07-30 09:51:42 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-07-30 09:51:42 +0200
commitcd7bbc479f8e2f277092a9557bb486ab664deba6 (patch)
tree4c3a5ed40727d193920203d57f1b9fea09d0afd8
parent4ed3806e625a4b5c148e27dba5384f133dd77c1a (diff)
- [ABI BREAK] add an ErrorType option to CacheSetHelper
* cmdline/apt-cache.cc: - use Notice instead of Error in the CacheSetHelper messages for compat reasons. Otherwise tools like sbuild blow up
-rw-r--r--apt-pkg/cacheset.cc18
-rw-r--r--apt-pkg/cacheset.h16
-rw-r--r--apt-pkg/contrib/error.cc16
-rw-r--r--apt-pkg/contrib/error.h16
-rw-r--r--cmdline/apt-cache.cc24
-rw-r--r--debian/changelog14
6 files changed, 81 insertions, 23 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index 84021a2b7..bbfdfd4f2 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -437,21 +437,21 @@ pkgCache::VerIterator VersionSet::getInstalledVer(pkgCacheFile &Cache,
pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
std::string const &str) {
if (ShowError == true)
- _error->Error(_("Unable to locate package %s"), str.c_str());
+ _error->Insert(ErrorType, _("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());
+ _error->Insert(ErrorType, _("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());
+ _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
return PackageSet();
}
/*}}}*/
@@ -464,7 +464,7 @@ PackageSet CacheSetHelper::canNotFindPackage(pkgCacheFile &Cache, std::string co
VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg) {
if (ShowError == true)
- _error->Notice(_("Can't select versions from package '%s' as it purely virtual"), Pkg.FullName(true).c_str());
+ _error->Insert(ErrorType, _("Can't select versions from package '%s' as it purely virtual"), Pkg.FullName(true).c_str());
return VersionSet();
}
/*}}}*/
@@ -472,7 +472,7 @@ VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
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());
+ _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
return VersionSet();
}
/*}}}*/
@@ -480,7 +480,7 @@ VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache,
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());
+ _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
return VersionSet();
}
/*}}}*/
@@ -488,7 +488,7 @@ VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache,
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());
+ _error->Insert(ErrorType, _("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
return pkgCache::VerIterator(Cache, 0);
}
/*}}}*/
@@ -496,7 +496,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
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());
+ _error->Insert(ErrorType, _("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
return pkgCache::VerIterator(Cache, 0);
}
/*}}}*/
@@ -504,7 +504,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache
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());
+ _error->Insert(ErrorType, _("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/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index c8c3dd096..3f4f0066b 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -32,7 +32,9 @@ class CacheSetHelper { /*{{{*/
printed out.
*/
public: /*{{{*/
- CacheSetHelper(bool const &ShowError = true) : ShowError(ShowError) {};
+ CacheSetHelper(bool const &ShowError = true,
+ GlobalError::MsgType ErrorType = GlobalError::ERROR) :
+ ShowError(ShowError), ErrorType(ErrorType) {};
virtual ~CacheSetHelper() {};
virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {};
@@ -58,9 +60,21 @@ public: /*{{{*/
bool showErrors() const { return ShowError; };
bool showErrors(bool const &newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); };
+ GlobalError::MsgType errorType() const { return ErrorType; };
+ GlobalError::MsgType errorType(GlobalError::MsgType const &newValue)
+ {
+ if (ErrorType == newValue) return ErrorType;
+ else {
+ GlobalError::MsgType const &oldValue = ErrorType;
+ ErrorType = newValue;
+ return oldValue;
+ }
+ };
+
/*}}}*/
protected:
bool ShowError;
+ GlobalError::MsgType ErrorType;
}; /*}}}*/
class PackageSet : public std::set<pkgCache::PkgIterator> { /*{{{*/
/** \class APT::PackageSet
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index d63b06d13..e2e8d6e57 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -92,6 +92,14 @@ bool GlobalError::DebugE(const char *Function,const char *Description,...) {
return InsertErrno(DEBUG, Function, Description, args);
}
/*}}}*/
+// GlobalError::InsertErrno - Get part of the errortype string from errno/*{{{*/
+bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
+ const char *Description,...) {
+ va_list args;
+ va_start(args,Description);
+ return InsertErrno(type, Function, Description, args);
+}
+ /*}}}*/
// GlobalError::InsertErrno - formats an error message with the errno /*{{{*/
bool GlobalError::InsertErrno(MsgType type, const char* Function,
const char* Description, va_list &args) {
@@ -138,6 +146,14 @@ bool GlobalError::Debug(const char *Description,...)
return Insert(DEBUG, Description, args);
}
/*}}}*/
+// GlobalError::Insert - Add a errotype message to the list /*{{{*/
+bool GlobalError::Insert(MsgType const &type, const char *Description,...)
+{
+ va_list args;
+ va_start(args,Description);
+ return Insert(type, Description, args);
+}
+ /*}}}*/
// GlobalError::Insert - Insert a new item at the end /*{{{*/
bool GlobalError::Insert(MsgType type, const char* Description,
va_list &args) {
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index 4af0302c0..ae756dbc4 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -114,6 +114,15 @@ public: /*{{{*/
*/
bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ /** \brief adds an errno message with the given type
+ *
+ * \param type of the error message
+ * \param Function which failed
+ * \param Description of the error
+ */
+ bool InsertErrno(MsgType const &type, const char* Function,
+ const char* Description,...) __like_printf(4) __cold;
+
/** \brief add an fatal error message to the list
*
* Most of the stuff we consider as "error" is also "fatal" for
@@ -169,6 +178,13 @@ public: /*{{{*/
*/
bool Debug(const char *Description,...) __like_printf(2) __cold;
+ /** \brief adds an error message with the given type
+ *
+ * \param type of the error message
+ * \param Description of the error
+ */
+ bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold;
+
/** \brief is an error in the list?
*
* \return \b true if an error is included in the list, \b false otherwise
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 70732e4d0..2a4e200a7 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -173,7 +173,9 @@ bool UnMet(CommandLine &CmdL)
}
else
{
- APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+ APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1,
+ APT::VersionSet::CANDIDATE, helper);
for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
if (ShowUnMet(V, Important) == false)
return false;
@@ -187,7 +189,8 @@ bool UnMet(CommandLine &CmdL)
bool DumpPackage(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+ APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
@@ -566,7 +569,7 @@ public:
return pkgCache::VerIterator(Cache, 0);
}
- CacheSetHelperDepends() : CacheSetHelper(false) {}
+ CacheSetHelperDepends() : CacheSetHelper(false, GlobalError::NOTICE) {}
};
bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
{
@@ -754,11 +757,12 @@ bool XVcg(CommandLine &CmdL)
}
// Load the list of packages from the command line into the show list
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
std::list<APT::PackageSet::Modifier> mods;
mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
std::map<unsigned short, APT::PackageSet> pkgsets =
- APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+ APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0, helper);
for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
Pkg != pkgsets[0].end(); ++Pkg)
@@ -968,11 +972,12 @@ bool Dotty(CommandLine &CmdL)
}
// Load the list of packages from the command line into the show list
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
std::list<APT::PackageSet::Modifier> mods;
mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
std::map<unsigned short, APT::PackageSet> pkgsets =
- APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+ APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0, helper);
for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
Pkg != pkgsets[0].end(); ++Pkg)
@@ -1403,9 +1408,10 @@ bool ShowAuto(CommandLine &CmdL)
bool ShowPackage(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
- APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select);
+ APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
if (DisplayRecord(CacheFile, Ver) == false)
return false;
@@ -1564,7 +1570,8 @@ bool Policy(CommandLine &CmdL)
(InstalledLessCandidate > 0 ? (InstalledLessCandidate) : 0) - 1;
// Print out detailed information for each package
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+ APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
for (APT::PackageSet::const_iterator I = pkgset.begin(); I != pkgset.end(); ++I)
{
pkgCache::PkgIterator Pkg = I.Group().FindPkg("any");
@@ -1644,7 +1651,8 @@ bool Madison(CommandLine &CmdL)
if (_error->PendingError() == true)
_error->Discard();
- APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1);
+ APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+ APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
if (Pkg.end() == false)
diff --git a/debian/changelog b/debian/changelog
index d6bfa76ee..bd3400d2b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,13 +1,17 @@
apt (0.7.26~exp12) UNRELEASEDexperimental; urgency=low
+ [ Michael Vogt ]
* debian/control:
- add dependency on zlib-dev for libapt-pkg-dev
- * apt-pkg/cacheset.cc:
- - make CacheSetHelper::canNotFindAllVer display a notice
- only (for compat reasons). Otherwise tools like sbuild
- blow up
- -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 29 Jul 2010 23:45:42 +0200
+ [ David Kalnischkies ]
+ * apt-pkg/cacheset.cc:
+ - [ABI BREAK] add an ErrorType option to CacheSetHelper
+ * cmdline/apt-cache.cc:
+ - use Notice instead of Error in the CacheSetHelper messages
+ for compat reasons. Otherwise tools like sbuild blow up
+
+ -- David Kalnischkies <kalnischkies@gmail.com> Fri, 30 Jul 2010 09:48:04 +0200
apt (0.7.26~exp11) experimental; urgency=low