Browse Source

libdpkg: Add db:Status-Want, db:Status-Status and db:Status-Eflag fields

These are virtual fields for the database Status field, which will allow
easier access to the specific status values.
Guillem Jover 12 years ago
parent
commit
8aecb71520
3 changed files with 41 additions and 0 deletions
  1. 2 0
      debian/changelog
  2. 36 0
      lib/dpkg/pkg-format.c
  3. 3 0
      man/dpkg-query.1

+ 2 - 0
debian/changelog

@@ -41,6 +41,8 @@ dpkg (1.17.11) UNRELEASED; urgency=low
   * Change «dpkg-deb --field» code to use the libdpkg deb822 parser instead
     of an ad-hoc one. This makes sure any field fixup and sanity check is
     performed on the input, and gets reflected on the output.
+  * Add new dpkg-query virtual fields db:Status-Want, db:Status-Status and
+    db:Status-Eflag to allow fine-grained access to the Status values.
 
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127

+ 36 - 0
lib/dpkg/pkg-format.c

@@ -235,6 +235,39 @@ virt_status_abbrev(struct varbuf *vb,
 	varbuf_add_char(vb, pkg_abbrev_eflag(pkg));
 }
 
+static void
+virt_status_want(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_str(vb, pkg_want_name(pkg));
+}
+
+static void
+virt_status_status(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_str(vb, pkg_status_name(pkg));
+}
+
+static void
+virt_status_eflag(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_str(vb, pkg_eflag_name(pkg));
+}
+
 static void
 virt_summary(struct varbuf *vb,
              const struct pkginfo *pkg, const struct pkgbin *pkgbin,
@@ -297,6 +330,9 @@ const struct fieldinfo virtinfos[] = {
 	{ "binary:Package", NULL, virt_package },
 	{ "binary:Summary", NULL, virt_summary },
 	{ "db:Status-Abbrev", NULL, virt_status_abbrev },
+	{ "db:Status-Want", NULL, virt_status_want },
+	{ "db:Status-Status", NULL, virt_status_status },
+	{ "db:Status-Eflag", NULL, virt_status_eflag },
 	{ "source:Package", NULL, virt_source_package },
 	{ "source:Version", NULL, virt_source_version },
 	{ NULL },

+ 3 - 0
man/dpkg-query.1

@@ -230,6 +230,9 @@ fields in control files):
     \fBbinary:Package\fP
     \fBbinary:Summary\fP
     \fBdb:Status\-Abbrev\fP
+    \fBdb:Status\-Want\fP
+    \fBdb:Status\-Status\fP
+    \fBdb:Status\-Eflag\fP
     \fBsource:Package\fP
     \fBsource:Version\fP
 .fi