Source: libselinux
Followup-For: Bug #1065539

Hello.
The attached suggestion list is rebased on 2bd44832.
>From af7c5de1b7c37b2b5753a87a9141fee21876643a Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 19:38:30 +0100
Subject: [PATCH 01/16] Delegate Built-Using to dh-sequence-builtusing

---
 debian/control | 3 ++-
 debian/rules   | 5 -----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/debian/control b/debian/control
index aedf808..f9f37da 100644
--- a/debian/control
+++ b/debian/control
@@ -8,6 +8,7 @@ Uploaders: Laurent Bigonville <bi...@debian.org>,
            Russell Coker <russ...@coker.com.au>
 Standards-Version: 4.6.2
 Build-Depends: debhelper-compat (= 13),
+               dh-sequence-builtusing,
                dh-sequence-python3 <!nopython>,
                dh-sequence-ruby <!noruby>,
                file,
@@ -128,7 +129,7 @@ Description: Ruby bindings to SELinux shared libraries
 Package: python3-selinux
 Architecture: linux-any
 Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends}
-Built-Using: ${Built-Using}
+Built-Using: ${dh-builtusing:libsepol-dev}
 Section: python
 Provides: ${python3:Provides}
 Build-Profiles: <!nopython>
diff --git a/debian/rules b/debian/rules
index 3dd799b..f01918d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -26,8 +26,6 @@ endif
 
 DOPACKAGES = $(shell dh_listpackages)
 
-BUILT_USING=$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W "libsepol-dev")
-
 ifeq ($(DEB_HOST_ARCH_BITS),32)
 # Use of lstat64 requires this macro.
 export DEB_CPPFLAGS_MAINT_APPEND += -D_LARGEFILE64_SOURCE
@@ -99,9 +97,6 @@ ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
 	done;
 endif
 
-override_dh_gencontrol:
-	dh_gencontrol -- -VBuilt-Using="$(BUILT_USING)"
-
 override_dh_makeshlibs:
 	dh_makeshlibs -plibselinux1 --add-udeb="libselinux1-udeb" -V
 	dh_makeshlibs --remaining-packages
-- 
2.39.5

>From 1a598c73a44c8d5203db27bacb7fd2f136363579 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 20:26:03 +0100
Subject: [PATCH 02/16] Refine pattern in debian/*.install with
 DEB_HOST_MULTIARCH

---
 debian/libselinux1-dev.install  | 6 +++---
 debian/libselinux1-udeb.install | 2 +-
 debian/libselinux1.install      | 2 +-
 debian/ruby-selinux.install     | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/debian/libselinux1-dev.install b/debian/libselinux1-dev.install
index 9b93167..1169fad 100644
--- a/debian/libselinux1-dev.install
+++ b/debian/libselinux1-dev.install
@@ -1,5 +1,5 @@
 usr/include/selinux/*.h
-usr/lib/*/*.a
-usr/lib/*/*.so
-usr/lib/*/pkgconfig/*.pc
+usr/lib/${DEB_HOST_MULTIARCH}/*.a
+usr/lib/${DEB_HOST_MULTIARCH}/*.so
+usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/*.pc
 usr/share/man/man3/*.3
diff --git a/debian/libselinux1-udeb.install b/debian/libselinux1-udeb.install
index 3de3b10..8b38ff6 100644
--- a/debian/libselinux1-udeb.install
+++ b/debian/libselinux1-udeb.install
@@ -1 +1 @@
-usr/lib/*/*.so.*
+usr/lib/${DEB_HOST_MULTIARCH}/*.so.*
diff --git a/debian/libselinux1.install b/debian/libselinux1.install
index 3de3b10..8b38ff6 100644
--- a/debian/libselinux1.install
+++ b/debian/libselinux1.install
@@ -1 +1 @@
-usr/lib/*/*.so.*
+usr/lib/${DEB_HOST_MULTIARCH}/*.so.*
diff --git a/debian/ruby-selinux.install b/debian/ruby-selinux.install
index 267ca7a..4117767 100644
--- a/debian/ruby-selinux.install
+++ b/debian/ruby-selinux.install
@@ -1 +1 @@
-usr/lib/*/ruby
+usr/lib/${DEB_HOST_MULTIARCH}/ruby
-- 
2.39.5

>From 5a25c65aaebef0822b9fd2e00e99dc02e1f18567 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 21:58:00 +0100
Subject: [PATCH 03/16] debian/rules: use dpkg buildtools.mk Makefile snippet

---
 debian/rules | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index f01918d..5d52910 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,10 +6,10 @@
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 include /usr/share/dpkg/architecture.mk
+
+include /usr/share/dpkg/buildtools.mk
 # for cross compilation
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
-export CC := $(DEB_HOST_GNU_TYPE)-gcc
-export PKG_CONFIG := $(DEB_HOST_GNU_TYPE)-pkg-config
 export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
 define ruby_env
   RUBYLIB=/usr/lib/$(DEB_HOST_MULTIARCH)/ruby-crossbuild/$$($(1) -e "puts RbConfig::CONFIG['ruby_version']")
-- 
2.39.5

>From ff2a398a155b929d27730ecd97fb751064d9045e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 21:58:41 +0100
Subject: [PATCH 04/16] debian/rules: use dpkg buildopts.mk Makefile snippet

---
 debian/rules | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/debian/rules b/debian/rules
index 5d52910..5b53b57 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,10 +19,8 @@ define ruby_env
 endef
 endif
 
-ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-    MAKEFLAGS += -j$(NUMJOBS)
-endif
+include /usr/share/dpkg/buildopts.mk
+MAKEFLAGS += $(DEB_BUILD_OPTION_PARALLEL:%=-j%)
 
 DOPACKAGES = $(shell dh_listpackages)
 
-- 
2.39.5

>From ebbebc4a9691c57a92ead39e5b3259db9df4c9ee Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 22:02:05 +0100
Subject: [PATCH 05/16] debian/rules: use dpkg buildflags.mk Makefile snippet

This is recommended by dpkg-buildflags(1) in case debian/rules is
invoked directly.
---
 debian/rules | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/debian/rules b/debian/rules
index 5b53b57..bbedb59 100755
--- a/debian/rules
+++ b/debian/rules
@@ -3,7 +3,7 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
-export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+DEB_BUILD_MAINT_OPTIONS := hardening=+all
 
 include /usr/share/dpkg/architecture.mk
 
@@ -30,10 +30,13 @@ export DEB_CPPFLAGS_MAINT_APPEND += -D_LARGEFILE64_SOURCE
 endif
 
 # Upstream recommends using this flag
-export DEB_CFLAGS_MAINT_APPEND = -fno-semantic-interposition
+DEB_CFLAGS_MAINT_APPEND := -fno-semantic-interposition
 ## The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable the
 ## missing (hardening) flags. Also enable Wall and Wextra to spot basic irregularities.
-export DEB_CFLAGS_MAINT_APPEND += $(shell dpkg-buildflags --get CPPFLAGS) -Wall -Wextra
+DEB_CFLAGS_MAINT_APPEND += -Wall -Wextra
+DPKG_EXPORT_BUILDFLAGS := 1
+include /usr/share/dpkg/buildflags.mk
+export CFLAGS += $(CPPFLAGS)
 
 ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
 PY3VERSIONS = $(shell py3versions -rv)
-- 
2.39.5

>From 82d74ec95e6b6798023f8e12b3cae9066d93f30e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 3 Mar 2024 22:05:19 +0100
Subject: [PATCH 06/16] debian/rules: replace shell loops with Make loops

Each actually executed command is displayed first, and any failure
interrupts the build (without sh -e).

