瀏覽代碼

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 年之前
父節點
當前提交
8aecb71520
共有 3 個文件被更改,包括 41 次插入0 次删除
  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
   * 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
     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.
     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 ]
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127
   * 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));
 	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
 static void
 virt_summary(struct varbuf *vb,
 virt_summary(struct varbuf *vb,
              const struct pkginfo *pkg, const struct pkgbin *pkgbin,
              const struct pkginfo *pkg, const struct pkgbin *pkgbin,
@@ -297,6 +330,9 @@ const struct fieldinfo virtinfos[] = {
 	{ "binary:Package", NULL, virt_package },
 	{ "binary:Package", NULL, virt_package },
 	{ "binary:Summary", NULL, virt_summary },
 	{ "binary:Summary", NULL, virt_summary },
 	{ "db:Status-Abbrev", NULL, virt_status_abbrev },
 	{ "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:Package", NULL, virt_source_package },
 	{ "source:Version", NULL, virt_source_version },
 	{ "source:Version", NULL, virt_source_version },
 	{ NULL },
 	{ NULL },

+ 3 - 0
man/dpkg-query.1

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