apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

apt-cache.cc
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  apt-cache - Manages the cache files
6 
7  apt-cache provides some functions fo manipulating the cache files.
8  It uses the command line interface common to all the APT tools.
9 
10  Returns 100 on failure, 0 on success.
11 
12  ##################################################################### */
13  /*}}}*/
14 // Include Files /*{{{*/
15 #include <config.h>
16 
17 #include <apt-pkg/algorithms.h>
18 #include <apt-pkg/cachefile.h>
19 #include <apt-pkg/cacheset.h>
20 #include <apt-pkg/cmndline.h>
21 #include <apt-pkg/configuration.h>
22 #include <apt-pkg/depcache.h>
23 #include <apt-pkg/error.h>
24 #include <apt-pkg/fileutl.h>
25 #include <apt-pkg/indexfile.h>
26 #include <apt-pkg/init.h>
27 #include <apt-pkg/macros.h>
28 #include <apt-pkg/metaindex.h>
29 #include <apt-pkg/mmap.h>
30 #include <apt-pkg/pkgcache.h>
31 #include <apt-pkg/pkgrecords.h>
32 #include <apt-pkg/pkgsystem.h>
33 #include <apt-pkg/policy.h>
34 #include <apt-pkg/progress.h>
35 #include <apt-pkg/sourcelist.h>
36 #include <apt-pkg/srcrecords.h>
37 #include <apt-pkg/strutl.h>
38 #include <apt-pkg/tagfile.h>
39 #include <apt-pkg/version.h>
40 
48 
49 #include <algorithm>
50 #include <cstring>
51 #include <iomanip>
52 #include <iostream>
53 #include <list>
54 #include <map>
55 #include <set>
56 #include <string>
57 #include <vector>
58 #include <regex.h>
59 #include <stddef.h>
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <unistd.h>
63 
64 #include <apti18n.h>
65  /*}}}*/
66 
67 using namespace std;
68 
69 // DumpPackage - Show a dump of a package record /*{{{*/
70 // ---------------------------------------------------------------------
71 /* */
72 static bool DumpPackage(CommandLine &CmdL)
73 {
77 
78  for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
79  {
80  cout << "Package: " << Pkg.FullName(true) << endl;
81  cout << "Versions: " << endl;
82  for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
83  {
84  cout << Cur.VerStr();
85  for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; ++Vf)
86  cout << " (" << Vf.File().FileName() << ")";
87  cout << endl;
88  for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; ++D)
89  {
90  cout << " Description Language: " << D.LanguageCode() << endl
91  << " File: " << D.FileList().File().FileName() << endl
92  << " MD5: " << D.md5() << endl;
93  }
94  cout << endl;
95  }
96 
97  cout << endl;
98 
99  cout << "Reverse Depends: " << endl;
100  for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D)
101  {
102  cout << " " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true);
103  if (D->Version != 0)
104  cout << ' ' << DeNull(D.TargetVer()) << endl;
105  else
106  cout << endl;
107  }
108 
109  cout << "Dependencies: " << endl;
110  for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
111  {
112  cout << Cur.VerStr() << " - ";
113  for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; ++Dep)
114  cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
115  cout << endl;
116  }
117 
118  cout << "Provides: " << endl;
119  for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
120  {
121  cout << Cur.VerStr() << " - ";
122  for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; ++Prv)
123  cout << Prv.ParentPkg().FullName(true) << " (= " << (Prv->ProvideVersion == 0 ? "" : Prv.ProvideVersion()) << ") ";
124  cout << endl;
125  }
126  cout << "Reverse Provides: " << endl;
127  for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; ++Prv)
128  cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << " (= " << (Prv->ProvideVersion == 0 ? "" : Prv.ProvideVersion()) << ")"<< endl;
129  }
130 
131  return true;
132 }
133  /*}}}*/
134 // ShowHashTableStats - Show stats about a hashtable /*{{{*/
135 // ---------------------------------------------------------------------
136 /* */
138 static map_pointer<pkgCache::Group> GroupNext(pkgCache::Group const * const G) { return G->Next; }
139 template <class T>
140 static void ShowHashTableStats(char const *const Type,
141  T *StartP,
142  map_pointer<T> *Hashtable,
143  unsigned long Size,
144  map_pointer<T> (*Next)(T const *const))
145 {
146  // hashtable stats for the HashTable
147  unsigned long NumBuckets = Size;
148  unsigned long UsedBuckets = 0;
149  unsigned long UnusedBuckets = 0;
150  unsigned long LongestBucket = 0;
151  unsigned long ShortestBucket = NumBuckets;
152  unsigned long Entries = 0;
153  for (unsigned int i=0; i < NumBuckets; ++i)
154  {
155  T *P = StartP + Hashtable[i];
156  if(P == 0 || P == StartP)
157  {
158  ++UnusedBuckets;
159  continue;
160  }
161  ++UsedBuckets;
162  unsigned long ThisBucketSize = 0;
163  for (; P != StartP; P = StartP + Next(P))
164  ++ThisBucketSize;
165  Entries += ThisBucketSize;
166  LongestBucket = std::max(ThisBucketSize, LongestBucket);
167  ShortestBucket = std::min(ThisBucketSize, ShortestBucket);
168  }
169  cout << "Total buckets in " << Type << ": " << NumBuckets << std::endl;
170  cout << " Unused: " << UnusedBuckets << std::endl;
171  cout << " Used: " << UsedBuckets << std::endl;
172  cout << " Utilization: " << 100.0 * UsedBuckets/NumBuckets << "%" << std::endl;
173  cout << " Average entries: " << Entries/(double)UsedBuckets << std::endl;
174  cout << " Longest: " << LongestBucket << std::endl;
175  cout << " Shortest: " << ShortestBucket << std::endl;
176 }
177  /*}}}*/
178 // Stats - Dump some nice statistics /*{{{*/
179 // ---------------------------------------------------------------------
180 /* */
181 static bool Stats(CommandLine &CmdL)
182 {
183  if (CmdL.FileSize() > 1) {
184  _error->Error(_("%s does not take any arguments"), "apt-cache stats");
185  return false;
186  }
187 
189  pkgCache *Cache = CacheFile.GetPkgCache();
190 
191  if (unlikely(Cache == NULL))
192  return false;
193 
194  cout << _("Total package names: ") << Cache->Head().GroupCount << " (" <<
195  SizeToStr(Cache->Head().GroupCount*Cache->Head().GroupSz) << ')' << endl
196  << _("Total package structures: ") << Cache->Head().PackageCount << " (" <<
197  SizeToStr(Cache->Head().PackageCount*Cache->Head().PackageSz) << ')' << endl;
198 
199  int Normal = 0;
200  int Virtual = 0;
201  int NVirt = 0;
202  int DVirt = 0;
203  int Missing = 0;
204  for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
205  {
206  if (I->VersionList != 0 && I->ProvidesList == 0)
207  {
208  Normal++;
209  continue;
210  }
211 
212  if (I->VersionList != 0 && I->ProvidesList != 0)
213  {
214  NVirt++;
215  continue;
216  }
217 
218  if (I->VersionList == 0 && I->ProvidesList != 0)
219  {
220  // Only 1 provides
221  if (I.ProvidesList()->NextProvides == 0)
222  {
223  DVirt++;
224  }
225  else
226  Virtual++;
227  continue;
228  }
229  if (I->VersionList == 0 && I->ProvidesList == 0)
230  {
231  Missing++;
232  continue;
233  }
234  }
235  cout << _(" Normal packages: ") << Normal << endl;
236  cout << _(" Pure virtual packages: ") << Virtual << endl;
237  cout << _(" Single virtual packages: ") << DVirt << endl;
238  cout << _(" Mixed virtual packages: ") << NVirt << endl;
239  cout << _(" Missing: ") << Missing << endl;
240 
241  cout << _("Total distinct versions: ") << Cache->Head().VersionCount << " (" <<
242  SizeToStr(Cache->Head().VersionCount*Cache->Head().VersionSz) << ')' << endl;
243  cout << _("Total distinct descriptions: ") << Cache->Head().DescriptionCount << " (" <<
244  SizeToStr(Cache->Head().DescriptionCount*Cache->Head().DescriptionSz) << ')' << endl;
245  cout << _("Total dependencies: ") << Cache->Head().DependsCount << "/" << Cache->Head().DependsDataCount << " (" <<
246  SizeToStr((Cache->Head().DependsCount*Cache->Head().DependencySz) +
247  (Cache->Head().DependsDataCount*Cache->Head().DependencyDataSz)) << ')' << endl;
248  cout << _("Total ver/file relations: ") << Cache->Head().VerFileCount << " (" <<
249  SizeToStr(Cache->Head().VerFileCount*Cache->Head().VerFileSz) << ')' << endl;
250  cout << _("Total Desc/File relations: ") << Cache->Head().DescFileCount << " (" <<
251  SizeToStr(Cache->Head().DescFileCount*Cache->Head().DescFileSz) << ')' << endl;
252  cout << _("Total Provides mappings: ") << Cache->Head().ProvidesCount << " (" <<
253  SizeToStr(Cache->Head().ProvidesCount*Cache->Head().ProvidesSz) << ')' << endl;
254 
255  // String list stats
256  std::set<map_stringitem_t> stritems;
257  for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() == false; ++G)
258  stritems.insert(G->Name);
259  for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
260  {
261  stritems.insert(P->Arch);
262  for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
263  {
264  if (V->VerStr != 0)
265  stritems.insert(V->VerStr);
266  if (V->Section != 0)
267  stritems.insert(V->Section);
268  stritems.insert(V->SourcePkgName);
269  stritems.insert(V->SourceVerStr);
270  for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D)
271  {
272  if (D->Version != 0)
273  stritems.insert(D->Version);
274  }
275  for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; ++D)
276  {
277  stritems.insert(D->md5sum);
278  stritems.insert(D->language_code);
279  }
280  }
281  for (pkgCache::PrvIterator Prv = P.ProvidesList(); Prv.end() == false; ++Prv)
282  {
283  if (Prv->ProvideVersion != 0)
284  stritems.insert(Prv->ProvideVersion);
285  }
286  }
287  for (pkgCache::RlsFileIterator F = Cache->RlsFileBegin(); F != Cache->RlsFileEnd(); ++F)
288  {
289  stritems.insert(F->FileName);
290  stritems.insert(F->Archive);
291  stritems.insert(F->Codename);
292  stritems.insert(F->Version);
293  stritems.insert(F->Origin);
294  stritems.insert(F->Label);
295  stritems.insert(F->Site);
296  }
297  for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F)
298  {
299  stritems.insert(F->FileName);
300  stritems.insert(F->Architecture);
301  stritems.insert(F->Component);
302  stritems.insert(F->IndexType);
303  }
304 
305  unsigned long Size = 0;
306  for (std::set<map_stringitem_t>::const_iterator i = stritems.begin(); i != stritems.end(); ++i)
307  Size += strlen(Cache->StrP + *i) + 1;
308  cout << _("Total globbed strings: ") << stritems.size() << " (" << SizeToStr(Size) << ')' << endl;
309  stritems.clear();
310 
311  unsigned long Slack = 0;
312  for (int I = 0; I != 7; I++)
313  Slack += Cache->Head().Pools[I].ItemSize*Cache->Head().Pools[I].Count;
314  cout << _("Total slack space: ") << SizeToStr(Slack) << endl;
315 
316  unsigned long Total = 0;
317 #define APT_CACHESIZE(X,Y) (Cache->Head().X * Cache->Head().Y)
318  Total = Slack + Size +
319  APT_CACHESIZE(GroupCount, GroupSz) +
320  APT_CACHESIZE(PackageCount, PackageSz) +
321  APT_CACHESIZE(VersionCount, VersionSz) +
322  APT_CACHESIZE(DescriptionCount, DescriptionSz) +
323  APT_CACHESIZE(DependsCount, DependencySz) +
324  APT_CACHESIZE(DependsDataCount, DependencyDataSz) +
325  APT_CACHESIZE(ReleaseFileCount, ReleaseFileSz) +
326  APT_CACHESIZE(PackageFileCount, PackageFileSz) +
327  APT_CACHESIZE(VerFileCount, VerFileSz) +
328  APT_CACHESIZE(DescFileCount, DescFileSz) +
329  APT_CACHESIZE(ProvidesCount, ProvidesSz) +
330  (2 * Cache->Head().GetHashTableSize() * sizeof(map_id_t));
331  cout << _("Total space accounted for: ") << SizeToStr(Total) << endl;
332 #undef APT_CACHESIZE
333 
334  // hashtable stats
335  ShowHashTableStats<pkgCache::Package>("PkgHashTable", Cache->PkgP, Cache->Head().PkgHashTableP(), Cache->Head().GetHashTableSize(), PackageNext);
336  ShowHashTableStats<pkgCache::Group>("GrpHashTable", Cache->GrpP, Cache->Head().GrpHashTableP(), Cache->Head().GetHashTableSize(), GroupNext);
337 
338  return true;
339 }
340  /*}}}*/
341 // Dump - show everything /*{{{*/
342 // ---------------------------------------------------------------------
343 /* This is worthless except fer debugging things */
344 static bool Dump(CommandLine &)
345 {
347  pkgCache *Cache = CacheFile.GetPkgCache();
348  if (unlikely(Cache == NULL))
349  return false;
350 
351  std::cout << "Using Versioning System: " << Cache->VS->Label << std::endl;
352 
353  for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
354  {
355  std::cout << "Package: " << P.FullName(true) << std::endl;
356  for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
357  {
358  std::cout << " Version: " << V.VerStr() << std::endl;
359  std::cout << " File: " << V.FileList().File().FileName() << std::endl;
360  for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D)
361  std::cout << " Depends: " << D.TargetPkg().FullName(true) << ' ' <<
362  DeNull(D.TargetVer()) << std::endl;
363  for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; ++D)
364  {
365  std::cout << " Description Language: " << D.LanguageCode() << std::endl
366  << " File: " << D.FileList().File().FileName() << std::endl
367  << " MD5: " << D.md5() << std::endl;
368  }
369  }
370  }
371 
372  for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F)
373  {
374  std::cout << "File: " << F.FileName() << std::endl;
375  std::cout << " Type: " << F.IndexType() << std::endl;
376  std::cout << " Size: " << F->Size << std::endl;
377  std::cout << " ID: " << F->ID << std::endl;
378  std::cout << " Flags: " << F->Flags << std::endl;
379  std::cout << " Time: " << TimeRFC1123(F->mtime, true) << std::endl;
380  std::cout << " Archive: " << DeNull(F.Archive()) << std::endl;
381  std::cout << " Component: " << DeNull(F.Component()) << std::endl;
382  std::cout << " Version: " << DeNull(F.Version()) << std::endl;
383  std::cout << " Origin: " << DeNull(F.Origin()) << std::endl;
384  std::cout << " Site: " << DeNull(F.Site()) << std::endl;
385  std::cout << " Label: " << DeNull(F.Label()) << std::endl;
386  std::cout << " Architecture: " << DeNull(F.Architecture()) << std::endl;
387  }
388 
389  return true;
390 }
391  /*}}}*/
392 // DumpAvail - Print out the available list /*{{{*/
393 // ---------------------------------------------------------------------
394 /* This is needed to make dpkg --merge happy.. I spent a bit of time to
395  make this run really fast, perhaps I went a little overboard.. */
396 static bool DumpAvail(CommandLine &)
397 {
399  pkgCache *Cache = CacheFile.GetPkgCache();
400  if (unlikely(Cache == NULL || CacheFile.BuildPolicy() == false))
401  return false;
402 
403  auto const Count = Cache->HeaderP->PackageCount+1;
404  pkgCache::VerFile **VFList = new pkgCache::VerFile *[Count];
405  memset(VFList,0,sizeof(*VFList)*Count);
406 
407  // Map versions that we want to write out onto the VerList array.
408  for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
409  {
410  if (P->VersionList == 0)
411  continue;
412 
413  /* Find the proper version to use. If the policy says there are no
414  possible selections we return the installed version, if available..
415  This prevents dselect from making it obsolete. */
417  if (V.end() == true)
418  {
419  if (P->CurrentVer == 0)
420  continue;
421  V = P.CurrentVer();
422  }
423 
424  pkgCache::VerFileIterator VF = V.FileList();
425  for (; VF.end() == false ; ++VF)
426  if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0)
427  break;
428 
429  /* Okay, here we have a bit of a problem.. The policy has selected the
430  currently installed package - however it only exists in the
431  status file.. We need to write out something or dselect will mark
432  the package as obsolete! Thus we emit the status file entry, but
433  below we remove the status line to make it valid for the
434  available file. However! We only do this if their do exist *any*
435  non-source versions of the package - that way the dselect obsolete
436  handling works OK. */
437  if (VF.end() == true)
438  {
439  for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; ++Cur)
440  {
441  for (VF = Cur.FileList(); VF.end() == false; ++VF)
442  {
443  if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0)
444  {
445  VF = V.FileList();
446  break;
447  }
448  }
449 
450  if (VF.end() == false)
451  break;
452  }
453  }
454 
455  VFList[P->ID] = VF;
456  }
457 
458  LocalitySort(VFList,Count,sizeof(*VFList));
459 
460  std::vector<pkgTagSection::Tag> RW;
461  RW.push_back(pkgTagSection::Tag::Remove("Status"));
462  RW.push_back(pkgTagSection::Tag::Remove("Config-Version"));
463  FileFd stdoutfd;
464  stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false);
465 
466  // Iterate over all the package files and write them out.
467  char *Buffer = new char[Cache->HeaderP->MaxVerFileSize+10];
468  for (pkgCache::VerFile **J = VFList; *J != 0;)
469  {
470  pkgCache::PkgFileIterator File(*Cache, Cache->PkgFileP + (*J)->File);
471  // FIXME: Add support for volatile/with-source files
472  FileFd PkgF(File.FileName(),FileFd::ReadOnly, FileFd::Extension);
473  if (_error->PendingError() == true)
474  break;
475 
476  /* Write all of the records from this package file, since we
477  already did locality sorting we can now just seek through the
478  file in read order. We apply 1 more optimization here, since often
479  there will be < 1 byte gaps between records (for the \n) we read that
480  into the next buffer and offset a bit.. */
481  unsigned long Pos = 0;
482  for (; *J != 0; J++)
483  {
484  if (Cache->PkgFileP + (*J)->File != File)
485  break;
486 
487  const pkgCache::VerFile &VF = **J;
488 
489  // Read the record and then write it out again.
490  unsigned long Jitter = VF.Offset - Pos;
491  if (Jitter > 8)
492  {
493  if (PkgF.Seek(VF.Offset) == false)
494  break;
495  Jitter = 0;
496  }
497 
498  if (PkgF.Read(Buffer,VF.Size + Jitter) == false)
499  break;
500  Buffer[VF.Size + Jitter] = '\n';
501 
502  // See above..
504  {
505  pkgTagSection Tags;
506  if (Tags.Scan(Buffer+Jitter,VF.Size+1) == false ||
507  Tags.Write(stdoutfd, NULL, RW) == false ||
508  stdoutfd.Write("\n", 1) == false)
509  {
510  _error->Error("Internal Error, Unable to parse a package record");
511  break;
512  }
513  }
514  else
515  {
516  if (stdoutfd.Write(Buffer + Jitter, VF.Size + 1) == false)
517  break;
518  }
519 
520  Pos = VF.Offset + VF.Size;
521  }
522 
523  if (_error->PendingError() == true)
524  break;
525  }
526 
527  delete [] Buffer;
528  delete [] VFList;
529  return !_error->PendingError();
530 }
531  /*}}}*/
532 // xvcg - Generate a graph for xvcg /*{{{*/
533 // ---------------------------------------------------------------------
534 // Code contributed from Junichi Uekawa <dancer@debian.org> on 20 June 2002.
535 
536 static bool XVcg(CommandLine &CmdL)
537 {
539  pkgCache *Cache = CacheFile.GetPkgCache();
540  if (unlikely(Cache == NULL))
541  return false;
542 
543  bool GivenOnly = _config->FindB("APT::Cache::GivenOnly",false);
544 
545  /* Normal packages are boxes
546  Pure Provides are triangles
547  Mixed are diamonds
548  rhomb are missing packages*/
549  const char *Shapes[] = {"ellipse","triangle","box","rhomb"};
550 
551  /* Initialize the list of packages to show.
552  1 = To Show
553  2 = To Show no recurse
554  3 = Emitted no recurse
555  4 = Emitted
556  0 = None */
557  enum States {None=0, ToShow, ToShowNR, DoneNR, Done};
558  enum TheFlags {ForceNR=(1<<0)};
559  auto PackageCount = Cache->Head().PackageCount;
560  unsigned char *Show = new unsigned char[PackageCount];
561  unsigned char *Flags = new unsigned char[PackageCount];
562  unsigned char *ShapeMap = new unsigned char[PackageCount];
563 
564  // Show everything if no arguments given
565  if (CmdL.FileList[1] == 0)
566  for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
567  Show[I] = ToShow;
568  else
569  for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
570  Show[I] = None;
571  memset(Flags,0,sizeof(*Flags)*PackageCount);
572 
573  // Map the shapes
574  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
575  {
576  if (Pkg->VersionList == 0)
577  {
578  // Missing
579  if (Pkg->ProvidesList == 0)
580  ShapeMap[Pkg->ID] = 0;
581  else
582  ShapeMap[Pkg->ID] = 1;
583  }
584  else
585  {
586  // Normal
587  if (Pkg->ProvidesList == 0)
588  ShapeMap[Pkg->ID] = 2;
589  else
590  ShapeMap[Pkg->ID] = 3;
591  }
592  }
593 
594  // Load the list of packages from the command line into the show list
596  std::list<APT::CacheSetHelper::PkgModifier> mods;
599  std::map<unsigned short, APT::PackageSet> pkgsets =
600  APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0, helper);
601 
602  for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
603  Pkg != pkgsets[0].end(); ++Pkg)
604  Show[Pkg->ID] = ToShow;
605  for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
606  Pkg != pkgsets[1].end(); ++Pkg)
607  {
608  Show[Pkg->ID] = ToShow;
609  Flags[Pkg->ID] |= ForceNR;
610  }
611 
612  // Little header
613  cout << "graph: { title: \"packages\"" << endl <<
614  "xmax: 700 ymax: 700 x: 30 y: 30" << endl <<
615  "layout_downfactor: 8" << endl;
616 
617  bool Act = true;
618  while (Act == true)
619  {
620  Act = false;
621  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
622  {
623  // See we need to show this package
624  if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR)
625  continue;
626 
627  //printf ("node: { title: \"%s\" label: \"%s\" }\n", Pkg.Name(), Pkg.Name());
628 
629  // Colour as done
630  if (Show[Pkg->ID] == ToShowNR || (Flags[Pkg->ID] & ForceNR) == ForceNR)
631  {
632  // Pure Provides and missing packages have no deps!
633  if (ShapeMap[Pkg->ID] == 0 || ShapeMap[Pkg->ID] == 1)
634  Show[Pkg->ID] = Done;
635  else
636  Show[Pkg->ID] = DoneNR;
637  }
638  else
639  Show[Pkg->ID] = Done;
640  Act = true;
641 
642  // No deps to map out
643  if (Pkg->VersionList == 0 || Show[Pkg->ID] == DoneNR)
644  continue;
645 
646  pkgCache::VerIterator Ver = Pkg.VersionList();
647  for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
648  {
649  // See if anything can meet this dep
650  // Walk along the actual package providing versions
651  bool Hit = false;
652  pkgCache::PkgIterator DPkg = D.TargetPkg();
653  for (pkgCache::VerIterator I = DPkg.VersionList();
654  I.end() == false && Hit == false; ++I)
655  {
656  if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true)
657  Hit = true;
658  }
659 
660  // Follow all provides
661  for (pkgCache::PrvIterator I = DPkg.ProvidesList();
662  I.end() == false && Hit == false; ++I)
663  {
664  if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false)
665  Hit = true;
666  }
667 
668 
669  // Only graph critical deps
670  if (D.IsCritical() == true)
671  {
672  printf ("edge: { sourcename: \"%s\" targetname: \"%s\" class: 2 ",Pkg.FullName(true).c_str(), D.TargetPkg().FullName(true).c_str() );
673 
674  // Colour the node for recursion
675  if (Show[D.TargetPkg()->ID] <= DoneNR)
676  {
677  /* If a conflicts does not meet anything in the database
678  then show the relation but do not recurse */
679  if (Hit == false && D.IsNegative() == true)
680  {
681  if (Show[D.TargetPkg()->ID] == None &&
682  Show[D.TargetPkg()->ID] != ToShow)
683  Show[D.TargetPkg()->ID] = ToShowNR;
684  }
685  else
686  {
687  if (GivenOnly == true && Show[D.TargetPkg()->ID] != ToShow)
688  Show[D.TargetPkg()->ID] = ToShowNR;
689  else
690  Show[D.TargetPkg()->ID] = ToShow;
691  }
692  }
693 
694  // Edge colour
695  switch(D->Type)
696  {
698  printf("label: \"conflicts\" color: lightgreen }\n");
699  break;
701  printf("label: \"breaks\" color: lightgreen }\n");
702  break;
704  printf("label: \"obsoletes\" color: lightgreen }\n");
705  break;
706 
708  printf("label: \"predepends\" color: blue }\n");
709  break;
710 
711  default:
712  printf("}\n");
713  break;
714  }
715  }
716  }
717  }
718  }
719 
720  /* Draw the box colours after the fact since we can not tell what colour
721  they should be until everything is finished drawing */
722  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
723  {
724  if (Show[Pkg->ID] < DoneNR)
725  continue;
726 
727  if (Show[Pkg->ID] == DoneNR)
728  printf("node: { title: \"%s\" label: \"%s\" color: orange shape: %s }\n", Pkg.FullName(true).c_str(), Pkg.FullName(true).c_str(),
729  Shapes[ShapeMap[Pkg->ID]]);
730  else
731  printf("node: { title: \"%s\" label: \"%s\" shape: %s }\n", Pkg.FullName(true).c_str(), Pkg.FullName(true).c_str(),
732  Shapes[ShapeMap[Pkg->ID]]);
733 
734  }
735 
736  delete[] Show;
737  delete[] Flags;
738  delete[] ShapeMap;
739 
740  printf("}\n");
741  return true;
742 }
743  /*}}}*/
744 // Dotty - Generate a graph for Dotty /*{{{*/
745 // ---------------------------------------------------------------------
746 /* Dotty is the graphvis program for generating graphs. It is a fairly
747  simple queuing algorithm that just writes dependencies and nodes.
748  http://www.research.att.com/sw/tools/graphviz/ */
749 static bool Dotty(CommandLine &CmdL)
750 {
752  pkgCache *Cache = CacheFile.GetPkgCache();
753  if (unlikely(Cache == NULL))
754  return false;
755 
756  bool GivenOnly = _config->FindB("APT::Cache::GivenOnly",false);
757 
758  /* Normal packages are boxes
759  Pure Provides are triangles
760  Mixed are diamonds
761  Hexagons are missing packages*/
762  const char *Shapes[] = {"hexagon","triangle","box","diamond"};
763 
764  /* Initialize the list of packages to show.
765  1 = To Show
766  2 = To Show no recurse
767  3 = Emitted no recurse
768  4 = Emitted
769  0 = None */
770  enum States {None=0, ToShow, ToShowNR, DoneNR, Done};
771  enum TheFlags {ForceNR=(1<<0)};
772  auto PackageCount = Cache->Head().PackageCount;
773  unsigned char *Show = new unsigned char[PackageCount];
774  unsigned char *Flags = new unsigned char[PackageCount];
775  unsigned char *ShapeMap = new unsigned char[PackageCount];
776 
777  // Show everything if no arguments given
778  if (CmdL.FileList[1] == 0)
779  for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
780  Show[I] = ToShow;
781  else
782  for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
783  Show[I] = None;
784  memset(Flags,0,sizeof(*Flags)*PackageCount);
785 
786  // Map the shapes
787  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
788  {
789  if (Pkg->VersionList == 0)
790  {
791  // Missing
792  if (Pkg->ProvidesList == 0)
793  ShapeMap[Pkg->ID] = 0;
794  else
795  ShapeMap[Pkg->ID] = 1;
796  }
797  else
798  {
799  // Normal
800  if (Pkg->ProvidesList == 0)
801  ShapeMap[Pkg->ID] = 2;
802  else
803  ShapeMap[Pkg->ID] = 3;
804  }
805  }
806 
807  // Load the list of packages from the command line into the show list
809  std::list<APT::CacheSetHelper::PkgModifier> mods;
812  std::map<unsigned short, APT::PackageSet> pkgsets =
813  APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0, helper);
814 
815  for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
816  Pkg != pkgsets[0].end(); ++Pkg)
817  Show[Pkg->ID] = ToShow;
818  for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
819  Pkg != pkgsets[1].end(); ++Pkg)
820  {
821  Show[Pkg->ID] = ToShow;
822  Flags[Pkg->ID] |= ForceNR;
823  }
824 
825  // Little header
826  printf("digraph packages {\n");
827  printf("concentrate=true;\n");
828  printf("size=\"30,40\";\n");
829 
830  bool Act = true;
831  while (Act == true)
832  {
833  Act = false;
834  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
835  {
836  // See we need to show this package
837  if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR)
838  continue;
839 
840  // Colour as done
841  if (Show[Pkg->ID] == ToShowNR || (Flags[Pkg->ID] & ForceNR) == ForceNR)
842  {
843  // Pure Provides and missing packages have no deps!
844  if (ShapeMap[Pkg->ID] == 0 || ShapeMap[Pkg->ID] == 1)
845  Show[Pkg->ID] = Done;
846  else
847  Show[Pkg->ID] = DoneNR;
848  }
849  else
850  Show[Pkg->ID] = Done;
851  Act = true;
852 
853  // No deps to map out
854  if (Pkg->VersionList == 0 || Show[Pkg->ID] == DoneNR)
855  continue;
856 
857  pkgCache::VerIterator Ver = Pkg.VersionList();
858  for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
859  {
860  // See if anything can meet this dep
861  // Walk along the actual package providing versions
862  bool Hit = false;
863  pkgCache::PkgIterator DPkg = D.TargetPkg();
864  for (pkgCache::VerIterator I = DPkg.VersionList();
865  I.end() == false && Hit == false; ++I)
866  {
867  if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true)
868  Hit = true;
869  }
870 
871  // Follow all provides
872  for (pkgCache::PrvIterator I = DPkg.ProvidesList();
873  I.end() == false && Hit == false; ++I)
874  {
875  if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false)
876  Hit = true;
877  }
878 
879  // Only graph critical deps
880  if (D.IsCritical() == true)
881  {
882  printf("\"%s\" -> \"%s\"",Pkg.FullName(true).c_str(),D.TargetPkg().FullName(true).c_str());
883 
884  // Colour the node for recursion
885  if (Show[D.TargetPkg()->ID] <= DoneNR)
886  {
887  /* If a conflicts does not meet anything in the database
888  then show the relation but do not recurse */
889  if (Hit == false && D.IsNegative() == true)
890  {
891  if (Show[D.TargetPkg()->ID] == None &&
892  Show[D.TargetPkg()->ID] != ToShow)
893  Show[D.TargetPkg()->ID] = ToShowNR;
894  }
895  else
896  {
897  if (GivenOnly == true && Show[D.TargetPkg()->ID] != ToShow)
898  Show[D.TargetPkg()->ID] = ToShowNR;
899  else
900  Show[D.TargetPkg()->ID] = ToShow;
901  }
902  }
903 
904  // Edge colour
905  switch(D->Type)
906  {
910  printf("[color=springgreen];\n");
911  break;
912 
914  printf("[color=blue];\n");
915  break;
916 
917  default:
918  printf(";\n");
919  break;
920  }
921  }
922  }
923  }
924  }
925 
926  /* Draw the box colours after the fact since we can not tell what colour
927  they should be until everything is finished drawing */
928  for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
929  {
930  if (Show[Pkg->ID] < DoneNR)
931  continue;
932 
933  // Orange box for early recursion stoppage
934  if (Show[Pkg->ID] == DoneNR)
935  printf("\"%s\" [color=orange,shape=%s];\n",Pkg.FullName(true).c_str(),
936  Shapes[ShapeMap[Pkg->ID]]);
937  else
938  printf("\"%s\" [shape=%s];\n",Pkg.FullName(true).c_str(),
939  Shapes[ShapeMap[Pkg->ID]]);
940  }
941 
942  printf("}\n");
943  delete[] Show;
944  delete[] Flags;
945  delete[] ShapeMap;
946  return true;
947 }
948  /*}}}*/
949 /* ShowAuto - show automatically installed packages (sorted) {{{*/
950 static bool ShowAuto(CommandLine &)
951 {
953  pkgCache *Cache = CacheFile.GetPkgCache();
954  pkgDepCache *DepCache = CacheFile.GetDepCache();
955  if (unlikely(Cache == NULL || DepCache == NULL))
956  return false;
957 
958  std::vector<string> packages;
959  packages.reserve(Cache->HeaderP->PackageCount / 3);
960 
961  for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
962  if ((*DepCache)[P].Flags & pkgCache::Flag::Auto)
963  packages.push_back(P.Name());
964 
965  std::sort(packages.begin(), packages.end());
966 
967  for (vector<string>::iterator I = packages.begin(); I != packages.end(); ++I)
968  cout << *I << "\n";
969 
970  _error->Notice(_("This command is deprecated. Please use 'apt-mark showauto' instead."));
971  return true;
972 }
973  /*}}}*/
974 // ShowPkgNames - Show package names /*{{{*/
975 // ---------------------------------------------------------------------
976 /* This does a prefix match on the first argument */
977 static bool ShowPkgNames(CommandLine &CmdL)
978 {
980  if (unlikely(CacheFile.BuildCaches(NULL, false) == false))
981  return false;
983  bool const All = _config->FindB("APT::Cache::AllNames", false);
984 
985  if (CmdL.FileList[1] != 0)
986  {
987  for (;I.end() != true; ++I)
988  {
989  if (All == false && (I.PackageList().end() || I.PackageList()->VersionList == 0))
990  continue;
991  if (strncmp(I.Name(),CmdL.FileList[1],strlen(CmdL.FileList[1])) == 0)
992  cout << I.Name() << endl;
993  }
994 
995  return true;
996  }
997 
998  // Show all pkgs
999  for (;I.end() != true; ++I)
1000  {
1001  if (All == false && (I.PackageList().end() || I.PackageList()->VersionList == 0))
1002  continue;
1003  cout << I.Name() << endl;
1004  }
1005 
1006  return true;
1007 }
1008  /*}}}*/
1009 // Madison - Look a bit like katie's madison /*{{{*/
1010 // ---------------------------------------------------------------------
1011 /* */
1012 static bool Madison(CommandLine &CmdL)
1013 {
1015  pkgSourceList *SrcList = CacheFile.GetSourceList();
1016 
1017  if (SrcList == 0)
1018  return false;
1019 
1020  // Create the src text record parsers and ignore errors about missing
1021  // deb-src lines that are generated from pkgSrcRecords::pkgSrcRecords
1022  pkgSrcRecords SrcRecs(*SrcList);
1023  if (_error->PendingError() == true)
1024  _error->Discard();
1025 
1027  for (const char **I = CmdL.FileList + 1; *I != 0; I++)
1028  {
1029  _error->PushToStack();
1031  for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
1032  {
1033  for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V)
1034  {
1035  for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
1036  {
1037 // This might be nice, but wouldn't uniquely identify the source -mdz
1038 // if (VF.File().Archive() != 0)
1039 // {
1040 // cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
1041 // << VF.File().Archive() << endl;
1042 // }
1043 
1044  // Locate the associated index files so we can derive a description
1045  for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S)
1046  {
1047  vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
1048  for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
1049  IF != Indexes->end(); ++IF)
1050  {
1051  if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File())
1052  {
1053  cout << setw(10) << Pkg.FullName(true) << " | " << setw(10) << V.VerStr() << " | "
1054  << (*IF)->Describe(true) << endl;
1055  }
1056  }
1057  }
1058  }
1059  }
1060  }
1061 
1062  SrcRecs.Restart();
1063  pkgSrcRecords::Parser *SrcParser;
1064  bool foundSomething = false;
1065  while ((SrcParser = SrcRecs.Find(*I, false)) != 0)
1066  {
1067  foundSomething = true;
1068  // Maybe support Release info here too eventually
1069  cout << setw(10) << SrcParser->Package() << " | "
1070  << setw(10) << SrcParser->Version() << " | "
1071  << SrcParser->Index().Describe(true) << endl;
1072  }
1073  if (foundSomething == true)
1074  _error->RevertToStack();
1075  else
1076  _error->MergeWithStack();
1077  }
1078 
1079  return true;
1080 }
1081  /*}}}*/
1082 // GenCaches - Call the main cache generator /*{{{*/
1083 // ---------------------------------------------------------------------
1084 /* */
1085 static bool GenCaches(CommandLine &)
1086 {
1087  OpTextProgress Progress(*_config);
1088 
1090  return CacheFile.BuildCaches(&Progress, true);
1091 }
1092  /*}}}*/
1093 static bool ShowHelp(CommandLine &) /*{{{*/
1094 {
1095  std::cout <<
1096  _("Usage: apt-cache [options] command\n"
1097  " apt-cache [options] show pkg1 [pkg2 ...]\n"
1098  "\n"
1099  "apt-cache queries and displays available information about installed\n"
1100  "and installable packages. It works exclusively on the data acquired\n"
1101  "into the local cache via the 'update' command of e.g. apt-get. The\n"
1102  "displayed information may therefore be outdated if the last update was\n"
1103  "too long ago, but in exchange apt-cache works independently of the\n"
1104  "availability of the configured sources (e.g. offline).\n");
1105  return true;
1106 }
1107  /*}}}*/
1108 static std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
1109 {
1110  return {
1111  {"gencaches",&GenCaches, nullptr},
1112  {"showsrc",&ShowSrcPackage, _("Show source records")},
1113  {"showpkg",&DumpPackage, nullptr},
1114  {"stats",&Stats, nullptr},
1115  {"dump",&Dump, nullptr},
1116  {"dumpavail",&DumpAvail, nullptr},
1117  {"unmet",&UnMet, nullptr},
1118  {"search",&DoSearch, _("Search the package list for a regex pattern")},
1119  {"depends",&Depends, _("Show raw dependency information for a package")},
1120  {"rdepends",&RDepends, _("Show reverse dependency information for a package")},
1121  {"dotty",&Dotty, nullptr},
1122  {"xvcg",&XVcg, nullptr},
1123  {"show",&ShowPackage, _("Show a readable record for the package")},
1124  {"pkgnames",&ShowPkgNames, _("List the names of all packages in the system")},
1125  {"showauto",&ShowAuto, nullptr},
1126  {"policy",&Policy, _("Show policy settings")},
1127  {"madison",&Madison, nullptr},
1128  {nullptr, nullptr, nullptr}
1129  };
1130 }
1131  /*}}}*/
1132 int main(int argc,const char *argv[]) /*{{{*/
1133 {
1134  // Parse the command line and initialize the package library
1135  CommandLine CmdL;
1136  auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
1137 
1138  InitOutput();
1139 
1140  if (_config->Exists("APT::Cache::Generate") == true)
1141  _config->Set("pkgCacheFile::Generate", _config->FindB("APT::Cache::Generate", true));
1142 
1143  return DispatchCommandLine(CmdL, Cmds);
1144 }
1145  /*}}}*/
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
static bool XVcg(CommandLine &CmdL)
Definition: apt-cache.cc:536
static bool Dump(CommandLine &)
Definition: apt-cache.cc:344
static void ShowHashTableStats(char const *const Type, T *StartP, map_pointer< T > *Hashtable, unsigned long Size, map_pointer< T >(*Next)(T const *const))
Definition: apt-cache.cc:140
static bool ShowHelp(CommandLine &)
Definition: apt-cache.cc:1093
static bool Dotty(CommandLine &CmdL)
Definition: apt-cache.cc:749
static std::vector< aptDispatchWithHelp > GetCommands()
Definition: apt-cache.cc:1108
static map_pointer< pkgCache::Package > PackageNext(pkgCache::Package const *const P)
Definition: apt-cache.cc:137
#define APT_CACHESIZE(X, Y)
static bool DumpAvail(CommandLine &)
Definition: apt-cache.cc:396
static bool DumpPackage(CommandLine &CmdL)
Definition: apt-cache.cc:72
static bool Madison(CommandLine &CmdL)
Definition: apt-cache.cc:1012
static bool GenCaches(CommandLine &)
Definition: apt-cache.cc:1085
static bool ShowAuto(CommandLine &)
Definition: apt-cache.cc:950
int main(int argc, const char *argv[])
Definition: apt-cache.cc:1132
static bool Stats(CommandLine &CmdL)
Definition: apt-cache.cc:181
static map_pointer< pkgCache::Group > GroupNext(pkgCache::Group const *const G)
Definition: apt-cache.cc:138
static bool ShowPkgNames(CommandLine &CmdL)
Definition: apt-cache.cc:977
const_iterator begin() const
Definition: cacheset.h:371
static PackageContainer FromString(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper)
returns all packages specified by a string
Definition: cacheset.h:461
static PackageContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper)
returns all packages specified on the commandline
Definition: cacheset.h:478
const_iterator end() const
Definition: cacheset.h:372
static std::map< unsigned short, PackageContainer > GroupedFromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::list< CacheSetHelper::PkgModifier > const &mods, unsigned short const &fallback, CacheSetHelper &helper)
group packages by a action modifiers
Definition: cacheset.h:499
bool BuildCaches(bool WithLock=true)
const char ** FileList
Definition: cmndline.h:78
unsigned int FileSize() const APT_PURE
Definition: cmndline.cc:353
Definition: fileutl.h:39
bool OpenDescriptor(int Fd, unsigned int const Mode, CompressMode Compress, bool AutoClose=false)
Definition: fileutl.cc:2572
@ Extension
Definition: fileutl.h:80
@ WriteOnly
Definition: fileutl.h:60
@ ReadOnly
Definition: fileutl.h:59
bool Write(const void *From, unsigned long long Size)
Definition: fileutl.cc:2819
bool Seek(unsigned long long To)
Definition: fileutl.cc:2875
bool Read(void *To, unsigned long long Size, bool AllowEof)
Definition: fileutl.h:89
@ NOTICE
deprecation warnings, old fallback behavior, …
Definition: error.h:64
pkgPolicy * GetPolicy()
Definition: cachefile.h:75
pkgDepCache * GetDepCache()
Definition: cachefile.h:74
pkgSourceList * GetSourceList()
Definition: cachefile.h:76
bool BuildPolicy(OpProgress *Progress=NULL)
Definition: cachefile.cc:167
pkgCache * GetPkgCache()
Definition: cachefile.h:73
virtual std::string Describe(bool const Short=false) const =0
virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg) APT_OVERRIDE
Definition: policy.cc:140
const_iterator begin() const
Definition: sourcelist.h:97
const_iterator end() const
Definition: sourcelist.h:98
std::vector< metaIndex * >::const_iterator const_iterator
Definition: sourcelist.h:76
const pkgIndexFile & Index() const
Definition: srcrecords.h:59
virtual std::string Version() const =0
virtual std::string Package() const =0
bool Restart()
Definition: srcrecords.cc:76
Parser * Find(const char *Package, bool const &SrcOnly=false)
Definition: srcrecords.cc:111
APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const Restart=true)
searches the boundaries of the current section
Definition: tagfile.cc:484
bool Write(FileFd &File, char const *const *const Order=NULL, std::vector< Tag > const &Rewrite=std::vector< Tag >()) const
Definition: tagfile.cc:999
Configuration * _config
pkgCache - Structure definitions for the cache file
uint32_t map_id_t
Definition: pkgcache.h:93
pkgSystem * _system
Definition: pkgsystem.cc:24
std::vector< CommandLine::Dispatch > ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary, Configuration *const *const Cnf, pkgSystem **const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &), std::vector< aptDispatchWithHelp >(*GetCommands)(void))
unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector< CommandLine::Dispatch > const &Cmds)
bool RDepends(CommandLine &CmdL)
bool Depends(CommandLine &CmdL)
bool InitOutput(std::basic_streambuf< char > *const out)
bool DoSearch(CommandLine &CmdL)
void LocalitySort(pkgCache::VerFile **const begin, unsigned long long const Count, size_t const Size)
bool Policy(CommandLine &CmdL)
bool ShowPackage(CommandLine &CmdL)
bool ShowSrcPackage(CommandLine &CmdL)
bool UnMet(CommandLine &CmdL)
groups architecture depending packages together
Definition: pkgcache.h:415
map_pointer< Group > Next
Link to the next Group.
Definition: pkgcache.h:426
contains information for a single unique package
Definition: pkgcache.h:450
map_pointer< Package > NextPackage
Link to the next package in the same bucket.
Definition: pkgcache.h:470
associates a version with a PackageFile
Definition: pkgcache.h:593
map_filesize_t Offset
position in the package file
Definition: pkgcache.h:599
map_filesize_t Size
Definition: pkgcache.h:601
static Tag Remove(std::string const &Name)
Definition: tagfile.cc:950
string SizeToStr(double Size)
Definition: strutl.cc:437
string TimeRFC1123(time_t Date, bool const NumericTimezone)
Definition: strutl.cc:853
const char * DeNull(const char *s)
Definition: strutl.h:190