The order of the recursive Makes is different ('make python' and 'make
ruby' are executed before 'make all'), and the patch of some python
files happens even if python is disabled (but does nothing then).
---
 debian/rules | 63 +++++++++++++++++++++-------------------------------
 1 file changed, 25 insertions(+), 38 deletions(-)

diff --git a/debian/rules b/debian/rules
index bbedb59..e77138e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -51,52 +51,39 @@ endif
 ## Set up some variables to be passed to the upstream Makefile
 extra_make_args = ARCH=$(patsubst i%86,i386,$(DEB_HOST_GNU_CPU))
 extra_make_args += USE_PCRE2=y
-override_dh_auto_build:
+
+override_dh_auto_build: $(PY3VERSIONS:%=build-python-%) \
+                        $(RUBY_VERSIONS:%=build-ruby-%)
 	$(MAKE) all $(extra_make_args)
-ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(PY3VERSIONS); do        \
-	  $(MAKE) pywrap $(extra_make_args) PYTHON=python$$version; \
-	done;
-endif
-ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(RUBY_VERSIONS); do      \
-	  $(call ruby_env,$$version) \
-	  $(MAKE) rubywrap $(extra_make_args) RUBY=$$version; \
-	done;
-endif
+build-python-%:
+	$(MAKE) pywrap $(extra_make_args) PYTHON=python$*
+build-ruby-%:
+	$(call ruby_env,$*) \
+	$(MAKE) rubywrap $(extra_make_args) RUBY=$*
 
-override_dh_auto_install:
+override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
+                          $(RUBY_VERSIONS:%=install-ruby-%)
 	$(MAKE) install $(extra_make_args) DESTDIR="${CURDIR}/debian/tmp" \
 	  LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
 	  SHLIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
-ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(PY3VERSIONS); do \
-	  $(MAKE) install-pywrap $(extra_make_args) PYTHON=python$$version DESTDIR="${CURDIR}/debian/tmp" DEB_PYTHON_INSTALL_LAYOUT=deb; \
-	done;
-	find "${CURDIR}/debian/tmp" -name direct_url.json -delete ;
-	find "${CURDIR}/debian/tmp" -name RECORD -exec sed -i '/\/direct_url.json,/d' {} + ;
-endif
-ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(RUBY_VERSIONS); do \
-	  $(call ruby_env,$$version) \
-	  $(MAKE) install-rubywrap $(extra_make_args) RUBY=$$version DESTDIR="${CURDIR}/debian/tmp"; \
-	done;
-endif
+  # Patch the python installations.
+	find "${CURDIR}/debian/tmp" -name direct_url.json -delete
+	find "${CURDIR}/debian/tmp" -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +
+install-python-%:
+	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR="${CURDIR}/debian/tmp" DEB_PYTHON_INSTALL_LAYOUT=deb
+install-ruby-%:
+	$(call ruby_env,$*) \
+	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR="${CURDIR}/debian/tmp"
 
-override_dh_auto_clean:
+override_dh_auto_clean: $(PY3VERSIONS:%=clean-python-%) \
+                        $(RUBY_VERSIONS:%=clean-ruby-%)
 	rm -f utils/getpolicyload
 	$(MAKE) distclean $(extra_make_args) PYTHON=true
-ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(PY3VERSIONS); do         \
-	  $(MAKE) clean-pywrap $(extra_make_args) PYTHON=python$$version;  \
-	done;
-endif
-ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
-	set -e; for version in $(RUBY_VERSIONS); do      \
-	  $(call ruby_env,$$version) \
-	  $(MAKE) clean-rubywrap $(extra_make_args) RUBY=$$version; \
-	done;
-endif
+clean-python-%:
+	$(MAKE) clean-pywrap $(extra_make_args) PYTHON=python$*
+clean-ruby-%:
+	$(call ruby_env,$*) \
+	$(MAKE) clean-rubywrap $(extra_make_args) RUBY=$*
 
 override_dh_makeshlibs:
 	dh_makeshlibs -plibselinux1 --add-udeb="libselinux1-udeb" -V
-- 
2.39.5

>From 20c58fd27288be21929c67c20ec9ec8aa36c3f8f Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 11:04:49 +0100
Subject: [PATCH 07/16] debian/rules: remove obsolete dh_makeshlibs override

This is automatic since debhelper 12.3.
---
 debian/rules | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/debian/rules b/debian/rules
index e77138e..52f05e8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -84,7 +84,3 @@ clean-python-%:
 clean-ruby-%:
 	$(call ruby_env,$*) \
 	$(MAKE) clean-rubywrap $(extra_make_args) RUBY=$*
-
-override_dh_makeshlibs:
-	dh_makeshlibs -plibselinux1 --add-udeb="libselinux1-udeb" -V
-	dh_makeshlibs --remaining-packages
-- 
2.39.5

>From 750a072fcb46fb8de780141ffe8713e8ccad125e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:08:39 +0100
Subject: [PATCH 08/16] debian/rules: avoid hardcoded duplications of libdir

---
 debian/rules | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/debian/rules b/debian/rules
index 52f05e8..5e878c9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,13 +6,14 @@
 DEB_BUILD_MAINT_OPTIONS := hardening=+all
 
 include /usr/share/dpkg/architecture.mk
+libdir := /usr/lib/$(DEB_HOST_MULTIARCH)
 
 include /usr/share/dpkg/buildtools.mk
 # for cross compilation
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
 define ruby_env
-  RUBYLIB=/usr/lib/$(DEB_HOST_MULTIARCH)/ruby-crossbuild/$$($(1) -e "puts RbConfig::CONFIG['ruby_version']")
+  RUBYLIB=$(libdir)/ruby-crossbuild/$$($(1) -e "puts RbConfig::CONFIG['ruby_version']")
 endef
 else
 define ruby_env
@@ -64,8 +65,8 @@ build-ruby-%:
 override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
                           $(RUBY_VERSIONS:%=install-ruby-%)
 	$(MAKE) install $(extra_make_args) DESTDIR="${CURDIR}/debian/tmp" \
-	  LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
-	  SHLIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
+	  LIBDIR=$(libdir) \
+	  SHLIBDIR=$(libdir)
   # Patch the python installations.
 	find "${CURDIR}/debian/tmp" -name direct_url.json -delete
 	find "${CURDIR}/debian/tmp" -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +
-- 
2.39.5

>From 6ef24dd97a00537a7926b1e5a044017b99c2edc9 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:09:06 +0100
Subject: [PATCH 09/16] debian/rules: avoid hardcoded duplications of destdir

---
 debian/rules | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/debian/rules b/debian/rules
index 5e878c9..650bbf6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -62,19 +62,20 @@ build-ruby-%:
 	$(call ruby_env,$*) \
 	$(MAKE) rubywrap $(extra_make_args) RUBY=$*
 
+destdir := '$(CURDIR)/debian/tmp'
 override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
                           $(RUBY_VERSIONS:%=install-ruby-%)
-	$(MAKE) install $(extra_make_args) DESTDIR="${CURDIR}/debian/tmp" \
+	$(MAKE) install $(extra_make_args) DESTDIR=$(destdir) \
 	  LIBDIR=$(libdir) \
 	  SHLIBDIR=$(libdir)
   # Patch the python installations.
-	find "${CURDIR}/debian/tmp" -name direct_url.json -delete
-	find "${CURDIR}/debian/tmp" -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +
+	find $(destdir) -name direct_url.json -delete
+	find $(destdir) -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +
 install-python-%:
-	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR="${CURDIR}/debian/tmp" DEB_PYTHON_INSTALL_LAYOUT=deb
+	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR=$(destdir) DEB_PYTHON_INSTALL_LAYOUT=deb
 install-ruby-%:
 	$(call ruby_env,$*) \
-	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR="${CURDIR}/debian/tmp"
+	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR=$(destdir)
 
 override_dh_auto_clean: $(PY3VERSIONS:%=clean-python-%) \
                         $(RUBY_VERSIONS:%=clean-ruby-%)
-- 
2.39.5

>From 53ec72eacb9c58c673cd444fb058963abf89de1a Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:14:37 +0100
Subject: [PATCH 10/16] debian/rules: assign some variables with := instead of
 =

This is cosmetic for extra_make_args, but avoids a lot of subshells
for DOPACKAGES and PY3VERSIONS.
---
 debian/rules | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debian/rules b/debian/rules
index 650bbf6..767376f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,7 +23,7 @@ endif
 include /usr/share/dpkg/buildopts.mk
 MAKEFLAGS += $(DEB_BUILD_OPTION_PARALLEL:%=-j%)
 
-DOPACKAGES = $(shell dh_listpackages)
+DOPACKAGES := $(shell dh_listpackages)
 
 ifeq ($(DEB_HOST_ARCH_BITS),32)
 # Use of lstat64 requires this macro.
@@ -40,7 +40,7 @@ include /usr/share/dpkg/buildflags.mk
 export CFLAGS += $(CPPFLAGS)
 
 ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
-PY3VERSIONS = $(shell py3versions -rv)
+PY3VERSIONS := $(shell py3versions -rv)
 endif
 ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
 RUBY_VERSIONS := $(shell dh_ruby --print-supported)
@@ -50,7 +50,7 @@ endif
 	@dh $@
 
 ## Set up some variables to be passed to the upstream Makefile
-extra_make_args = ARCH=$(patsubst i%86,i386,$(DEB_HOST_GNU_CPU))
+extra_make_args := ARCH=$(patsubst i%86,i386,$(DEB_HOST_GNU_CPU))
 extra_make_args += USE_PCRE2=y
 
 override_dh_auto_build: $(PY3VERSIONS:%=build-python-%) \
-- 
2.39.5

>From d4d7b864609e5d9f2155b55f4e4fe35ee8b5c909 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:18:05 +0100
Subject: [PATCH 11/16] debian/rules: replace define and call constructs with
 simpler ones

---
 debian/rules | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/debian/rules b/debian/rules
index 767376f..8e7eba2 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,12 +12,8 @@ include /usr/share/dpkg/buildtools.mk
 # for cross compilation
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
-define ruby_env
-  RUBYLIB=$(libdir)/ruby-crossbuild/$$($(1) -e "puts RbConfig::CONFIG['ruby_version']")
-endef
-else
-define ruby_env
-endef
+# When ruby_env is expanded, $* is the ruby interpreter.
+ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e "puts RbConfig::CONFIG['ruby_version']")
 endif
 
 include /usr/share/dpkg/buildopts.mk
