From 38767e49020e160259361b66547e7b2d29f0c20a Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 3 Oct 2013 11:42:06 +0300 Subject: [PATCH 01/91] Add dependency generator for kABI provides The only difference from RHEL 7 is that we're looking for symvers file in /lib/modules now, per #1609695[1]. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1609695 - Add dependency generator for kABI provides Resolves: #1942563 Resolves: #2008554 Signed-off-by: Eugene Syromiatnikov --- kabi.attr | 2 ++ kabi.sh | 13 +++++++++++++ kernel-srpm-macros.spec | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 kabi.attr create mode 100644 kabi.sh diff --git a/kabi.attr b/kabi.attr new file mode 100644 index 0000000..85d30a2 --- /dev/null +++ b/kabi.attr @@ -0,0 +1,2 @@ +%__kabi_provides %{_rpmconfigdir}/kabi.sh +%__kabi_path ^/lib/modules/[1-9].*/symvers.gz$ diff --git a/kabi.sh b/kabi.sh new file mode 100644 index 0000000..0afa5ad --- /dev/null +++ b/kabi.sh @@ -0,0 +1,13 @@ +#!/bin/bash +x +# +# kabi.sh - Automatically extract any kernel symbol checksum from the +# symvers file and add to RPM deps. This is used to move the +# checksum checking from modprobe to rpm install for 3rd party +# modules (so they can fail during install and not at load). + +IFS=$'\n' + +for symvers in $(grep -E '/lib/modules/[1-9].*/symvers\.gz') "$@"; +do + zcat $symvers | awk ' {print "kernel(" $2 ") = " $1 }' +done diff --git a/kernel-srpm-macros.spec b/kernel-srpm-macros.spec index 6188dcb..c0fa367 100644 --- a/kernel-srpm-macros.spec +++ b/kernel-srpm-macros.spec @@ -30,6 +30,10 @@ Source300: kmodtool Source301: rpmsort Source302: symset-table +# kabi provides generator +Source400: kabi.attr +Source401: kabi.sh + %global rrcdir /usr/lib/rpm/redhat @@ -74,13 +78,17 @@ install -p -m 755 -t %{buildroot}%{rrcdir}/find-provides.d firmware.prov modalia install -p -m 644 -t %{buildroot}%{_rpmconfigdir}/macros.d macros.kmp install -p -m 644 -t %{buildroot}%{_fileattrsdir} kmod.attr +install -p -m 644 -t "%{buildroot}%{_fileattrsdir}" kabi.attr +install -p -m 755 -t "%{buildroot}%{_rpmconfigdir}" kabi.sh %files %{_rpmconfigdir}/macros.d/macros.kernel-srpm %{_fileattrsdir}/kmod.attr %files -n kernel-rpm-macros +%{_rpmconfigdir}/kabi.sh %{_rpmconfigdir}/macros.d/macros.kmp +%{_fileattrsdir}/kabi.attr %dir %{rrcdir}/find-provides.d %{rrcdir}/kmodtool %{rrcdir}/rpmsort From cc5344c96dd9f8af2a24708efaf014033104df2a Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 13 Aug 2018 23:10:06 +0200 Subject: [PATCH 02/91] Re-instantiate support for old symvers path As it breaks bz1004930-detect-kabi-provides test[1] otherwise. [1] http://pkgs.devel.redhat.com/cgit/tests/redhat-rpm-config/tree/Sanity/bz1004930-detect-kabi-provides - Re-instantiate support for old symvers path * kabi.attr (%__kabi_path): Add "/boot/symvers-.*" to the path matching regular expression. * kabi.sh: Likewise. Resolves: #1942563 Resolves: #2008554 Signed-off-by: Eugene Syromiatnikov --- kabi.attr | 2 +- kabi.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kabi.attr b/kabi.attr index 85d30a2..2d81387 100644 --- a/kabi.attr +++ b/kabi.attr @@ -1,2 +1,2 @@ %__kabi_provides %{_rpmconfigdir}/kabi.sh -%__kabi_path ^/lib/modules/[1-9].*/symvers.gz$ +%__kabi_path ^(/boot/symvers-.*|/lib/modules/[1-9].*/symvers)\.gz$ diff --git a/kabi.sh b/kabi.sh index 0afa5ad..59b2b86 100644 --- a/kabi.sh +++ b/kabi.sh @@ -7,7 +7,7 @@ IFS=$'\n' -for symvers in $(grep -E '/lib/modules/[1-9].*/symvers\.gz') "$@"; +for symvers in $(grep -E '(/boot/symvers-.*|/lib/modules/[1-9].*/symvers)\.gz') "$@"; do zcat $symvers | awk ' {print "kernel(" $2 ") = " $1 }' done From 1ecae1d45e7ead9b501d84ebee63b2b87bf6b793 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Wed, 13 Oct 2021 17:17:57 +0200 Subject: [PATCH 03/91] find-requires.ksyms: import RHEL-specific changes from RHEL 7.6 * find-requires.ksyms: Add file comment. (check_kabi): New function. (if [ ${#modules[@]} -gt 0 ]): Call it. Resolves: #2002887 Signed-off-by: Eugene Syromiatnikov --- find-requires.ksyms | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/find-requires.ksyms b/find-requires.ksyms index b11c7bb..6918a01 100755 --- a/find-requires.ksyms +++ b/find-requires.ksyms @@ -1,4 +1,9 @@ #! /bin/bash +# +# This script is called during external module building to create dependencies +# both upon the RHEL kernel, and on additional external modules. Symbols that +# cannot be reconciled against those provided by the kernel are assumed to be +# provided by an external module and "ksym" replaces th regular "kernel" dep. IFS=$'\n' @@ -50,6 +55,49 @@ if ! [ -e /sbin/modinfo -a -e /sbin/modprobe ]; then exit 0 fi +check_kabi() { + arch=$(uname -m) + kabi_file="/lib/modules/kabi-current/kabi_stablelist_$arch" + + # If not installed, output a warning and return (continue) + if [ ! -f "$kabi_file" ]; then + echo "" >&2 + echo "********************************************************************************" >&2 + echo "*********************** KERNEL ABI COMPATIBILITY WARNING ***********************" >&2 + echo "********************************************************************************" >&2 + echo "The kernel ABI reference files (provided by "kabi-stablelists") were not found." >&2 + echo "No compatibility check was performed. Please install the kABI reference files" >&2 + echo "and rebuild if you would like to verify compatibility with kernel ABI." >&2 + echo "" >&2 + return + fi + + unset non_kabi + for symbol in "$@"; do + if ! egrep "^[[:space:]]$symbol\$" $kabi_file >/dev/null; then + non_kabi=("${non_kabi[@]}" "$symbol") + fi + done + + if [ ${#non_kabi[@]} -gt 0 ]; then + echo "" >&2 + echo "********************************************************************************" >&2 + echo "*********************** KERNEL ABI COMPATIBILITY WARNING ***********************" >&2 + echo "********************************************************************************" >&2 + echo "The following kernel symbols are not guaranteed to remain compatible with" >&2 + echo "future kernel updates to this RHEL release:" >&2 + echo "" >&2 + for symbol in "${non_kabi[@]}"; do + printf "\t$symbol\n" >&2 + done + echo "" >&2 + echo "Red Hat recommends that you consider using only official kernel ABI symbols" >&2 + echo "where possible. Requests for additions to the kernel ABI can be filed with" >&2 + echo "your partner or customer representative (component: driver-update-program)." >&2 + echo "" >&2 + fi +} + modules=($(grep -E '/lib/modules/.+\.ko$')) if [ ${#modules[@]} -gt 0 ]; then kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q) @@ -71,4 +119,10 @@ if [ ${#modules[@]} -gt 0 ]; then # Symbols from elsewhere get a "ksym" dependency LC_ALL=C join -t $'\t' -j 1 -v 2 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ | awk '{ FS = "\t" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }' + + # Check kABI if the kabi-stablelists package is installed + # Do this last so we can try to output this error at the end + kabi_check_symbols=($(LC_ALL=C join -t $'\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ + | awk '{ FS = "\t" ; OFS = "\t" } { print $1 }')) + check_kabi "${kabi_check_symbols[@]}" fi From 6b98812de693cd2bc1a80ac30b6414ea63d81947 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 20 Aug 2018 08:35:59 +0200 Subject: [PATCH 04/91] find-requires.ksym: fix external kmod deps for symbols with the same name Generate colon-separated pairs of symbol_name:version and then run joins over them instead over just symbol names. Resolves: #2002887 Signed-off-by: Eugene Syromiatnikov --- find-requires.ksyms | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/find-requires.ksyms b/find-requires.ksyms index 6918a01..2c12712 100755 --- a/find-requires.ksyms +++ b/find-requires.ksyms @@ -12,8 +12,8 @@ all_provides() { if [[ -n $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then nm "$@" \ | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ - | awk --non-decimal-data '{printf("0x%08x\t%s\n", $1, $2)}' \ - | LC_ALL=C sort -k2,2 -u + | awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}' \ + | LC_ALL=C sort -k1,1 -u else ELFRODATA=$(readelf -R .rodata "$@" | awk '/0x/{printf $2$3$4$5}') if [[ -n $(readelf -h "$@" | grep "little endian") ]]; then @@ -24,8 +24,8 @@ all_provides() { for sym in $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do echo $sym $RODATA done \ - | awk --non-decimal-data '{printf("0x%08s\t%s\n", substr($3,($1*2)+1,8), $2)}' \ - | LC_ALL=C sort -k2,2 -u + | awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}' \ + | LC_ALL=C sort -k1,1 -u fi } @@ -36,15 +36,15 @@ all_requires() { /sbin/modprobe --dump-modversions "$module" \ | awk --non-decimal-data ' BEGIN { FS = "\t" ; OFS = "\t" } - {printf("0x%08x\t%s\n", $1, $2)}' \ + {printf("%s:0x%08x\n", $2, $1)}' \ | sed -r -e 's:$:\t'"$1"':' done \ - | LC_ALL=C sort -k2,2 -u + | LC_ALL=C sort -k1,1 -u } # Filter out requirements fulfilled by the module itself. mod_requires() { - LC_ALL=C join -t $'\t' -j 2 -v 1 \ + LC_ALL=C join -t $'\t' -j 1 -v 1 \ <(all_requires "$@") \ <(all_provides "$@") \ | LC_ALL=C sort -k1,1 -u @@ -107,22 +107,24 @@ if [ ${#modules[@]} -gt 0 ]; then cat /usr/src/kernels/$kernel/Module.symvers | awk ' BEGIN { FS = "\t" ; OFS = "\t" } - { print $2 "\t" $1 } + { print $2 ":" $1 } ' \ | sed -r -e 's:$:\t'"$kernel"':' \ | LC_ALL=C sort -k1,1 -u > $symvers # Symbols matching with the kernel get a "kernel" dependency - LC_ALL=C join -t $'\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ - | awk '{ FS = "\t" ; OFS = "\t" } { print "kernel(" $1 ") = " $2 }' + mod_req=$(mktemp -t mod_req.XXXXX) + mod_requires "${modules[@]}" > "$mod_req" + LC_ALL=C join -t $'\t' -j 1 $symvers "$mod_req" | LC_ALL=C sort -u \ + | awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print "kernel(" $1 ") = " $2 }' # Symbols from elsewhere get a "ksym" dependency - LC_ALL=C join -t $'\t' -j 1 -v 2 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ - | awk '{ FS = "\t" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }' + LC_ALL=C join -t $'\t' -j 1 -v 2 $symvers "$mod_req" | LC_ALL=C sort -u \ + | awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }' # Check kABI if the kabi-stablelists package is installed # Do this last so we can try to output this error at the end - kabi_check_symbols=($(LC_ALL=C join -t $'\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ - | awk '{ FS = "\t" ; OFS = "\t" } { print $1 }')) + kabi_check_symbols=($(LC_ALL=C join -t $'\t' -j 1 $symvers "$mod_req" | LC_ALL=C sort -u \ + | awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print $1 }')) check_kabi "${kabi_check_symbols[@]}" fi From 40474999ce7f1d9d39f473938598f724c6e8b8bb Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Fri, 24 Aug 2018 08:45:49 +0200 Subject: [PATCH 05/91] Add support for compressed kernel modules - Add support for compressed kernel modules to find-provides.ksyms, find-requires.ksyms, firmware.prov (#1622019) * find-provides.ksyms: Try to process files whose names end with something else than "*.ko" by guessing a decompressor and uncompressing it in a temporary file and parsing it instead. * find-requires.ksyms (all_provides): Likewise. Add "(\.gz|\.bz2|\.xz)?" to the end of the module path matching regular expression. * firmware.prov: Add "(\.gz|\.bz2|\.xz)?" to the end of the module path matching regular expression. Resolves: #1942537 Signed-off-by: Eugene Syromiatnikov --- find-provides.ksyms | 26 ++++++++++++++++++- find-requires.ksyms | 61 ++++++++++++++++++++++++++++++++------------- firmware.prov | 2 +- 3 files changed, 69 insertions(+), 20 deletions(-) diff --git a/find-provides.ksyms b/find-provides.ksyms index 0526cd7..a58978b 100755 --- a/find-provides.ksyms +++ b/find-provides.ksyms @@ -2,7 +2,29 @@ IFS=$'\n' -for module in $(grep -E '/lib/modules/.+\.ko$'); do +for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'); do + tmpfile="" + if [ "x${module%.ko}" = "x${module}" ]; then + tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko) + proc_bin= + case "${module##*.}" in + xz) + proc_bin=xz + ;; + bz2) + proc_bin=bzip2 + ;; + gz) + proc_bin=gzip + ;; + esac + + [ -n "$proc_bin" ] || continue + + "$proc_bin" -d -c - < "$module" > "$tmpfile" || continue + module="$tmpfile" + fi + if [[ -n $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then nm $module \ | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ @@ -21,4 +43,6 @@ for module in $(grep -E '/lib/modules/.+\.ko$'); do | awk --non-decimal-data '{printf("ksym(%s) = 0x%08s\n", $2, substr($3,($1*2)+1,8))}' \ | LC_ALL=C sort -u fi + + [ -z "$tmpfile" ] || rm -f -- "$tmpfile" done diff --git a/find-requires.ksyms b/find-requires.ksyms index 2c12712..d574681 100755 --- a/find-requires.ksyms +++ b/find-requires.ksyms @@ -9,24 +9,49 @@ IFS=$'\n' # Extract all of the symbols provided by this module. all_provides() { - if [[ -n $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then - nm "$@" \ - | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ - | awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}' \ - | LC_ALL=C sort -k1,1 -u - else - ELFRODATA=$(readelf -R .rodata "$@" | awk '/0x/{printf $2$3$4$5}') - if [[ -n $(readelf -h "$@" | grep "little endian") ]]; then - RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') - else - RODATA=$ELFRODATA + for module in "$@"; do + tmpfile="" + if [ "x${module%.ko}" = "x${module}" ]; then + tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko) + proc_bin= + case "${module##*.}" in + xz) + proc_bin=xz + ;; + bz2) + proc_bin=bzip2 + ;; + gz) + proc_bin=gzip + ;; + esac + + [ -n "$proc_bin" ] || continue + + "$proc_bin" -d -c - < "$module" > "$tmpfile" || continue + module="$tmpfile" fi - for sym in $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do - echo $sym $RODATA - done \ - | awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}' \ - | LC_ALL=C sort -k1,1 -u - fi + + if [[ -n $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then + nm "$module" \ + | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ + | awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}' + else + ELFRODATA=$(readelf -R .rodata "$module" | awk '/0x/{printf $2$3$4$5}') + if [[ -n $(readelf -h "$module" | grep "little endian") ]]; then + RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') + else + RODATA=$ELFRODATA + fi + for sym in $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do + echo $sym $RODATA + done \ + | awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}' + fi + + [ -z "$tmpfile" ] || rm -f -- "$tmpfile" + done \ + | LC_ALL=C sort -k1,1 -u } # Extract all of the requirements of this module. @@ -98,7 +123,7 @@ check_kabi() { fi } -modules=($(grep -E '/lib/modules/.+\.ko$')) +modules=($(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$')) if [ ${#modules[@]} -gt 0 ]; then kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q) diff --git a/firmware.prov b/firmware.prov index 3614369..c4aa26f 100644 --- a/firmware.prov +++ b/firmware.prov @@ -5,7 +5,7 @@ IFS=$'\n' -for module in $(grep -E '/lib/modules/.+\.ko$') $*; +for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') $*; do for firmware in `/sbin/modinfo -F firmware $module`; do From 581680855a27e649f47ab372e2795f9c88cd30f2 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 21 Jan 2019 08:52:21 +0100 Subject: [PATCH 06/91] 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 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 --- kmodtool | 161 +++++++++++++++++++++++++++++------------------------ macros.kmp | 27 +++------ 2 files changed, 96 insertions(+), 92 deletions(-) diff --git a/kmodtool b/kmodtool index 1308af2..edf6d4e 100755 --- a/kmodtool +++ b/kmodtool @@ -1,7 +1,12 @@ #!/bin/bash # kmodtool - Helper script for building kernel module RPMs -# Copyright (c) 2003-2006 Ville Skyttä , +# 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ä , # Thorsten Leemhuis # Jon Masters # @@ -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 - echo "%global _use_internal_dependency_generator 0" - fi + # Turn of the internal dep generator so we will use the kmod scripts. + echo "%global _use_internal_dependency_generator 0" cat <= ${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 < /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 < /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 < /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 < /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 <