fix -Wmissing-field-initializers warnings
[ntk/apt.git] / apt-private / private-show.cc
index cee1328..9e4bbd3 100644 (file)
@@ -54,6 +54,15 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
    if (I.IsOk() == false)
       return _error->Error(_("Package file %s is out of sync."),I.FileName());
 
+   // find matching sources.list metaindex
+   pkgSourceList *SrcList = CacheFile.GetSourceList();
+   pkgIndexFile *Index;
+   if (SrcList->FindIndex(I, Index) == false &&
+       _system->FindIndex(I, Index) == false)
+      return _error->Error("Can not find indexfile for Package %s (%s)", 
+                           V.ParentPkg().Name(), V.VerStr());
+   std::string source_index_file = Index->Describe(true);
+
    // Read the record
    FileFd PkgF;
    if (PkgF.Open(I.FileName(), FileFd::ReadOnly, FileFd::Extension) == false)
@@ -67,12 +76,12 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
    // make size nice
    std::string installed_size;
    if (Tags.FindI("Installed-Size") > 0)
-      installed_size = SizeToStr(Tags.FindI("Installed-Size")*1024);
+      strprintf(installed_size, "%sB", SizeToStr(Tags.FindI("Installed-Size")*1024).c_str());
    else
       installed_size = _("unknown");
    std::string package_size;
    if (Tags.FindI("Size") > 0)
-      package_size = SizeToStr(Tags.FindI("Size"));
+      strprintf(package_size, "%sB", SizeToStr(Tags.FindI("Size")).c_str());
    else
       package_size = _("unknown");
 
@@ -83,16 +92,27 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
       manual_installed = !(state.Flags & pkgCache::Flag::Auto) ? "yes" : "no";
    else
       manual_installed = 0;
-   std::string suite = GetArchiveSuite(CacheFile, V);
+
+   // FIXME: add verbose that does not do the removal of the tags?
    TFRewriteData RW[] = {
-      {"Conffiles",0},
-      {"Description",0},
-      {"Description-md5",0},
-      {"Installed-Size", installed_size.c_str(), 0},
+      // delete, apt-cache show has this info and most users do not care
+      {"MD5sum", NULL, NULL},
+      {"SHA1", NULL, NULL},
+      {"SHA256", NULL, NULL},
+      {"Filename", NULL, NULL},
+      {"Multi-Arch", NULL, NULL},
+      {"Architecture", NULL, NULL},
+      {"Conffiles", NULL, NULL},
+      // we use the translated description
+      {"Description", NULL, NULL},
+      {"Description-md5", NULL, NULL},
+      // improve
+      {"Installed-Size", installed_size.c_str(), NULL},
       {"Size", package_size.c_str(), "Download-Size"},
-      {"Archive-Origin", suite.c_str(), 0},
-      {"Manual-Installed", manual_installed, 0},
-      {}
+      // add
+      {"APT-Manual-Installed", manual_installed, NULL},
+      {"APT-Sources", source_index_file.c_str(), NULL},
+      {NULL, NULL, NULL}
    };
 
    if(TFRewrite(stdout, Tags, NULL, RW) == false)