@@ -59,7 +55,7 @@ override_dh_auto_build: $(PY3VERSIONS:%=build-python-%) \
 build-python-%:
 	$(MAKE) pywrap $(extra_make_args) PYTHON=python$*
 build-ruby-%:
-	$(call ruby_env,$*) \
+	$(ruby_env) \
 	$(MAKE) rubywrap $(extra_make_args) RUBY=$*
 
 destdir := '$(CURDIR)/debian/tmp'
@@ -74,7 +70,7 @@ override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
 install-python-%:
 	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR=$(destdir) DEB_PYTHON_INSTALL_LAYOUT=deb
 install-ruby-%:
-	$(call ruby_env,$*) \
+	$(ruby_env) \
 	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR=$(destdir)
 
 override_dh_auto_clean: $(PY3VERSIONS:%=clean-python-%) \
@@ -84,5 +80,5 @@ override_dh_auto_clean: $(PY3VERSIONS:%=clean-python-%) \
 clean-python-%:
 	$(MAKE) clean-pywrap $(extra_make_args) PYTHON=python$*
 clean-ruby-%:
-	$(call ruby_env,$*) \
+	$(ruby_env) \
 	$(MAKE) clean-rubywrap $(extra_make_args) RUBY=$*
-- 
2.39.5

>From 0dd2eea07a8feaa6a4e45e469ef1ecf55539a23f Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:22:08 +0100
Subject: [PATCH 12/16] debian/rules: move the DOPACKAGES variable near its
 usage

