[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Export the source version from dpkg-buildpackage



Some build scripts might need the version in order to embed it in the
build result. Most usually they run dpkg-parsechangelog and massage it
from there.

This patch makes dpkg-buildpackage export this as DEB_SOURCE_VERSION so
that it's available directly (and should remove duplicate code from
packages that want it).
---
 Note that I don't know if this is the right way, or I should have
 instead opened a bug. Please CC me, not subscribed to the list.

 man/dpkg-buildpackage.1      |    8 ++++++++
 scripts/dpkg-buildpackage.pl |    3 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index e2c9643..5bbf04a 100644
--- a/man/dpkg-buildpackage.1
+++ b/man/dpkg-buildpackage.1
@@ -298,6 +298,14 @@ Optimization options appended to the compiler flags when linking code,
 which must not be overwritten by the package (mostly used to for test
 builds). Default value: empty.
 .
+.SS Other variables
+Additionally, dpkg-buildpackage exports:
+.TP
+.B DEB_SOURCE_VERSION
+The source version as parsed from the changelog; this removes the need
+for the build rules to compute it via dpkg-parsechangelog if they need
+this information.
+.
 .SH BUGS
 It should be possible to specify spaces and shell metacharacters in
 and initial arguments for
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index cf39187..9d059f0 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -339,6 +339,9 @@ unless ($sourceonly) {
     $arch = 'source';
 }
 
+# Export the source version
+$ENV{DEB_SOURCE_VERSION} = $version;
+
 # Preparation of environment stops here
 
 (my $sversion = $version) =~ s/^\d+://;
-- 
1.6.5.7


Reply to: