On Wed, 20 Jul 2011, Raphael Hertzog wrote:
> Forgot to expand a bit: the version related variables are commonly used in
> "get-orig-source" targets, and it would be nice to factor out the version
> splitting logic.
> 
> The source package name is often the same as the name of the only
> binary package and it's also relatively frequently used to avoid
> hardcoding debian/packagename/ everywhere in the rules files.
> 
> Thus my personal preference would be to provide something to cover
> those use cases.

I attached a patch for this. I ended up diverging slightly on the
variable names to be more consistent.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Follow my Debian News ▶ http://RaphaelHertzog.com (English)
                      ▶ http://RaphaelHertzog.fr (Français)
commit 1257e741acbf1d9df9068441e337c0b9a337d3a6
Author: Raphaël Hertzog <hert...@debian.org>
Date:   Fri Jul 29 16:18:52 2011 +0200

    Provide a new makefile snippet exporting basic package information

diff --git a/scripts/mk/Makefile.am b/scripts/mk/Makefile.am
index 710578d..784adf1 100644
--- a/scripts/mk/Makefile.am
+++ b/scripts/mk/Makefile.am
@@ -4,6 +4,7 @@ dist_pkgdata_DATA = \
        architecture.mk \
        buildflags.mk \
        default.mk \
+       pkg-info.mk \
        vendor.mk
 
 do_path_subst = $(AM_V_GEN) \
diff --git a/scripts/mk/default.mk b/scripts/mk/default.mk
index 9f9d61b..b4b123c 100644
--- a/scripts/mk/default.mk
+++ b/scripts/mk/default.mk
@@ -4,4 +4,5 @@
 dpkg_datadir = .
 include $(dpkg_datadir)/architecture.mk
 include $(dpkg_datadir)/buildflags.mk
+include $(dpkg_datadir)/pkg-info.mk
 include $(dpkg_datadir)/vendor.mk
diff --git a/scripts/mk/pkg-info.mk b/scripts/mk/pkg-info.mk
new file mode 100644
index 0000000..b75f2ea
--- /dev/null
+++ b/scripts/mk/pkg-info.mk
@@ -0,0 +1,17 @@
+# Makefile snippet defining the following variables:
+#
+# DEB_SOURCE_PACKAGE: the source package name
+# DEB_VERSION: the full version of the package
+# DEB_VERSION_NOREV: the package's version without the Debian revision
+# DEB_VERSION_NOEPOCH: the package's version without the Debian epoch
+# DEB_VERSION_UPSTREAM: the package's upstream version
+# DEB_DISTRIBUTION: the first distribution of the current entry in 
debian/changelog
+
+dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := 
$(shell $(2)))$(value DPKG_CACHE_$(1)))
+
+DEB_SOURCE_PACKAGE = $(call dpkg_late_eval,DEB_SOURCE_PACKAGE,awk '/^Source: / 
{ print $$2 }' debian/control)
+DEB_VERSION = $(call dpkg_late_eval,DEB_VERSION,dpkg-parsechangelog | awk 
'/^Version: / { print $$2 }')
+DEB_VERSION_NOREV = $(call dpkg_late_eval,DEB_VERSION_NOREV,echo 
'$(DEB_VERSION)' | sed -e 's/-[^-]*$$//')
+DEB_VERSION_NOEPOCH = $(call dpkg_late_eval,DEB_VERSION_NOEPOCH,echo 
'$(DEB_VERSION)' | sed -e 's/^[0-9]*://')
+DEB_VERSION_UPSTREAM = $(call dpkg_late_eval,DEB_VERSION_UPSTREAM,echo 
'$(DEB_VERSION_NOREV)' | sed -e 's/^[0-9]*://')
+DEB_DISTRIBUTION = $(call dpkg_late_eval,DEB_DISTRIBUTION,dpkg-parsechangelog 
| awk '/^Distribution: / { print $$2 }')

Reply via email to