summaryrefslogtreecommitdiff
path: root/apt-private/private-show.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-22 17:18:26 +0100
committerMichael Vogt <mvo@debian.org>2014-01-22 17:18:26 +0100
commit9e51c0b6a3a1a36336820eda11bcfd5534d9d80c (patch)
tree762c18d7ca6a62ce52fdcee00aa0958f44d6341d /apt-private/private-show.cc
parent6d73fe5be080e66a4f6ff2b250ed1957ae7ac063 (diff)
"apt show" show user friendly size info
The size/installed-size is displayed via SizeToStr() and Size is rewriten to "Download-Size" to make clear what size is refered to here.
Diffstat (limited to 'apt-private/private-show.cc')
-rw-r--r--apt-private/private-show.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index 0aa42ecce..32a49cc5c 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -57,20 +57,32 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
return false;
pkgTagSection Tags;
pkgTagFile TagF(&PkgF);
-
+
+ if (TagF.Jump(Tags, V.FileList()->Offset) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
+
+ // make size nice
+ std::string installed_size;
+ if (Tags.FindI("Installed-Size") > 0)
+ installed_size = SizeToStr(Tags.FindI("Installed-Size")*1024);
+ else
+ installed_size = _("unknown");
+ std::string package_size;
+ if (Tags.FindI("Size") > 0)
+ package_size = SizeToStr(Tags.FindI("Size"));
+ else
+ package_size = _("unknown");
+
TFRewriteData RW[] = {
{"Conffiles",0},
{"Description",0},
{"Description-md5",0},
+ {"Installed-Size", installed_size.c_str(), 0},
+ {"Size", package_size.c_str(), "Download-Size"},
{}
};
- const char *Zero = 0;
- if (TagF.Jump(Tags, V.FileList()->Offset) == false ||
- TFRewrite(stdout,Tags,&Zero,RW) == false)
- {
- _error->Error("Internal Error, Unable to parse a package record");
- return false;
- }
+ if(TFRewrite(stdout, Tags, NULL, RW) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
// write the description
pkgRecords Recs(*Cache);