]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-show.cc
support APT::Get::Build-Dep-Automatic again in build-dep
[apt.git] / apt-private / private-show.cc
index c2517e1301943dd1ccb82af702a95829cc1961c8..792c455a8285ecee38ed00fd2328e3e0822c4131 100644 (file)
@@ -299,6 +299,14 @@ bool ShowPackage(CommandLine &CmdL)                                        /*{{{*/
    return true;
 }
                                                                        /*}}}*/
+static std::string Sha1FromString(std::string const &input)            /*{{{*/
+{
+   // XXX: move to hashes.h: HashString::FromString() ?
+   SHA1Summation sha1;
+   sha1.Add(input.c_str(), input.length());
+   return sha1.Result().Value();
+}
+                                                                       /*}}}*/
 bool ShowSrcPackage(CommandLine &CmdL)                                 /*{{{*/
 {
    pkgCacheFile CacheFile;
@@ -312,6 +320,8 @@ bool ShowSrcPackage(CommandLine &CmdL)                                      /*{{{*/
       return false;
 
    bool found = false;
+   // avoid showing identical records
+   std::set<std::string> seen;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    {
       SrcRecs.Restart();
@@ -323,9 +333,14 @@ bool ShowSrcPackage(CommandLine &CmdL)                                     /*{{{*/
         if (_config->FindB("APT::Cache::Only-Source", false) == true)
            if (Parse->Package() != *I)
               continue;
-        std::cout << Parse->AsStr() << std::endl;;
-        found = true;
-        found_this = true;
+         std::string sha1str = Sha1FromString(Parse->AsStr());
+         if (std::find(seen.begin(), seen.end(), sha1str) == seen.end())
+         {
+            std::cout << Parse->AsStr() << std::endl;;
+            found = true;
+            found_this = true;
+            seen.insert(sha1str);
+         }
       }
       if (found_this == false) {
         _error->Warning(_("Unable to locate package %s"),*I);