From bd2cfd4bb2ced72ee4b1a018c5a29a12efd47499 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Wed, 19 May 2021 11:59:40 +0300 Subject: [PATCH] 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