---
 debian/rules | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index 8e7eba2..0131a86 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,8 +19,6 @@ endif
 include /usr/share/dpkg/buildopts.mk
 MAKEFLAGS += $(DEB_BUILD_OPTION_PARALLEL:%=-j%)
 
-DOPACKAGES := $(shell dh_listpackages)
-
 ifeq ($(DEB_HOST_ARCH_BITS),32)
 # Use of lstat64 requires this macro.
 export DEB_CPPFLAGS_MAINT_APPEND += -D_LARGEFILE64_SOURCE
@@ -35,6 +33,7 @@ DPKG_EXPORT_BUILDFLAGS := 1
 include /usr/share/dpkg/buildflags.mk
 export CFLAGS += $(CPPFLAGS)
 
+DOPACKAGES := $(shell dh_listpackages)
 ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
 PY3VERSIONS := $(shell py3versions -rv)
 endif
-- 
2.39.5

>From 06933a8ee8fc8a41392cae7461f12238d35dd775 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:22:38 +0100
Subject: [PATCH 13/16] debian/rules: show the dh command in build logs

---
 debian/rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index 0131a86..20f348b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -42,7 +42,7 @@ RUBY_VERSIONS := $(shell dh_ruby --print-supported)
 endif
 
 %:
-	@dh $@
+	dh $@
 
 ## Set up some variables to be passed to the upstream Makefile
 extra_make_args := ARCH=$(patsubst i%86,i386,$(DEB_HOST_GNU_CPU))
