// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.66 2003/08/01 20:27:13 mdz Exp $
+// $Id: apt-cache.cc,v 1.72 2004/04/30 04:34:03 mdz Exp $
/* ######################################################################
apt-cache - Manages the cache files
#include <errno.h>
#include <regex.h>
#include <stdio.h>
+
+#include <iomanip>
/*}}}*/
using namespace std;
Buffer[V.FileList()->Size] = '\n';
if (PkgF.Seek(V.FileList()->Offset) == false ||
PkgF.Read(Buffer,V.FileList()->Size) == false ||
- write(STDOUT_FILENO,Buffer,V.FileList()->Size+1) != V.FileList()->Size+1)
+ fwrite(Buffer,1,V.FileList()->Size+1,stdout) < (size_t)(V.FileList()->Size+1))
{
delete [] Buffer;
return false;
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++)
+ {
+// This might be nice, but wouldn't uniquely identify the source -mdz
+// if (VF.File().Archive() != 0)
+// {
+// cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+// << VF.File().Archive() << endl;
+// }
+
+ // Locate the associated index files so we can derive a description
+ for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++)
+ {
+ vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
+ for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
+ IF != Indexes->end(); IF++)
+ {
+ if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File())
+ {
+ cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+ << (*IF)->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 /*{{{*/
// ---------------------------------------------------------------------
" -q Disable progress indicator.\n"
" -i Show only important deps for the unmet command.\n"
" -c=? Read this configuration file\n"
- " -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp\n"
+ " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"
"See the apt-cache(8) and apt.conf(5) manual pages for more information.\n");
return true;
}
{'f',"full","APT::Cache::ShowFull",0},
{'g',"generate","APT::Cache::Generate",0},
{'a',"all-versions","APT::Cache::AllVersions",0},
- {0,"names-only","APT::Cache::NamesOnly",0},
- {'n',"all-names","APT::Cache::AllNames",0},
+ {'n',"names-only","APT::Cache::NamesOnly",0},
+ {0,"all-names","APT::Cache::AllNames",0},
{0,"recurse","APT::Cache::RecurseDepends",0},
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
- {'n',"installed","APT::Cache::Installed",0},
+ {0,"installed","APT::Cache::Installed",0},
{0,0,0,0}};
CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
{"add",&DoAdd},
{"show",&ShowPackage},
{"pkgnames",&ShowPkgNames},
{"policy",&Policy},
+ {"madison",&Madison},
{0,0}};
CacheInitialize();
}
// Deal with stdout not being a tty
- if (ttyname(STDOUT_FILENO) == 0 && _config->FindI("quiet",0) < 1)
+ if (isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
_config->Set("quiet","1");
if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)