[DSE-Dev] Bug#875551: libsemanage does not correctly handle multiple build profiles

Helmut Grohne helmut at subdivi.de
Tue Sep 12 07:18:39 UTC 2017


Source: libsemanage
Version: 2.7-1
Tags: patch
User: helmutg at debian.org
Usertags: rebootstrap

Thanks for adding support for build profiles. However the current
implementation leaves things to be wished for. The idea with profiles is
that you can just specify them and packages will know which ones are
relevant to them and ignore others. Thus the variable DEB_BUILD_PROFILES
was called with a plural. However building libsemanage with stage1 and
another profile causes a gross mess, because it only checks whether
DEB_BUILD_PROFILES is exactly stage1. This is wrong. The typical idiom
here is:

    ineq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
    do something for stage1
    endif

In the attached patch, I am using another idiom that seems like a better
match here:

    ineq ($(filter somebinarypackage,$(DOPACKAGES)),)
    do something for somebinarypackage
    endif

The latter idiom makes renaming profiles easier. Please consider
applying it.

Helmut
-------------- next part --------------
diff --minimal -Nru libsemanage-2.7/debian/changelog libsemanage-2.7/debian/changelog
--- libsemanage-2.7/debian/changelog	2017-09-10 01:07:48.000000000 +0200
+++ libsemanage-2.7/debian/changelog	2017-09-12 07:38:23.000000000 +0200
@@ -1,3 +1,10 @@
+libsemanage (2.7-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Support being built with multiple build profiles. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Tue, 12 Sep 2017 07:38:23 +0200
+
 libsemanage (2.7-1) unstable; urgency=medium
 
   * New upstream release
diff --minimal -Nru libsemanage-2.7/debian/rules libsemanage-2.7/debian/rules
--- libsemanage-2.7/debian/rules	2017-09-10 01:07:48.000000000 +0200
+++ libsemanage-2.7/debian/rules	2017-09-12 07:38:23.000000000 +0200
@@ -3,12 +3,20 @@
 
 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
-ifeq ($(DEB_BUILD_PROFILES),stage1)
-export DH_OPTIONS += -Nruby-semanage -Npython-semanage -Npython3-semanage
-else
+DOPACKAGES = $(shell dh_listpackages)
+
+DH_ADDONS=
+ifneq ($(filter python-semanage,$(DOPACKAGES)),)
 PYVERSIONS = $(shell pyversions -rv)
+DH_ADDONS += --with=python2
+endif
+ifneq ($(filter python3-semanage,$(DOPACKAGES)),)
 PY3VERSIONS = $(shell py3versions -rv)
+DH_ADDONS += --with=python3
+endif
+ifneq ($(filter ruby-semanage,$(DOPACKAGES)),)
 RUBY_VERSIONS := $(shell dh_ruby --print-supported)
+DH_ADDONS += --with=ruby
 endif
 
 # The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable the
@@ -16,24 +24,23 @@
 export DEB_CFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS)
 
 %:
-ifeq ($(DEB_BUILD_PROFILES),stage1)
-	dh $@
-else
-	dh $@ --with python2 --with ruby --with python3
-endif
+	dh $@ $(DH_ADDONS)
 
 override_dh_auto_build:
 	$(MAKE) all LIBBASE="lib/${DEB_HOST_MULTIARCH}" SELINUXEXECDIR="usr/lib/selinux"
 
-ifneq ($(DEB_BUILD_PROFILES),stage1)
-	for version in $(PYVERSIONS); do              \
+ifneq ($(filter python-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(PYVERSIONS); do         \
 	  $(MAKE) pywrap PYTHON=python$$version PYLIBS=; \
 	done;
-	for version in $(PY3VERSIONS); do              \
+endif
+ifneq ($(filter python3-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(PY3VERSIONS); do        \
 	  $(MAKE) pywrap PYTHON=python$$version PYLIBS=; \
 	done;
-
-	for version in $(RUBY_VERSIONS); do              \
+endif
+ifneq ($(filter ruby-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(RUBY_VERSIONS); do      \
 	  $(MAKE) -C src rubywrap RUBY=$$version \
 	    RUBYLIBS="$$($$version -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')"; \
 	done;
@@ -45,24 +52,27 @@
 	  SHLIBDIR="${CURDIR}/debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}" \
 	  SELINUXEXECDIR="${CURDIR}/debian/tmp/usr/lib/selinux"
 
-ifneq ($(DEB_BUILD_PROFILES),stage1)
-	for version in $(PYVERSIONS); do              \
+ifneq ($(filter python-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(PYVERSIONS); do         \
 	  $(MAKE) install-pywrap PYTHON=python$$version  \
 	    PYSITEDIR="${CURDIR}/debian/tmp/usr/lib/python$$version/dist-packages"; \
 	done;
-	for version in $(PY3VERSIONS); do              \
+endif
+ifneq ($(filter python3-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(PY3VERSIONS); do        \
 	  $(MAKE) install-pywrap PYTHON=python$$version  \
 	    PYSITEDIR="${CURDIR}/debian/tmp/usr/lib/python$$version/dist-packages"; \
 	done;
-
-	for version in $(RUBY_VERSIONS); do              \
+endif
+ifneq ($(filter ruby-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(RUBY_VERSIONS); do      \
 	  $(MAKE) -C src install-rubywrap RUBY=$$version DESTDIR="${CURDIR}/debian/tmp"; \
 	done;
 endif
 
 override_dh_auto_clean:
-ifneq ($(DEB_BUILD_PROFILES),stage1)
-	for version in $(PYVERSIONS); do              \
+ifneq ($(filter python-semanage,$(DOPACKAGES)),)
+	set -e; for version in $(PYVERSIONS); do         \
 	  $(MAKE) clean PYTHON=python$$version;  \
 	done;
 endif
@@ -72,8 +82,12 @@
 
 override_dh_fixperms:
 	dh_fixperms
-	-chmod -x ${CURDIR}/debian/python-semanage/usr/lib/python*/*-packages/semanage.py
-	-chmod -x ${CURDIR}/debian/python3-semanage/usr/lib/python*/*-packages/semanage.py
+ifneq ($(filter python-semanage,$(DOPACKAGES)),)
+	chmod -x ${CURDIR}/debian/python-semanage/usr/lib/python*/*-packages/semanage.py
+endif
+ifneq ($(filter python3-semanage,$(DOPACKAGES)),)
+	chmod -x ${CURDIR}/debian/python3-semanage/usr/lib/python*/*-packages/semanage.py
+endif
 
 override_dh_auto_test:
 	$(MAKE) test || true


More information about the SELinux-devel mailing list