On 02/28/2014 01:26 AM, Boris Egorov wrote:
Hello folks.

I found a problem which triggers bug #498239. You can see it in src/cmdline/cmdline_do_action.cc:307 or at this long path: https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=aptitude/aptitude.git;a=blob;f=src/cmdline/cmdline_do_action.cc;h=8d0883797daee17666eb63f253e65bd841409c74;hb=0a2795f113e2588fc4c6b4091cf32ccff49e4974#l307

We do a two runs over all the packages if we have auto-install turned on (see comment). So we call function cmdline_applyaction from src/cmdline/cmdline_action.cc:221 twice (if we have one action as in bug inputs). This function at line 375 and overloaded one at line 582 triggers the bug.

How it should be fixed? All overloaded functions cmdline_applyaction has argument allow_auto which set to true if current iteration is not first. I think we can not to print warnings if allow_auto is true. What do you think?

Sorry if I'm doing something wrong, I haven't contributed to debian before. I found the bug thanks to how-can-i-help and want to fix it.

Double printing can appear in many cases, for example this command triggers it too:
# aptitude markauto 'lib'
This one can generate lots of duplicated output:
# aptitude markauto 'liblap'

Attached patch can solve parts of the problem mentioned above and in the bug report. Should we change all the conditions when warnings printed? Does it break something?

--
Best regards,
Boris Egorov

diff --git a/src/cmdline/cmdline_action.cc b/src/cmdline/cmdline_action.cc
index a499d19..04e5510 100644
--- a/src/cmdline/cmdline_action.cc
+++ b/src/cmdline/cmdline_action.cc
@@ -371,7 +371,7 @@ bool cmdline_applyaction(cmdline_pkgaction_type action,
 	  if(pkg.CurrentVer().end())
 	    printf(_("Package %s is not installed, cannot forbid an upgrade\n"),
                    pkg.FullName(true).c_str());
-	  else if(!pkg_state.Upgradable())
+	  else if(!pkg_state.Upgradable() && !allow_auto)
 	    printf(_("Package %s is not upgradable, cannot forbid an upgrade\n"),
                    pkg.FullName(true).c_str());
 	}
@@ -552,15 +552,18 @@ bool cmdline_applyaction(string s,
 
 	  if(!possible.empty())
 	    {
-	      // Don't overwhelm the user.
-	      if(possible.size()>40)
-		printf(_("Couldn't find package \"%s\", and more than 40\npackages contain \"%s\" in their name.\n"), package.c_str(), package.c_str());
-	      else
-		{
-		  printf(_("Couldn't find package \"%s\".  However, the following\npackages contain \"%s\" in their name:\n"), package.c_str(), package.c_str());
-		  cmdline_show_pkglist(possible, term_metrics);
+		  if(!allow_auto)
+		    {
+		    // Don't overwhelm the user.
+		    if(possible.size()>40)
+		      printf(_("Couldn't find package \"%s\", and more than 40\npackages contain \"%s\" in their name.\n"), package.c_str(), package.c_str());
+		    else
+		      {
+		        printf(_("Couldn't find package \"%s\".  However, the following\npackages contain \"%s\" in their name:\n"), package.c_str(), package.c_str());
+		        cmdline_show_pkglist(possible, term_metrics);
+		      }
+		    }
 		}
-	    }
 	  else
 	    {
 	      for(pkgCache::PkgIterator j=(*apt_cache_file)->PkgBegin();
@@ -578,14 +581,17 @@ bool cmdline_applyaction(string s,
 		    }
 		}
 
-	      if(possible.empty())
-		printf(_("Couldn't find any package whose name or description matched \"%s\"\n"), package.c_str());
-	      else if(possible.size()>40)
-		printf(_("Couldn't find any package matching \"%s\", and more than 40\npackages contain \"%s\" in their description.\n"), package.c_str(), package.c_str());
-	      else
+	      if(!allow_auto)
 		{
-		  printf(_("Couldn't find any package matching \"%s\".  However, the following\npackages contain \"%s\" in their description:\n"), package.c_str(), package.c_str());
-		  cmdline_show_pkglist(possible, term_metrics);
+		  if(possible.empty())
+		    printf(_("Couldn't find any package whose name or description matched \"%s\"\n"), package.c_str());
+		  else if(possible.size()>40)
+		    printf(_("Couldn't find any package matching \"%s\", and more than 40\npackages contain \"%s\" in their description.\n"), package.c_str(), package.c_str());
+		  else
+		    {
+		      printf(_("Couldn't find any package matching \"%s\".  However, the following\npackages contain \"%s\" in their description:\n"), package.c_str(), package.c_str());
+cmdline_show_pkglist(possible, term_metrics);
+		    }
 		}
 	    }
 

_______________________________________________
Aptitude-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/aptitude-devel

Reply via email to