kmodtool: depmod path

Determine the location of depmod on the system, either /sbin/depmod or
/usr/sbin/depmod.  Then use that path when generating the specfile.

Additionally, update the Requires lines to reference the package which
provides depmod rather than the binary itself.  For CentOS/RHEL 7+8
and all supported Fedora releases this is the kmod package, and for
CentOS/RHEL 6 it is the module-init-tools package.

Reviewed-by: Minh Diep <mdiep@whamcloud.com>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8724
Closes #9310
This commit is contained in:
Brian Behlendorf 2019-09-11 11:14:50 -07:00 committed by GitHub
parent 490e23cdf4
commit 5b51c15861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,6 +144,12 @@ print_rpmtemplate_per_kmodpkg ()
local kernel_uname_r=${1} local kernel_uname_r=${1}
local kernel_variant="${2:+-${2}}" local kernel_variant="${2:+-${2}}"
# Detect depmod install location
local depmod_path=/sbin/depmod
if [ ! -f ${depmod_path} ]; then
depmod_path=/usr/sbin/depmod
fi
# first part # first part
cat <<EOF cat <<EOF
%package -n kmod-${kmodname}-${kernel_uname_r} %package -n kmod-${kmodname}-${kernel_uname_r}
@ -153,8 +159,14 @@ Provides: kernel-modules-for-kernel = ${kernel_uname_r}
Provides: kmod-${kmodname}-uname-r = ${kernel_uname_r} Provides: kmod-${kmodname}-uname-r = ${kernel_uname_r}
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release} Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version} Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
Requires(post): ${prefix}/sbin/depmod
Requires(postun): ${prefix}/sbin/depmod %if 0%{?rhel} == 6 || 0%{?centos} == 6
Requires(post): module-init-tools
Requires(postun): module-init-tools
%else
Requires(post): kmod
Requires(postun): kmod
%endif
EOF EOF
if [[ ${obsolete_name} ]]; then if [[ ${obsolete_name} ]]; then
@ -170,17 +182,17 @@ BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}} %{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}} %{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%post -n kmod-${kmodname}-${kernel_uname_r} %post -n kmod-${kmodname}-${kernel_uname_r}
${prefix}/sbin/depmod -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || : ${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
%postun -n kmod-${kmodname}-${kernel_uname_r} %postun -n kmod-${kmodname}-${kernel_uname_r}
${prefix}/sbin/depmod -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || : ${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
EOF EOF
else else
cat <<EOF cat <<EOF
%post -n kmod-${kmodname}-${kernel_uname_r} %post -n kmod-${kmodname}-${kernel_uname_r}
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || : [[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}${depmod_path} -a > /dev/null || :
%postun -n kmod-${kmodname}-${kernel_uname_r} %postun -n kmod-${kmodname}-${kernel_uname_r}
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || : [[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}${depmod_path} -a > /dev/null || :
EOF EOF
fi fi