| author | Guillem Jover <guillem@debian.org> | |
| Sat, 17 Jul 2010 16:28:56 +0000 (18:28 +0200) | ||
| committer | Guillem Jover <guillem@debian.org> | |
| Thu, 22 Dec 2011 06:12:11 +0000 (07:12 +0100) |
This adds support for show:Summary and show:Status-Abbrev virtual
output fields. They get namespaced with “show:” to not stomp over
possible fields with the same name coming from binary package or
databases, which would make them inaccessible from dpkg-query.
Closes: #192619, #427945
output fields. They get namespaced with “show:” to not stomp over
possible fields with the same name coming from binary package or
databases, which would make them inaccessible from dpkg-query.
Closes: #192619, #427945
| debian/changelog | patch | blob | history | |
| lib/dpkg/pkg-format.c | patch | blob | history | |
| man/dpkg-query.1 | patch | blob | history |
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
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
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
#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 {
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
--- a/man/dpkg-query.1
+++ b/man/dpkg-query.1
\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.
