]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
drop privileges in file:// method as we do for decompressors
[apt.git] / cmdline / apt-cache.cc
index 117a4429235c07aad383f6ec692086b0c2a806a8..2db25135070f6a36d393c2fde92f850aaec05d27 100644 (file)
@@ -310,10 +310,16 @@ static void ShowHashTableStats(std::string Type,
 // Stats - Dump some nice statistics                                   /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-static bool Stats(CommandLine &)
+static bool Stats(CommandLine &CmdL)
 {
+   if (CmdL.FileSize() > 1) {
+      _error->Error(_("apt-cache stats does not take any arguments"));
+      return false;
+   }
+
    pkgCacheFile CacheFile;
    pkgCache *Cache = CacheFile.GetPkgCache();
+
    if (unlikely(Cache == NULL))
       return false;
 
@@ -719,7 +725,6 @@ static bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
               continue;
 
            pkgCache::PkgIterator Trg = RevDepends ? D.ParentPkg() : D.TargetPkg();
-           bool const showNoArch = RevDepends || (D->CompareOp & pkgCache::Dep::ArchSpecific) != pkgCache::Dep::ArchSpecific;
 
            if((Installed && Trg->CurrentVer != 0) || !Installed)
              {
@@ -733,9 +738,9 @@ static bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
                if (ShowDepType == true)
                  cout << D.DepType() << ": ";
                if (Trg->VersionList == 0)
-                 cout << "<" << Trg.FullName(showNoArch) << ">";
+                 cout << "<" << Trg.FullName(true) << ">";
                else
-                 cout << Trg.FullName(showNoArch);
+                 cout << Trg.FullName(true);
                if (ShowVersion == true && D->Version != 0)
                   cout << " (" << pkgCache::CompTypeDeb(D->CompareOp) << ' ' << D.TargetVer() << ')';
                cout << std::endl;
@@ -1327,6 +1332,7 @@ static bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
 struct ExDescFile
 {
    pkgCache::DescFile *Df;
+   pkgCache::VerIterator V;
    map_id_t ID;
 };
 
@@ -1412,6 +1418,7 @@ static bool Search(CommandLine &CmdL)
         if (D.end() == true)
            continue;
         DFList[G->ID].Df = D.FileList();
+        DFList[G->ID].V = V;
         DFList[G->ID].ID = G->ID;
       }
 
@@ -1431,11 +1438,12 @@ static bool Search(CommandLine &CmdL)
         if (D.end() == true)
            continue;
         DFList[id].Df = D.FileList();
+        DFList[id].V = V;
         DFList[id].ID = id;
 
         size_t const PrvPatternOffset = id * NumPatterns;
         for (unsigned I = 0; I < NumPatterns; ++I)
-           PatternMatch[PrvPatternOffset + I] = PatternMatch[PatternOffset + I];
+           PatternMatch[PrvPatternOffset + I] |= PatternMatch[PatternOffset + I];
       }
    }
 
@@ -1472,13 +1480,7 @@ static bool Search(CommandLine &CmdL)
       if (matchedAll == true)
       {
         if (ShowFull == true)
-        {
-           const char *Start;
-           const char *End;
-           P.GetRec(Start,End);
-           fwrite(Start,End-Start,1,stdout);
-           putc('\n',stdout);
-        }       
+           DisplayRecord(CacheFile, J->V);
         else
            printf("%s - %s\n",P.Name().c_str(),P.ShortDesc().c_str());
       }
@@ -1605,6 +1607,10 @@ static bool ShowSrcPackage(CommandLine &CmdL)
       pkgSrcRecords::Parser *Parse;
       unsigned found_this = 0;
       while ((Parse = SrcRecs.Find(*I,false)) != 0) {
+         // SrcRecs.Find() will find both binary and source names
+         if (_config->FindB("APT::Cache::Only-Source", false) == true)
+            if (Parse->Package() != *I)
+               continue;
         cout << Parse->AsStr() << endl;;
         found++;
         found_this++;