-- 
2.39.5

>From bf0c5af612c6a28ac50f56485012c09954ed5274 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 12:33:51 +0100
Subject: [PATCH 14/16] debian/rules: indent conditionals and split a comment

---
 debian/rules | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/debian/rules b/debian/rules
index 20f348b..475b5a7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,9 +11,9 @@ libdir := /usr/lib/$(DEB_HOST_MULTIARCH)
 include /usr/share/dpkg/buildtools.mk
 # for cross compilation
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
-export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
-# When ruby_env is expanded, $* is the ruby interpreter.
-ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e "puts RbConfig::CONFIG['ruby_version']")
+  export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
+  # When ruby_env is expanded, $* is the ruby interpreter.
+  ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e "puts RbConfig::CONFIG['ruby_version']")
 endif
 
 include /usr/share/dpkg/buildopts.mk
@@ -26,19 +26,20 @@ endif
 
 # Upstream recommends using this flag
 DEB_CFLAGS_MAINT_APPEND := -fno-semantic-interposition
-## The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable the
-## missing (hardening) flags. Also enable Wall and Wextra to spot basic irregularities.
+# Enable Wall and Wextra to spot basic irregularities.
 DEB_CFLAGS_MAINT_APPEND += -Wall -Wextra
 DPKG_EXPORT_BUILDFLAGS := 1
 include /usr/share/dpkg/buildflags.mk
+# The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable
+# the missing (hardening) flags.
 export CFLAGS += $(CPPFLAGS)
 
 DOPACKAGES := $(shell dh_listpackages)
 ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
-PY3VERSIONS := $(shell py3versions -rv)
+  PY3VERSIONS := $(shell py3versions -rv)
 endif
 ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
-RUBY_VERSIONS := $(shell dh_ruby --print-supported)
+  RUBY_VERSIONS := $(shell dh_ruby --print-supported)
 endif
 
 %:
-- 
2.39.5

>From c0bbb3bec821bb57c4bc1c392a4500a57b743d3e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 13:25:56 +0100
Subject: [PATCH 15/16] debian/rules: split long lines

---
 debian/rules | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index 475b5a7..6212190 100755
--- a/debian/rules
+++ b/debian/rules
@@ -13,7 +13,8 @@ include /usr/share/dpkg/buildtools.mk
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
   export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
   # When ruby_env is expanded, $* is the ruby interpreter.
-  ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e "puts RbConfig::CONFIG['ruby_version']")
+  ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e \
+    "puts RbConfig::CONFIG['ruby_version']")
 endif
 
 include /usr/share/dpkg/buildopts.mk
@@ -68,7 +69,8 @@ override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
 	find $(destdir) -name direct_url.json -delete
 	find $(destdir) -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +
 install-python-%:
-	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR=$(destdir) DEB_PYTHON_INSTALL_LAYOUT=deb
+	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* \
+	  DESTDIR=$(destdir) DEB_PYTHON_INSTALL_LAYOUT=deb
 install-ruby-%:
 	$(ruby_env) \
 	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR=$(destdir)
-- 
2.39.5

>From 1043fc7e6ff4787ffc4468fe8f75a79c525d91d0 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 5 Mar 2024 14:57:18 +0100
Subject: [PATCH 16/16] Build-Depend on pkgconf instead of obsolete pkg-config

---
 debian/control | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index f9f37da..416cdf8 100644
--- a/debian/control
+++ b/debian/control
@@ -15,7 +15,7 @@ Build-Depends: debhelper-compat (= 13),
                libsepol-dev (>= 3.8),
                libpcre2-dev,
                libpython3-all-dev <!nopython>,
-               pkg-config,
+               pkgconf,
                python3-all-dev:any <!nopython>,
                python3-pip <!nopython>,
                python3-setuptools <!nopython>,
-- 
2.39.5

_______________________________________________
SELinux-devel mailing list
SELinux-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/selinux-devel

Reply via email to