[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#742611: apt-cache: showsrc non-existent returning 0



¡Hola David!

El 2014-03-26 a las 16:38 +0100, David Kalnischkies escribió:
> So while this would make sense, we hadn't the energy to push this hard
> enough. I guess a plan would be to:
> 1. add an option (default disabled) to promote them to errors again
>    ( -o apt::some::thing=true/false can be added at will )
> 2. change sbuild, launchpad, … to use this option if needed
> 3. change the default of the option to enabled
> 4. add the option to all the software forgotten in 2.

> I would accept a patch for 1. in jessie, so that if all known things in
> 2. can get fixed (one way or the other) to cope with 3. in jessie+1, but
> that needs someone who wants to work on it… volunteers?

I've prepared another patch that adds the config option.

Care to review it?

Happy hacking,
-- 
"If you are in a hole, stop digging." -- The First Rule of Excavation
Saludos /\/\ /\ >< `/
commit 333644f0f6651b0e8201d8583855f4b5b19c5242
Author: Maximiliano Curia <maxy@debian.org>
Date:   Tue Sep 23 15:17:34 2014 +0200

    apt-cache showsrc non-existent return code
    
    Raise the message to error, and exit with a return code !=0 to make scripting
    easier. This functionality is disabled by default and depends on the
    APT::Cache::ShowSrcErrorOnNotFound configuration option, or the
    --error-on-not-found command line option to showsrc.

diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index a4490f5..fdc310c 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -64,7 +64,11 @@ static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char cons
    {
       addArg('i', "important", "APT::Cache::Important", 0);
    }
-   else if (CmdMatches("gencaches", "showsrc", "showpkg", "stats", "dump",
+   else if (CmdMatches("showsrc"))
+   {
+      addArg(0, "error-on-not-found", "APT::Cache::ShowSrcErrorOnNotFound", 0);
+   }
+   else if (CmdMatches("gencaches", "showpkg", "stats", "dump",
 	    "dumpavail", "showauto", "policy", "madison"))
       ;
    else
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index ac0d48a..77358ef 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1517,8 +1517,13 @@ static bool ShowSrcPackage(CommandLine &CmdL)
         continue;
       }
    }
-   if (found == 0)
+   if (found == 0) {
+      bool const Fail = _config->FindB("APT::Cache::ShowSrcErrorOnNotFound", false);
+      if (Fail)
+          return _error->Error(_("No packages found"));
+
       _error->Notice(_("No packages found"));
+   }
    return true;
 }
 									/*}}}*/

Attachment: signature.asc
Description: Digital signature


Reply to: