Re-add contents of redhat-rpm-config-9.1.0-kmod-kabi.patch to RHEL 9

Apply redhat-rpm-config-9.1.0-kmod-kabi.patch from RHEL 7 branch.

Applied only changes to kmodtool and macros (now macros.kmp), as all
others are applied already. macros.kmp also had a merge conflict due to
commits f41a8a73aa6f ("Fix kernel_source macro to match the directory
that kernel sources are installed in") and d95e9bc7b618 ("Fix directory
name mismatch in kernel_source macro (#648996)") being applied already.

Commit message from the original commit:

    commit 29b4b765391b8f11ae64708e86ac3f7475c62661
    Author: Panu Matilainen <pmatilai@redhat.com>
    Date:   Tue Jul 9 09:57:29 2013 +0300

        - Re-add various kABI-related bits (Jon Masters)
        - Allow kmod building against z-stream kernels (Jiri Benc)

Resolves: #1971748
Resolves: #2002887
Resolves: #2015909
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
This commit is contained in:
Eugene Syromiatnikov 2019-01-21 08:52:21 +01:00
parent f6c02f2f49
commit 78df0af42a
2 changed files with 96 additions and 92 deletions

159
kmodtool
View File

@ -1,7 +1,12 @@
#!/bin/bash
# kmodtool - Helper script for building kernel module RPMs
# Copyright (c) 2003-2006 Ville Skyttä <ville.skytta@iki.fi>,
# An original version appeared in Fedora. This version is
# generally called only by the %kernel_module_package RPM macro
# during the process of building Driver Update Packages (which
# are also known as "kmods" in the Fedora community).
#
# Copyright (c) 2003-2010 Ville Skyttä <ville.skytta@iki.fi>,
# Thorsten Leemhuis <fedora@leemhuis.info>
# Jon Masters <jcm@redhat.com>
#
@ -24,21 +29,30 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Changelog:
#
# 2010/07/28 - Add fixes for filelists in line with LF standard
# - Remove now defunct "framepointer" kernel variant
# - Change version to "rhel6-rh2" as a consequence.
#
# 2010/01/10 - Simplified for RHEL6. We are working on upstream
# moving to a newer format and in any case do not
# need to retain support for really old systems.
shopt -s extglob
myprog="kmodtool"
myver="0.10.10_kmp2"
knownvariants=@(BOOT|PAE|@(big|huge)mem|debug|enterprise|kdump|?(large)smp|uml|xen[0U]?(-PAE)|xen)
knownvariants=@(debug|kdump)
kmod_name=
kver=
verrel=
variant=
kmp=
get_verrel ()
{
verrel=${1:-$(uname -r)}
verrel=${verrel%%$knownvariants}
verrel=${verrel/%.$knownvariants/}
}
print_verrel ()
@ -51,7 +65,7 @@ get_variant ()
{
get_verrel $@
variant=${1:-$(uname -r)}
variant=${variant##$verrel}
variant=${variant/#$verrel?(.)/}
variant=${variant:-'""'}
}
@ -61,117 +75,128 @@ print_variant ()
echo "${variant}"
}
get_filelist() {
local IFS=$'\n'
filelist=($(cat))
if [ ${#filelist[@]} -gt 0 ];
then
for ((n = 0; n < ${#filelist[@]}; n++));
do
line="${filelist[n]}"
line=$(echo "$line" \
| sed -e "s/%verrel/$verrel/g" \
| sed -e "s/%variant/$variant/g" \
| sed -e "s/%dashvariant/$dashvariant/g" \
| sed -e "s/%dotvariant/$dotvariant/g" \
| sed -e "s/\.%1/$dotvariant/g" \
| sed -e "s/\-%1/$dotvariant/g" \
| sed -e "s/%2/$verrel/g")
echo "$line"
done
else
echo "%defattr(644,root,root,755)"
echo "/lib/modules/${verrel}${dotvariant}"
fi
}
get_rpmtemplate ()
{
local variant="${1}"
local dashvariant="${variant:+-${variant}}"
case "$verrel" in
*.el*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
*.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
*) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;;
esac
local dotvariant="${variant:+.${variant}}"
echo "%package -n kmod-${kmod_name}${dashvariant}"
if [ -z "$kmp_provides_summary" ]; then
if [ -z "$kmod_provides_summary" ]; then
echo "Summary: ${kmod_name} kernel module(s)"
fi
if [ -z "$kmp_provides_group" ]; then
if [ -z "$kmod_provides_group" ]; then
echo "Group: System Environment/Kernel"
fi
if [ ! -z "$kmp_version" ]; then
echo "Version: %{kmp_version}"
if [ ! -z "$kmod_version" ]; then
echo "Version: %{kmod_version}"
fi
if [ ! -z "$kmp_release" ]; then
echo "Release: %{kmp_release}"
if [ ! -z "$kmod_release" ]; then
echo "Release: %{kmod_release}"
fi
if [ ! -z "$kmp" ]; then
# Turn of the internal dep generator so we will use the kmod scripts.
echo "%global _use_internal_dependency_generator 0"
fi
cat <<EOF
Provides: kernel-modules = ${verrel}${variant}
Provides: kernel-modules >= ${verrel}${dotvariant}
Provides: ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
EOF
if [ -z "$kmp" ]; then
echo "Requires: ${kdep}"
fi
#
# RHEL5 - Remove common package requirement on general kmod packages.
# Requires: ${kmod_name}-kmod-common >= %{?epoch:%{epoch}:}%{version}
#
cat <<EOF
Requires(post): /sbin/depmod
Requires(postun): /sbin/depmod
EOF
if [ "no" != "$kmp_nobuildreqs" ]
then
echo "BuildRequires: kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}"
fi
if [ "yes" != "$nobuildreqs" ]
then
echo "BuildRequires: kernel${dashvariant}-devel"
fi
if [ "" != "$kmp_override_preamble" ]
then
cat "$kmp_override_preamble"
fi
if [ "" != "$override_preamble" ]
then
cat "$override_preamble"
fi
cat <<EOF
%description -n kmod-${kmod_name}${dashvariant}
This package provides the ${kmod_name} kernel modules built for the Linux
kernel ${verrel}${variant} for the %{_target_cpu} family of processors.
%post -n kmod-${kmod_name}${dashvariant}
if [ -e "/boot/System.map-${verrel}${variant}" ]; then
/sbin/depmod -aeF "/boot/System.map-${verrel}${variant}" "${verrel}${variant}" > /dev/null || :
fi
This package provides the ${kmod_name} kernel modules built for
the Linux kernel ${verrel}${dotvariant} for the %{_target_cpu}
family of processors.
EOF
if [ ! -z "$kmp" ]; then
cat <<EOF
##############################################################################
## The following are not part of this script directly, they are scripts ##
## that will be executed by RPM during various stages of package processing ##
##############################################################################
modules=( \$(find /lib/modules/${verrel}${variant}/extra/${kmod_name}) )
cat <<EOF
%post -n kmod-${kmod_name}${dashvariant}
if [ -e "/boot/System.map-${verrel}${dotvariant}" ]; then
/sbin/depmod -aeF "/boot/System.map-${verrel}${dotvariant}" "${verrel}${dotvariant}" > /dev/null || :
fi
modules=( \$(find /lib/modules/${verrel}${dotvariant}/extra/${kmod_name} | grep '\.ko$') )
if [ -x "/sbin/weak-modules" ]; then
printf '%s\n' "\${modules[@]}" \
| /sbin/weak-modules --add-modules
fi
EOF
cat <<EOF
%preun -n kmod-${kmod_name}${dashvariant}
rpm -ql kmod-${kmod_name}${dashvariant} | grep '\.ko$' \
> /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
rpm -ql kmod-${kmod_name}${dashvariant}-%{kmod_version}-%{kmod_release}.$(arch) | grep '\.ko$' > /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
EOF
fi
cat <<EOF
cat <<EOF
%postun -n kmod-${kmod_name}${dashvariant}
/sbin/depmod -aF /boot/System.map-${verrel}${variant} ${verrel}${variant} &> /dev/null || :
EOF
if [ -e "/boot/System.map-${verrel}${dotvariant}" ]; then
/sbin/depmod -aeF "/boot/System.map-${verrel}${dotvariant}" "${verrel}${dotvariant}" > /dev/null || :
fi
if [ ! -z "$kmp" ]; then
cat <<EOF
modules=( \$(cat /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules) )
#rm /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
rm /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
if [ -x "/sbin/weak-modules" ]; then
printf '%s\n' "\${modules[@]}" \
| /sbin/weak-modules --remove-modules
fi
EOF
fi
echo "%files -n kmod-${kmod_name}${dashvariant}"
if [ "" == "$kmp_override_filelist" ];
if [ "" == "$override_filelist" ];
then
echo "%defattr(644,root,root,755)"
echo "/lib/modules/${verrel}${variant}/"
echo "/lib/firmware/"
echo "/lib/modules/${verrel}${dotvariant}"
else
cat "$kmp_override_filelist"
cat "$override_filelist" | get_filelist
fi
}
@ -216,8 +241,6 @@ Usage: ${myprog} <command> <option>+
- Get variant from uname.
rpmtemplate <mainpgkname> <uname> <variants>
- Return a template for use in a source RPM
rpmtemplate_kmp <mainpgkname> <uname> <variants>
- Return a template for use in a source RPM with KMP dependencies
version
- Output version number and exit.
EOF
@ -241,12 +264,6 @@ while [ "${1}" ] ; do
print_rpmtemplate "$@"
exit $?
;;
rpmtemplate_kmp)
shift
kmp=1
print_rpmtemplate "$@"
exit $?
;;
version)
echo "${myprog} ${myver}"
exit 0

View File

@ -12,40 +12,27 @@ kernel_module_package_release 1
kernel-devel
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
%define kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \
%define kmp_version %{-v*}%{!-v:%{version}} \
%define kmp_release %{-r*}%{!-r:%{release}} \
%define latest_kernel %(rpm -q --qf '%{VERSION}-%{RELEASE}\\\\n' `rpm -q kernel-devel | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1) \
%global kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \
%global kmod_version %{-v*}%{!-v:%{version}} \
%global kmod_release %{-r*}%{!-r:%{release}} \
%global latest_kernel %(rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}\\\\n' `rpm -q kernel-devel | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1) \
%{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \
%global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \
flavors="default" \
if [ "i686" == "%{_target_cpu}" ] || [ "x86_64" == "%{_target_cpu}" ] \
then \
xenver=$(rpm -q kernel-xen-devel-%{kverrel}|head -n 1)\
kdver=$(rpm -q kernel-kdump-devel-%{kverrel}|head -n 1)\
if [ "kernel-xen-devel-%{kverrel}" == "$xenver" ] \
then \
flavors="$flavors xen" \
fi \
if [ "kernel-kdump-devel-%{kverrel}" == "$kdver" ] \
then \
flavors="$flavors kdump" \
fi \
fi \
if [ -z "%*" ]; then \
flavors_to_build=$flavors \
elif [ -z "%{-x}" ]; then \
flavors_to_build="%*" \
else \
flavors_to_build=" $flavors "\
echo "[$flavors_to_build]" >/tmp/tmp.txt
for i in %* \
do \
flavors_to_build=${flavors_to_build//$i /}
done \
fi \
echo "%%global flavors_to_build ${flavors_to_build:-%%nil}" \
echo "%%global kernel_source() /usr/src/kernels/%kverrel.\\\$([ %%%%{1} = default ] || echo "%%%%{1}.")%_target_cpu" \
echo "%%global kernel_source() /usr/src/kernels/%kverrel\\\$([ %%%%{1} = default ] || echo ".%%%%{1}")" \
echo "%%global kernel_module_package_moddir() extra" \
if [ ! -z "%{-f*}" ] \
then \
filelist="%{-f*}" \
@ -59,5 +46,5 @@ kernel_module_package_release 1
then \
nobuildreqs="no" \
fi \
kmp_override_filelist="$filelist" kmp_override_preamble="$preamble" kmp_nobuildreqs="$nobuildreqs" %{kmodtool} rpmtemplate_kmp %{-n*}%{!-n:%name} %{kverrel} $flavors_to_build 2>/dev/null \
override_filelist="$filelist" override_preamble="$preamble" nobuildreqs="$nobuildreqs" kmod_version=%kmod_version kmod_release=%kmod_release %{kmodtool} rpmtemplate %{-n*}%{!-n:%name} %{kverrel} $flavors_to_build 2>/dev/null \
)}