Browse Source

libdpkg: Add virtual source:Upstream-Version field

Closes: #844348
Guillem Jover 7 years ago
parent
commit
94b53bdeaf
3 changed files with 19 additions and 0 deletions
  1. 1 0
      debian/changelog
  2. 14 0
      lib/dpkg/pkg-format.c
  3. 4 0
      man/dpkg-query.man

+ 1 - 0
debian/changelog

@@ -26,6 +26,7 @@ dpkg (1.18.16) UNRELEASED; urgency=medium
     install stuff but are reminded they need to get a fixed filesystem in
     place. This has affected at least ecryptfs in the past and now
     file-based encryption support in ext4 on Android N.
+  * Add new dpkg-query virtual field source:Upstream-Version. Closes: #84434
   * Perl modules:
     - Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
       DPKG_DATADIR environment variables in Dpkg::Build::Info.

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

@@ -306,6 +306,19 @@ virt_source_version(struct varbuf *vb,
 	varbuf_add_source_version(vb, pkg, pkgbin);
 }
 
+static void
+virt_source_upstream_version(struct varbuf *vb,
+                             const struct pkginfo *pkg, const struct pkgbin *pkgbin,
+                             enum fwriteflags flags, const struct fieldinfo *fip)
+{
+	struct dpkg_version version;
+
+	pkg_source_version(&version, pkg, pkgbin);
+
+	varbuf_add_str(vb, version.version);
+	varbuf_end_str(vb);
+}
+
 static const struct fieldinfo virtinfos[] = {
 	{ FIELD("binary:Package"), NULL, virt_package },
 	{ FIELD("binary:Summary"), NULL, virt_summary },
@@ -315,6 +328,7 @@ static const struct fieldinfo virtinfos[] = {
 	{ FIELD("db:Status-Eflag"), NULL, virt_status_eflag },
 	{ FIELD("source:Package"), NULL, virt_source_package },
 	{ FIELD("source:Version"), NULL, virt_source_version },
+	{ FIELD("source:Upstream-Version"), NULL, virt_source_upstream_version },
 	{ NULL },
 };
 

+ 4 - 0
man/dpkg-query.man

@@ -276,6 +276,10 @@ It contains the source package name for this binary package
 .B source:Version
 It contains the source package version for this binary package
 (since dpkg 1.16.2)
+.TP
+.B source:Upstream-Version
+It contains the source package upstream version for this binary package
+(since dpkg 1.18.16)
 .RE
 .IP
 The default format string is “\fB${binary:Package}\et${Version}\en\fP”.