Skip to content

Commit

Permalink
kmodtool: depmod path
Browse files Browse the repository at this point in the history
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 openzfs#8724
Closes openzfs#9310
  • Loading branch information
behlendorf authored and tonyhutter committed Sep 25, 2019
1 parent 97d4986 commit e17445d
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions scripts/kmodtool
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ print_rpmtemplate_per_kmodpkg ()
local kernel_uname_r=${1}
local kernel_variant="${2:+-${2}}"

# first part
# Detect depmod install location
local depmod_path=/sbin/depmod
if [ ! -f ${depmod_path} ]; then
depmod_path=/usr/sbin/depmod
fi

# first part
cat <<EOF
%package -n kmod-${kmodname}-${kernel_uname_r}
Summary: ${kmodname} kernel module(s) for ${kernel_uname_r}
Expand All @@ -153,8 +159,14 @@ Provides: kernel-modules-for-kernel = ${kernel_uname_r}
Provides: kmod-${kmodname}-uname-r = ${kernel_uname_r}
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
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

if [[ ${obsolete_name} ]]; then
Expand All @@ -170,17 +182,17 @@ BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${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}
${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
else
cat <<EOF
%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}
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || :
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}${depmod_path} -a > /dev/null || :
EOF
fi
Expand Down

0 comments on commit e17445d

Please sign in to comment.