summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog2
-rw-r--r--lib/dpkg/pkg-format.c29
-rw-r--r--man/dpkg-query.12
3 files changed, 33 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 3866df3..c4929aa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -43,6 +43,8 @@ dpkg (1.16.2) UNRELEASED; urgency=low
instead of dh_install, the former does not abort on empty glob expansion.
* Do not use absolute paths for programs in perl and shell code.
* Add missing ‘*’ in asprintf() and vasprintf() compat declarations.
+ * Add support for virtual output fields show:Summary and show:Status-Abbrev.
+ Closes: #192619, #427945
[ Raphaël Hertzog ]
* Update Dpkg::Shlibs to look into multiarch paths when cross-building
diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c
index d43e3cf..71d06f7 100644
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
@@ -30,6 +30,7 @@
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/parsedump.h>
+#include <dpkg/pkg-show.h>
#include <dpkg/pkg-format.h>
enum pkg_format_type {
@@ -201,7 +202,35 @@ pkg_format_parse(const char *fmt)
return head;
}
+static void
+virt_status_abbrev(struct varbuf *vb,
+ const struct pkginfo *pkg, const struct pkgbin *pkgbin,
+ enum fwriteflags flags, const struct fieldinfo *fip)
+{
+ if (pkgbin != &pkg->installed)
+ return;
+
+ varbuf_add_char(vb, pkg_abbrev_want(pkg));
+ varbuf_add_char(vb, pkg_abbrev_status(pkg));
+ varbuf_add_char(vb, pkg_abbrev_eflag(pkg));
+}
+
+static void
+virt_summary(struct varbuf *vb,
+ const struct pkginfo *pkg, const struct pkgbin *pkgbin,
+ enum fwriteflags flags, const struct fieldinfo *fip)
+{
+ const char *desc;
+ int len;
+
+ desc = pkg_summary(pkg, &len);
+
+ varbuf_add_buf(vb, desc, len);
+}
+
const struct fieldinfo virtinfos[] = {
+ { "show:Summary", NULL, virt_summary },
+ { "show:Status-Abbrev", NULL, virt_status_abbrev },
{ NULL },
};
diff --git a/man/dpkg-query.1 b/man/dpkg-query.1
index 8ddf7ea..c37c43f 100644
--- a/man/dpkg-query.1
+++ b/man/dpkg-query.1
@@ -179,6 +179,8 @@ fields or fields stored in the binary package end up in it):
\fBTriggers\-Awaited\fP (internal)
\fBTriggers\-Pending\fP (internal)
\fBVersion\fP
+ \fBshow:Summary\fP (virtual)
+ \fBshow:Status-Abbrev\fP (virtual)
.fi
The default format string is \(lq\fB${Package}\et${Version}\en\fP\(rq.