summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 17:04:45 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 17:04:45 +0000
commitbd3d53eff6e951c6546dde623ccd9eb489610a0f (patch)
tree50a27877fb663fe3acb9211f10a0b0ec2d0eda3c /cmdline
parentcc74210843bbaddc0407a579414d8a8caa2501e6 (diff)
* Add an "apt-cache madison" command with an output for...
Author: mdz Date: 2004-01-04 07:41:52 GMT * Add an "apt-cache madison" command with an output format similar to the katie tool of the same name (but less functionality)
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc69
1 files changed, 68 insertions, 1 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 00a2c6883..a8db900a1 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.69 2003/12/20 22:56:14 mdz Exp $
+// $Id: apt-cache.cc,v 1.70 2004/01/04 07:41:52 mdz Exp $
/* ######################################################################
apt-cache - Manages the cache files
@@ -37,6 +37,8 @@
#include <errno.h>
#include <regex.h>
#include <stdio.h>
+
+#include <iomanip>
/*}}}*/
using namespace std;
@@ -1560,6 +1562,70 @@ bool Policy(CommandLine &CmdL)
return true;
}
/*}}}*/
+// Madison - Look a bit like katie's madison /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool Madison(CommandLine &CmdL)
+{
+ if (SrcList == 0)
+ return _error->Error("Generate must be enabled for this function");
+
+ SrcList->ReadMainList();
+
+ pkgCache &Cache = *GCache;
+
+ // Create the text record parsers
+ pkgSrcRecords SrcRecs(*SrcList);
+ if (_error->PendingError() == true)
+ return false;
+
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ {
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
+
+ if (Pkg.end() == false)
+ {
+ for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; V++)
+ {
+ for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+ {
+ if (VF.File().Archive() != 0)
+ {
+ cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+ << VF.File().Archive() << endl;
+ }
+ else
+ {
+ // Locate the associated index files so we can derive a description
+ for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++)
+ {
+ if ((*S)->FindInCache(*(VF.File().Cache())) == VF.File())
+ {
+ cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+ << (*S)->Describe(true) << endl;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ SrcRecs.Restart();
+ pkgSrcRecords::Parser *SrcParser;
+ while ((SrcParser = SrcRecs.Find(*I,false)) != 0)
+ {
+ // Maybe support Release info here too eventually
+ cout << setw(10) << SrcParser->Package() << " | "
+ << setw(10) << SrcParser->Version() << " | "
+ << SrcParser->Index().Describe(true) << endl;
+ }
+ }
+
+ return true;
+}
+
+ /*}}}*/
// GenCaches - Call the main cache generator /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1670,6 +1736,7 @@ int main(int argc,const char *argv[])
{"show",&ShowPackage},
{"pkgnames",&ShowPkgNames},
{"policy",&Policy},
+ {"madison",&Madison},
{0,0}};
CacheInitialize();