// Includes /*{{{*/
-#include <apt-pkg/error.h>
+#include <config.h>
+
#include <apt-pkg/cachefile.h>
-#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
-#include <apti18n.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-show.h>
+
+#include <stdio.h>
+#include <ostream>
+#include <string>
-#include "private-output.h"
-#include "private-cacheset.h"
-#include "private-show.h"
+#include <apti18n.h>
/*}}}*/
namespace APT {
// DisplayRecord - Displays the complete record for the package /*{{{*/
// ---------------------------------------------------------------------
static bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
- ostream &out)
+ std::ostream &out)
{
pkgCache *Cache = CacheFile.GetPkgCache();
if (unlikely(Cache == NULL))
if (is_installed)
manual_installed = !(state.Flags & pkgCache::Flag::Auto) ? "yes" : "no";
else
- manual_installed = 0;
+ manual_installed = "";
// FIXME: add verbose that does not do the removal of the tags?
- TFRewriteData RW[] = {
- // 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"},
- // 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)
+ std::vector<pkgTagSection::Tag> RW;
+ // delete, apt-cache show has this info and most users do not care
+ RW.push_back(pkgTagSection::Tag::Remove("MD5sum"));
+ RW.push_back(pkgTagSection::Tag::Remove("SHA1"));
+ RW.push_back(pkgTagSection::Tag::Remove("SHA256"));
+ RW.push_back(pkgTagSection::Tag::Remove("SHA512"));
+ RW.push_back(pkgTagSection::Tag::Remove("Filename"));
+ RW.push_back(pkgTagSection::Tag::Remove("Multi-Arch"));
+ RW.push_back(pkgTagSection::Tag::Remove("Architecture"));
+ RW.push_back(pkgTagSection::Tag::Remove("Conffiles"));
+ // we use the translated description
+ RW.push_back(pkgTagSection::Tag::Remove("Description"));
+ RW.push_back(pkgTagSection::Tag::Remove("Description-md5"));
+ // improve
+ RW.push_back(pkgTagSection::Tag::Rewrite("Installed-Size", installed_size));
+ RW.push_back(pkgTagSection::Tag::Remove("Size"));
+ RW.push_back(pkgTagSection::Tag::Rewrite("Download-Size", package_size));
+ // add
+ RW.push_back(pkgTagSection::Tag::Rewrite("APT-Manual-Installed", manual_installed));
+ RW.push_back(pkgTagSection::Tag::Rewrite("APT-Sources", source_index_file));
+
+ FileFd stdoutfd;
+ if (stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false) == false ||
+ Tags.Write(stdoutfd, TFRewritePackageOrder, RW) == false || stdoutfd.Close() == false)
return _error->Error("Internal Error, Unable to parse a package record");
// write the description
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", false) ?
- APT::VersionList::ALL : APT::VersionList::CANDIDATE;
+ APT::CacheSetHelper::VerSelector const select = _config->FindB("APT::Cache::AllVersions", false) ?
+ APT::CacheSetHelper::ALL : APT::CacheSetHelper::CANDIDATE;
APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
if (DisplayRecord(CacheFile, Ver, c1out) == false)
return false;
- if (select == APT::VersionList::CANDIDATE)
+ if (select == APT::CacheSetHelper::CANDIDATE)
{
- APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::ALL, helper);
+ APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::CacheSetHelper::ALL, helper);
int const records = verset_all.size() - verset.size();
if (records > 0)
_error->Notice(P_("There is %i additional record. Please use the '-a' switch to see it", "There are %i additional records. Please use the '-a' switch to see them.", records), records);