From e097845cb8605d7f7b08c3c049f6a2befd9629c8 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 18 May 2021 15:20:51 +0300 Subject: [PATCH 1/5] Makefile: remove an always false condition The `if false` condition will never be true, so let's just remove that paragraph. --- Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 78bb23af2..92831a6d4 100644 --- a/Makefile +++ b/Makefile @@ -387,11 +387,7 @@ dpkg: ../scst_$(VERSION).orig.tar.gz else \ buildopts+=(-j4); \ fi && \ - if false; then \ - dpkg-buildpackage "$${buildopts[@]}"; \ - else \ - debuild "$${buildopts[@]}" --lintian-opts --profile debian; \ - fi && \ + debuild "$${buildopts[@]}" --lintian-opts --profile debian && \ mkdir -p dpkg && \ for f in "$${output_files[@]}" ../scst_$(VERSION).orig.tar.[gx]z; do\ mv $$f dpkg || true; \ From 65ef5e062798d32da31c91f77626c08610c141a9 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 18 May 2021 18:27:32 +0300 Subject: [PATCH 2/5] debian: make sure KVER and KDIR are visible to dpkg build The debuild clears up the environment, thus the essential SCST variables KVER and KDIR are cleared out. This patch fixes it. Note: technically, `debild` supports `--preserve-env` option. But in reality making use of it makes no difference, variables still do not appear. Work around it by using DEB_foo_SET from `man dpkg-buildflags` --- Makefile | 2 +- debian/rules | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 92831a6d4..77ad72294 100644 --- a/Makefile +++ b/Makefile @@ -387,7 +387,7 @@ dpkg: ../scst_$(VERSION).orig.tar.gz else \ buildopts+=(-j4); \ fi && \ - debuild "$${buildopts[@]}" --lintian-opts --profile debian && \ + DEB_KVER_SET=$(KVER) DEB_KDIR_SET=$(KDIR) debuild "$${buildopts[@]}" --lintian-opts --profile debian && \ mkdir -p dpkg && \ for f in "$${output_files[@]}" ../scst_$(VERSION).orig.tar.[gx]z; do\ mv $$f dpkg || true; \ diff --git a/debian/rules b/debian/rules index f78e364a0..8342862e9 100755 --- a/debian/rules +++ b/debian/rules @@ -17,6 +17,11 @@ SUBDIRS=scst fcst iscsi-scst qla2x00t/qla2x00-target scst_local scstadmin srpt DESTDIR=$(CURDIR)/debian/tmp VERSION:=$(shell head -n1 debian/changelog | sed 's/.*(\([0-9.]*\).*).*/\1/') +# rules won't see variables unless they're using DEB_foo_SET syntax. So use that as +# an intermediary. Also, export variables for sub-makes to be able to see them. +export KVER=$(DEB_KVER_SET) +export KDIR=$(DEB_KDIR_SET) + %: echo "*** dh $@ ***" dh $@ From bd2cfd4bb2ced72ee4b1a018c5a29a12efd47499 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Wed, 19 May 2021 11:59:40 +0300 Subject: [PATCH 3/5] debian: fix wrong kernel version used in preinst This script is used in the non-dkms scst package. The purpose of package is to determine kernel location at compile-time, as opposed to the package installation time. However, calling `uname -r` in package installation time violates that idea because it would get some random kernel that was running on the machine. This problem is particularly seen in containers, because in those `uname` shows the kernel running on the host, rather than the one running inside container. Fix this by determining the kernel location in `preinst` script at compile time as well. --- Makefile | 2 ++ debian/rules | 2 +- debian/{scst.preinst => scst.preinst.in} | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) rename debian/{scst.preinst => scst.preinst.in} (94%) diff --git a/Makefile b/Makefile index 77ad72294..0df19af3f 100644 --- a/Makefile +++ b/Makefile @@ -367,6 +367,8 @@ dpkg: ../scst_$(VERSION).orig.tar.gz [ -z "$$DEBFULLNAME" ] || export DEBFULLNAME="Bart Van Assche" &&\ sed 's/%{scst_version}/$(VERSION)/' \ debian/scst.dkms && \ + sed 's/%{KVER}/$(KVER)/' \ + debian/scst.preinst && \ output_files=( \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.deb \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.ddeb \ diff --git a/debian/rules b/debian/rules index 8342862e9..0c49bded8 100755 --- a/debian/rules +++ b/debian/rules @@ -29,7 +29,7 @@ export KDIR=$(DEB_KDIR_SET) clean: dh_testdir && \ dh_prep -Xqla_isp/TAGS -Xdebian/changelog && \ - scripts/clean-source-tree -x debian/changelog -x debian/compat + scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst.preinst build: make 2release && \ diff --git a/debian/scst.preinst b/debian/scst.preinst.in similarity index 94% rename from debian/scst.preinst rename to debian/scst.preinst.in index 4d5af2eaf..199a4e275 100644 --- a/debian/scst.preinst +++ b/debian/scst.preinst.in @@ -17,7 +17,7 @@ set -e case "$1" in install) # Remove any existing ib_srpt.ko kernel modules - find "/lib/modules/$(uname -r)" -name ib_srpt.ko -exec rm {} \; + find "/lib/modules/%{KVER}" -name ib_srpt.ko -exec rm {} \; # Remove files installed by "make install" rm -f /usr/local/man/man5/iscsi-scstd.conf.5 rm -f /usr/local/man/man8/iscsi-scst-adm.8 From 93d07f966e479cb86193aedbc6b61c547bd7057f Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Wed, 19 May 2021 15:42:04 +0300 Subject: [PATCH 4/5] debian: make sure depmod uses the correct version By default it uses the currently running kernel, which is not necessary the kernel the package was built for. Fix this by generating the path on package creation stage. --- Makefile | 2 ++ debian/rules | 3 ++- debian/{scst.postinst => scst.postinst.in} | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) rename debian/{scst.postinst => scst.postinst.in} (98%) diff --git a/Makefile b/Makefile index 0df19af3f..8becf0947 100644 --- a/Makefile +++ b/Makefile @@ -369,6 +369,8 @@ dpkg: ../scst_$(VERSION).orig.tar.gz debian/scst.dkms && \ sed 's/%{KVER}/$(KVER)/' \ debian/scst.preinst && \ + sed 's/%{KVER}/$(KVER)/' \ + debian/scst.postinst && \ output_files=( \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.deb \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.ddeb \ diff --git a/debian/rules b/debian/rules index 0c49bded8..af061fb37 100755 --- a/debian/rules +++ b/debian/rules @@ -29,7 +29,8 @@ export KDIR=$(DEB_KDIR_SET) clean: dh_testdir && \ dh_prep -Xqla_isp/TAGS -Xdebian/changelog && \ - scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst.preinst + scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst.preinst \ + -x debian/scst.postinst build: make 2release && \ diff --git a/debian/scst.postinst b/debian/scst.postinst.in similarity index 98% rename from debian/scst.postinst rename to debian/scst.postinst.in index d1569e33c..f535eebd9 100644 --- a/debian/scst.postinst +++ b/debian/scst.postinst.in @@ -23,7 +23,7 @@ case "$1" in mkdir -p /var/lib/scst/dif_tags mkdir -p /var/lib/scst/pr mkdir -p /var/lib/scst/vdev_mode_pages - depmod;; + depmod "%{KVER}";; abort-upgrade|abort-remove|abort-deconfigure) ;; From 2fa40456f7a035f8956f3356c609552a6cd5322f Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Wed, 19 May 2021 15:49:53 +0300 Subject: [PATCH 5/5] debian: make sure CC variable is passed through to the build --- Makefile | 2 +- debian/rules | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8becf0947..36545d500 100644 --- a/Makefile +++ b/Makefile @@ -391,7 +391,7 @@ dpkg: ../scst_$(VERSION).orig.tar.gz else \ buildopts+=(-j4); \ fi && \ - DEB_KVER_SET=$(KVER) DEB_KDIR_SET=$(KDIR) debuild "$${buildopts[@]}" --lintian-opts --profile debian && \ + DEB_CC_SET="$(CC)" DEB_KVER_SET=$(KVER) DEB_KDIR_SET=$(KDIR) debuild "$${buildopts[@]}" --lintian-opts --profile debian && \ mkdir -p dpkg && \ for f in "$${output_files[@]}" ../scst_$(VERSION).orig.tar.[gx]z; do\ mv $$f dpkg || true; \ diff --git a/debian/rules b/debian/rules index af061fb37..efd2cf134 100755 --- a/debian/rules +++ b/debian/rules @@ -21,6 +21,7 @@ VERSION:=$(shell head -n1 debian/changelog | sed 's/.*(\([0-9.]*\).*).*/\1/') # an intermediary. Also, export variables for sub-makes to be able to see them. export KVER=$(DEB_KVER_SET) export KDIR=$(DEB_KDIR_SET) +export CC=$(DEB_CC_SET) %: echo "*** dh $@ ***"