Sfoglia il codice sorgente

- [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 16 anni fa
parent
commit
cd7bbc479f
6 ha cambiato i file con 81 aggiunte e 23 eliminazioni
  1. 9 9
      apt-pkg/cacheset.cc
  2. 15 1
      apt-pkg/cacheset.h
  3. 16 0
      apt-pkg/contrib/error.cc
  4. 16 0
      apt-pkg/contrib/error.h
  5. 16 8
      cmdline/apt-cache.cc
  6. 9 5
      debian/changelog

+ 9 - 9
apt-pkg/cacheset.cc

@@ -437,21 +437,21 @@ pkgCache::VerIterator VersionSet::getInstalledVer(pkgCacheFile &Cache,
 pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
 pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
 			std::string const &str) {
 			std::string const &str) {
 	if (ShowError == true)
 	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);
 	return pkgCache::PkgIterator(Cache, 0);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindTask - handle the case no package is found for a task	/*{{{*/
 // canNotFindTask - handle the case no package is found for a task	/*{{{*/
 PackageSet CacheSetHelper::canNotFindTask(pkgCacheFile &Cache, std::string pattern) {
 PackageSet CacheSetHelper::canNotFindTask(pkgCacheFile &Cache, std::string pattern) {
 	if (ShowError == true)
 	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();
 	return PackageSet();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindRegEx - handle the case no package is found by a regex	/*{{{*/
 // canNotFindRegEx - handle the case no package is found by a regex	/*{{{*/
 PackageSet CacheSetHelper::canNotFindRegEx(pkgCacheFile &Cache, std::string pattern) {
 PackageSet CacheSetHelper::canNotFindRegEx(pkgCacheFile &Cache, std::string pattern) {
 	if (ShowError == true)
 	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();
 	return PackageSet();
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -464,7 +464,7 @@ PackageSet CacheSetHelper::canNotFindPackage(pkgCacheFile &Cache, std::string co
 VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
 VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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();
 	return VersionSet();
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -472,7 +472,7 @@ VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache,
 VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache,
 VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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();
 	return VersionSet();
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -480,7 +480,7 @@ VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache,
 VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache,
 VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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();
 	return VersionSet();
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -488,7 +488,7 @@ VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache,
 pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
 pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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);
 	return pkgCache::VerIterator(Cache, 0);
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -496,7 +496,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
 pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache,
 pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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);
 	return pkgCache::VerIterator(Cache, 0);
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -504,7 +504,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache
 pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache,
 pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	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);
 	return pkgCache::VerIterator(Cache, 0);
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 15 - 1
apt-pkg/cacheset.h

@@ -32,7 +32,9 @@ class CacheSetHelper {							/*{{{*/
     printed out.
     printed out.
 */
 */
 public:									/*{{{*/
 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 ~CacheSetHelper() {};
 
 
 	virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {};
 	virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {};
@@ -58,9 +60,21 @@ public:									/*{{{*/
 
 
 	bool showErrors() const { return ShowError; };
 	bool showErrors() const { return ShowError; };
 	bool showErrors(bool const &newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); };
 	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:
 protected:
 	bool ShowError;
 	bool ShowError;
+	GlobalError::MsgType ErrorType;
 };									/*}}}*/
 };									/*}}}*/
 class PackageSet : public std::set<pkgCache::PkgIterator> {		/*{{{*/
 class PackageSet : public std::set<pkgCache::PkgIterator> {		/*{{{*/
 /** \class APT::PackageSet
 /** \class APT::PackageSet

+ 16 - 0
apt-pkg/contrib/error.cc

@@ -92,6 +92,14 @@ bool GlobalError::DebugE(const char *Function,const char *Description,...) {
 	return InsertErrno(DEBUG, Function, Description, args);
 	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	/*{{{*/
 // GlobalError::InsertErrno - formats an error message with the errno	/*{{{*/
 bool GlobalError::InsertErrno(MsgType type, const char* Function,
 bool GlobalError::InsertErrno(MsgType type, const char* Function,
 			      const char* Description, va_list &args) {
 			      const char* Description, va_list &args) {
@@ -138,6 +146,14 @@ bool GlobalError::Debug(const char *Description,...)
 	return Insert(DEBUG, Description, args);
 	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			/*{{{*/
 // GlobalError::Insert - Insert a new item at the end			/*{{{*/
 bool GlobalError::Insert(MsgType type, const char* Description,
 bool GlobalError::Insert(MsgType type, const char* Description,
 			 va_list &args) {
 			 va_list &args) {

+ 16 - 0
apt-pkg/contrib/error.h

@@ -114,6 +114,15 @@ public:									/*{{{*/
 	 */
 	 */
 	bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold;
 	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
 	/** \brief add an fatal error message to the list
 	 *
 	 *
 	 *  Most of the stuff we consider as "error" is also "fatal" for
 	 *  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;
 	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?
 	/** \brief is an error in the list?
 	 *
 	 *
 	 *  \return \b true if an error is included in the list, \b false otherwise
 	 *  \return \b true if an error is included in the list, \b false otherwise

+ 16 - 8
cmdline/apt-cache.cc

@@ -173,7 +173,9 @@ bool UnMet(CommandLine &CmdL)
    }
    }
    else
    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)
       for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
 	 if (ShowUnMet(V, Important) == false)
 	 if (ShowUnMet(V, Important) == false)
 	    return false;
 	    return false;
@@ -187,7 +189,8 @@ bool UnMet(CommandLine &CmdL)
 bool DumpPackage(CommandLine &CmdL)
 bool DumpPackage(CommandLine &CmdL)
 {
 {
    pkgCacheFile CacheFile;
    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)
    for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
@@ -566,7 +569,7 @@ public:
       return pkgCache::VerIterator(Cache, 0);
       return pkgCache::VerIterator(Cache, 0);
    }
    }
 
 
-   CacheSetHelperDepends() : CacheSetHelper(false) {}
+   CacheSetHelperDepends() : CacheSetHelper(false, GlobalError::NOTICE) {}
 };
 };
 bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
 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
    // 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;
    std::list<APT::PackageSet::Modifier> mods;
    mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
    std::map<unsigned short, APT::PackageSet> pkgsets =
    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();
    for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
 	Pkg != pkgsets[0].end(); ++Pkg)
 	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
    // 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;
    std::list<APT::PackageSet::Modifier> mods;
    mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
    mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
    std::map<unsigned short, APT::PackageSet> pkgsets =
    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();
    for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
 	Pkg != pkgsets[0].end(); ++Pkg)
 	Pkg != pkgsets[0].end(); ++Pkg)
@@ -1403,9 +1408,10 @@ bool ShowAuto(CommandLine &CmdL)
 bool ShowPackage(CommandLine &CmdL)
 bool ShowPackage(CommandLine &CmdL)
 {
 {
    pkgCacheFile CacheFile;
    pkgCacheFile CacheFile;
+   APT::CacheSetHelper helper(true, GlobalError::NOTICE);
    APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
    APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
 			APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
 			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)
    for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
       if (DisplayRecord(CacheFile, Ver) == false)
       if (DisplayRecord(CacheFile, Ver) == false)
 	 return false;
 	 return false;
@@ -1564,7 +1570,8 @@ bool Policy(CommandLine &CmdL)
 		(InstalledLessCandidate > 0 ? (InstalledLessCandidate) : 0) - 1;
 		(InstalledLessCandidate > 0 ? (InstalledLessCandidate) : 0) - 1;
 
 
    // Print out detailed information for each package
    // 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)
    for (APT::PackageSet::const_iterator I = pkgset.begin(); I != pkgset.end(); ++I)
    {
    {
       pkgCache::PkgIterator Pkg = I.Group().FindPkg("any");
       pkgCache::PkgIterator Pkg = I.Group().FindPkg("any");
@@ -1644,7 +1651,8 @@ bool Madison(CommandLine &CmdL)
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       _error->Discard();
       _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)
    for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
    {
       if (Pkg.end() == false)
       if (Pkg.end() == false)

+ 9 - 5
debian/changelog

@@ -1,13 +1,17 @@
 apt (0.7.26~exp12) UNRELEASEDexperimental; urgency=low
 apt (0.7.26~exp12) UNRELEASEDexperimental; urgency=low
 
 
+  [ Michael Vogt ]
   * debian/control:
   * debian/control:
     - add dependency on zlib-dev for libapt-pkg-dev
     - 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
 apt (0.7.26~exp11) experimental; urgency=low