Source: collectd
Version: 5.8.0-5.2
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

I looked into cross building collectd and that turns out to be
difficult. However one thing became apparent quite quickly to me:
debian/rules confuses build and host. These terms are defined in man
dpkg-architecture. Furthermore, debian/rules tries to match everything
against the Debian architecture name, but there are better ways to match
e.g. the kernel. The attached patch fixes that. Please consider applying
it. Please also consider going beyond. For instance, a comment says
"These plugins are Intel-hardware specific.". If that is really the
case, then maybe use "ifeq (,$(filter amd64 i386,$(DEB_HOST_ARCH_CPU)))".
Doing so would additionally match kfreebsd-amd64, hurd-i386 and x32. I'm
not sure whether that's appropriate.

Before looking further into cross building collectd, I'll need to file a
patch for libvirt.

Helmut
diff --minimal -Nru collectd-5.8.0/debian/rules collectd-5.8.0/debian/rules
--- collectd-5.8.0/debian/rules	2018-08-06 20:36:32.000000000 +0200
+++ collectd-5.8.0/debian/rules	2018-11-13 06:09:53.000000000 +0100
@@ -8,9 +8,7 @@
 
 # These are used for cross-compiling and for saving the configure script
 # from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_ARCH      ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+include /usr/share/dpkg/architecture.mk
 
 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
 
@@ -28,7 +26,7 @@
 
 # A PostgreSQL header redefines CACHE_LINE_SIZE on FreeBSD.
 # Cf. https://bugs.debian.org/760719 and https://bugs.debian.org/763098
-ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	CPPFLAGS += -Wp,-w
 endif
 
@@ -95,7 +93,7 @@
 confflags += --disable-varnish
 
 # These plugins are Linux-specific.
-ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	confflags += \
 		--disable-barometer \
 		--disable-cgroups \
@@ -117,7 +115,7 @@
 endif
 
 # This plugin is FreeBSD-specific.
-ifeq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifneq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	confflags += \
 		--disable-pf
 endif
@@ -127,7 +125,7 @@
 		--disable-zone
 
 # These plugins have not been ported to FreeBSD yet.
-ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	# Work-around an incomplete check for kvm functionality
 	CPPFLAGS  += -DHAVE_STRUCT_KINFO_PROC_FREEBSD
 	confflags += --enable-processes=force
@@ -150,7 +148,7 @@
 endif
 
 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
-ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	confflags += \
 		--disable-gmond \
 		--disable-virt \
@@ -159,7 +157,7 @@
 endif
 
 # These plugins are Intel-hardware specific.
-ifeq (,$(filter amd64 i386, $(DEB_BUILD_ARCH)))
+ifeq (,$(filter amd64 i386, $(DEB_HOST_ARCH)))
 	confflags += \
 		--disable-dpdkevents \
 		--disable-dpdkstat \
@@ -171,25 +169,25 @@
 endif
 
 # This plugin is x86 and arm specific.
-ifeq (,$(filter amd64 arm64 armhf i386, $(DEB_BUILD_ARCH)))
+ifeq (,$(filter amd64 arm64 armhf i386, $(DEB_HOST_ARCH)))
 	confflags += \
 		--disable-xencpu
 endif
 
 # libatasmart isn't available on these platforms.
-ifneq (,$(filter hurd-i386 kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
+ifneq (,$(filter hurd kfreebsd,$(DEB_HOST_ARCH_OS)))
 	confflags += --disable-smart
 endif
 
 # The hppa buildds currently do not keep up with Java related stuff, thus
 # prevending testing transitions. sparc is also having trouble building the
 # java plugin.
-ifneq (,$(filter hppa sparc, $(DEB_BUILD_ARCH)))
+ifneq (,$(filter hppa sparc, $(DEB_HOST_ARCH)))
 	confflags += --disable-java
 endif
 
 # gRPC is only available on x86, arm, ppc.
-ifeq (,$(filter amd64 arm64 armel armhf i386 ppc64el powerpc, $(DEB_BUILD_ARCH)))
+ifeq (,$(filter amd64 arm64 armel armhf i386 ppc64el powerpc, $(DEB_HOST_ARCH)))
 	confflags += --disable-grpc
 endif
 

Reply via email to