From 91e2ae0b74d9efb47a5635466a8e0f0826c0a0e8 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 27 Nov 2018 04:05:09 +0100 Subject: scripts/mk: Add support for an improved dpkg_vendor_derives_from macro Version the macros so that both can be used, and default the unversioned one to the version 0 macro. --- debian/changelog | 3 +++ scripts/Makefile.am | 2 ++ scripts/mk/vendor.mk | 38 +++++++++++++++++++++++++++++++------- scripts/t/mk.t | 4 +++- scripts/t/mk/vendor-v0.mk | 6 ++++++ scripts/t/mk/vendor-v1.mk | 6 ++++++ scripts/t/mk/vendor.mk | 1 + 7 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 scripts/t/mk/vendor-v0.mk create mode 100644 scripts/t/mk/vendor-v1.mk diff --git a/debian/changelog b/debian/changelog index 4a4446434..aa84c615e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,9 @@ dpkg (1.19.3) UNRELEASED; urgency=medium Reported by Andreas Beckmann . Closes: #916799 * vendor.mk: Fix dpkg_vendor_derives_from macro documentation. Thanks to Colin Watson . Closes: #913816 + * vendor.mk: Add support for an improved dpkg_vendor_derives_from macro. + Version the macros so that both can be used, and default the unversioned + one to the version 0 macro. * Perl modules: - Dpkg::Changelog::Debian: Preserve modelines at EOF. Closes: #916056 Thanks to Chris Lamb for initial test cases. diff --git a/scripts/Makefile.am b/scripts/Makefile.am index aacd630fc..ea8aef557 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -364,6 +364,8 @@ test_data = \ t/mk/buildflags.mk \ t/mk/buildtools.mk \ t/mk/pkg-info.mk \ + t/mk/vendor-v0.mk \ + t/mk/vendor-v1.mk \ t/mk/vendor.mk \ t/origins/debian \ t/origins/default \ diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk index fe06828f5..f3b1565bb 100644 --- a/scripts/mk/vendor.mk +++ b/scripts/mk/vendor.mk @@ -3,16 +3,40 @@ # DEB_VENDOR: output of dpkg-vendor --query Vendor # DEB_PARENT_VENDOR: output of dpkg-vendor --query Parent (can be empty) # -# The snippet also defines a macro "dpkg_vendor_derives_from" that you can -# use to verify if the current vendor derives from another vendor with a -# simple test like this one: -# ifeq ($(shell $(call dpkg_vendor_derives_from,ubuntu)),yes) -# ... -# endif +# This Makefile snippet also defines a set "dpkg_vendor_derives_from" +# macros that can be used to verify if the current vendor derives from +# another vendor. The unversioned variant defaults to the v0 version if +# undefined, which can be defined explicitly to one of the versions or the +# versioned macros can be used directly. The following are example usages: +# +# - dpkg_vendor_derives_from (since dpkg 1.16.1) +# +# ifeq ($(shell $(call dpkg_vendor_derives_from,ubuntu)),yes) +# ... +# endif +# +# - dpkg_vendor_derives_from_v0 (since dpkg 1.19.3) +# +# ifeq ($(shell $(call dpkg_vendor_derives_from_v0,ubuntu)),yes) +# ... +# endif +# +# - dpkg_vendor_derives_from_v1 (since dpkg 1.19.3) +# +# dpkg_vendor_derives_from = $(dpkg_vendor_derives_from_v1) +# ifeq ($(call dpkg_vendor_derives_from,ubuntu),yes) +# ... +# endif +# ifeq ($(call dpkg_vendor_derives_from_v1,ubuntu),yes) +# ... +# endif dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1))) DEB_VENDOR = $(call dpkg_late_eval,DEB_VENDOR,dpkg-vendor --query Vendor) DEB_PARENT_VENDOR = $(call dpkg_late_eval,DEB_PARENT_VENDOR,dpkg-vendor --query Parent) -dpkg_vendor_derives_from = dpkg-vendor --derives-from $(1) && echo yes || echo no +dpkg_vendor_derives_from_v0 = dpkg-vendor --derives-from $(1) && echo yes || echo no +dpkg_vendor_derives_from_v1 = $(shell $(dpkg_vendor_derives_from_v0)) + +dpkg_vendor_derives_from ?= $(dpkg_vendor_derives_from_v0) diff --git a/scripts/t/mk.t b/scripts/t/mk.t index 0062e993c..98c7e5083 100644 --- a/scripts/t/mk.t +++ b/scripts/t/mk.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 8; use Test::Dpkg qw(:paths); use File::Spec::Functions qw(rel2abs); @@ -117,5 +117,7 @@ foreach my $tool (keys %buildtools) { test_makefile('pkg-info.mk'); test_makefile('vendor.mk'); +test_makefile('vendor-v0.mk'); +test_makefile('vendor-v1.mk'); 1; diff --git a/scripts/t/mk/vendor-v0.mk b/scripts/t/mk/vendor-v0.mk new file mode 100644 index 000000000..602a8c63a --- /dev/null +++ b/scripts/t/mk/vendor-v0.mk @@ -0,0 +1,6 @@ +dpkg_vendor_derives_from = $(dpkg_vendor_derives_from_v0) + +include $(srcdir)/mk/vendor.mk + +test: + test "$(shell $(call dpkg_vendor_derives_from,debian))" = "yes" diff --git a/scripts/t/mk/vendor-v1.mk b/scripts/t/mk/vendor-v1.mk new file mode 100644 index 000000000..11c1314ef --- /dev/null +++ b/scripts/t/mk/vendor-v1.mk @@ -0,0 +1,6 @@ +include $(srcdir)/mk/vendor.mk + +dpkg_vendor_derives_from = $(dpkg_vendor_derives_from_v1) + +test: + test "$(call dpkg_vendor_derives_from,debian)" = "yes" diff --git a/scripts/t/mk/vendor.mk b/scripts/t/mk/vendor.mk index 371b39c87..4e0d9ff89 100644 --- a/scripts/t/mk/vendor.mk +++ b/scripts/t/mk/vendor.mk @@ -3,3 +3,4 @@ include $(srcdir)/mk/vendor.mk test: test "$(DEB_VENDOR)" = "Debian" test "$(DEB_PARENT_VENDOR)" = "" + test "$(shell $(call dpkg_vendor_derives_from,debian))" = "yes" -- cgit v1.2.3