You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

510 lines
18 KiB

diff -Nuar redhat-rpm-config-9.1.0_old/find-provides.ksyms redhat-rpm-config-9.1.0/find-provides.ksyms
--- redhat-rpm-config-9.1.0_old/find-provides.ksyms 2013-03-22 10:48:56.344881194 +0800
+++ redhat-rpm-config-9.1.0/find-provides.ksyms 2013-03-22 10:49:31.727892674 +0800
@@ -4,6 +4,7 @@
for module in $(grep -E '/lib/modules/.+\.ko$'); do
nm $module \
- | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):ksym(\2) = \1:p'
+ | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \
+ | awk --non-decimal-data '{printf("ksym(%s) = 0x%08x\n", $2, $1)}'
done \
| sort -u
diff -Nuar redhat-rpm-config-9.1.0_old/find-requires redhat-rpm-config-9.1.0/find-requires
--- redhat-rpm-config-9.1.0_old/find-requires 2013-03-22 10:48:56.343881193 +0800
+++ redhat-rpm-config-9.1.0/find-requires 2013-03-22 10:49:31.727892674 +0800
@@ -153,8 +153,7 @@
fi
done
-# Disabling for now while the Fedora kernel doesn't produce kABI deps.
-#[ -x /usr/lib/rpm/redhat/find-requires.ksyms ] && [ "$is_kmod" ] &&
-# printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/redhat/find-requires.ksyms
+[ -x /usr/lib/rpm/redhat/find-requires.ksyms ] && [ "$is_kmod" ] &&
+ printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/redhat/find-requires.ksyms
exit 0
diff -Nuar redhat-rpm-config-9.1.0_old/find-requires.ksyms redhat-rpm-config-9.1.0/find-requires.ksyms
--- redhat-rpm-config-9.1.0_old/find-requires.ksyms 2013-03-22 10:48:56.343881193 +0800
+++ redhat-rpm-config-9.1.0/find-requires.ksyms 2013-03-22 10:49:31.728892676 +0800
@@ -1,20 +1,41 @@
#! /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'
+# Extract all of the symbols provided by this module.
all_provides() {
nm "$@" \
- | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):\1\t\2:p' \
- | sort -k2 -u
+ | 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)}' \
+ | LANG=C sort -k2,2 -u
}
+# Extract all of the requirements of this module.
all_requires() {
for module in "$@"; do
set -- $(/sbin/modinfo -F vermagic "$module" | sed -e 's: .*::' -e q)
/sbin/modprobe --dump-modversions "$module" \
- | sed -r -e 's:^0x0*::' -e 's:$:\t'"$1"':'
+ | awk --non-decimal-data '
+ BEGIN { FS = "\t" ; OFS = "\t" }
+ {printf("0x%08x\t%s\n", $1, $2)}' \
+ | sed -r -e 's:$:\t'"$1"':'
done \
- | sort -k2 -u
+ | LANG=C sort -k2,2 -u
+}
+
+# Filter out requirements fulfilled by the module itself.
+mod_requires() {
+ module=$1
+
+ LANG=C join -t $'\t' -j 2 -v 1 \
+ <(all_requires "$module") \
+ <(all_provides "$module") \
+ | LANG=C sort -k1,1 -u
}
if ! [ -e /sbin/modinfo -a -e /sbin/modprobe ]; then
@@ -22,27 +43,72 @@
exit 0
fi
+check_kabi() {
+ arch=$(uname -m)
+ kabi_file="/lib/modules/kabi/kabi_whitelist_$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-whitelists") 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
- symset_table=$(mktemp -t ${0##*/}.XXXXX)
- /usr/lib/rpm/redhat/symset-table | sort > $symset_table
+ kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q)
+ symvers=$(mktemp -t ${0##*/}.XXXXX)
- join -t $'\t' -j 1 -a 2 $symset_table <(
- # Filter out requirements that we fulfill ourself.
- join -t $'\t' -j 2 -v 1 \
- <(all_requires "${modules[@]}") \
- <(all_provides "${modules[@]}") \
- | awk '
+ cat /usr/src/kernels/$kernel/Module.symvers | awk '
BEGIN { FS = "\t" ; OFS = "\t" }
- { print $3 "/" $2 "/" $1 }
- ' \
- | sort -u) \
- | sort -u \
- | awk '
- { FS = "\t" ; OFS = "\t" }
- NF == 3 { print "kernel(" $2 ") = " $3
- next }
- { split($1, arr, "/")
- print "ksym(" arr[3] ") = " arr[2] }
- '
+ { print $2 "\t" $1 }
+ ' \
+ | sed -r -e 's:$:\t'"$kernel"':' \
+ | LANG=C sort -k1,1 -u > $symvers
+
+ # Symbols matching with the kernel get a "kernel" dependency
+ LANG=C join -t '\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LANG=C sort -u \
+ | awk '{ FS = "\t" ; OFS = "\t" } { print "kernel(" $1 ") = " $2 }'
+
+ # Symbols from elsewhere get a "ksym" dependency
+ LANG=C join -t '\t' -j 1 -v 2 $symvers <(mod_requires "${modules[@]}") | LANG=C sort -u \
+ | awk '{ FS = "\t" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }'
+
+ # Check kABI if the kabi-whitelists package is installed
+ # Do this last so we can try to output this error at the end
+ kabi_check_symbols=($(LANG=C join -t '\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LANG=C sort -u \
+ | awk '{ FS = "\t" ; OFS = "\t" } { print $1 }'))
+ check_kabi "${kabi_check_symbols[@]}"
fi
diff -Nuar redhat-rpm-config-9.1.0_old/kmodtool redhat-rpm-config-9.1.0/kmodtool
--- redhat-rpm-config-9.1.0_old/kmodtool 2013-03-22 10:48:56.344881194 +0800
+++ redhat-rpm-config-9.1.0/kmodtool 2013-03-22 10:49:58.453903908 +0800
@@ -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_verrel $@
variant=${1:-$(uname -r)}
- variant=${variant##$verrel}
+ variant=${variant/#$verrel?(.)/}
variant=${variant:-'""'}
}
@@ -61,117 +75,128 @@
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
-
- cat <<EOF
-Provides: kernel-modules = ${verrel}${variant}
-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}
-#
+ # Turn of the internal dep generator so we will use the kmod scripts.
+ echo "%global _use_internal_dependency_generator 0"
cat <<EOF
+Provides: kernel-modules >= ${verrel}${dotvariant}
+Provides: ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
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.
+This package provides the ${kmod_name} kernel modules built for
+the Linux kernel ${verrel}${dotvariant} for the %{_target_cpu}
+family of processors.
+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 ##
+##############################################################################
+
+cat <<EOF
%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 || :
+if [ -e "/boot/System.map-${verrel}${dotvariant}" ]; then
+ /sbin/depmod -aeF "/boot/System.map-${verrel}${dotvariant}" "${verrel}${dotvariant}" > /dev/null || :
fi
-EOF
-
- if [ ! -z "$kmp" ]; then
- cat <<EOF
-modules=( \$(find /lib/modules/${verrel}${variant}/extra/${kmod_name}) )
+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 [ ! -z "$kmp" ]; then
- cat <<EOF
+if [ -e "/boot/System.map-${verrel}${dotvariant}" ]; then
+ /sbin/depmod -aeF "/boot/System.map-${verrel}${dotvariant}" "${verrel}${dotvariant}" > /dev/null || :
+fi
+
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 @@
- 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 @@
print_rpmtemplate "$@"
exit $?
;;
- rpmtemplate_kmp)
- shift
- kmp=1
- print_rpmtemplate "$@"
- exit $?
- ;;
version)
echo "${myprog} ${myver}"
exit 0
diff -Nuar redhat-rpm-config-9.1.0_old/macros redhat-rpm-config-9.1.0/macros
--- redhat-rpm-config-9.1.0_old/macros 2013-03-22 10:48:56.344881194 +0800
+++ redhat-rpm-config-9.1.0/macros 2013-03-22 10:49:31.730892680 +0800
@@ -175,8 +175,8 @@
%__global_ldflags -Wl,-z,relro %{_hardened_ldflags}
# Use these macros to differentiate between RH and other KMP implementation(s).
-redhat_kernel_module_package 1
-kernel_module_package_release 1
+%global redhat_kernel_module_package 1
+%global kernel_module_package_release 1
#kernel_module_package [ -n name ] [ -v version ] [ -r release ] [ -s script ]
# [ -f filelist] [ -x ] [ -p preamble ] flavor flavor ...
@@ -185,40 +185,27 @@
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*}" \
@@ -231,7 +218,7 @@
then \
nobuildreqs="yes" \
fi \
- kmp_override_filelist="$filelist" kmp_override_preamble="$preamble" kmp_nobuildreqs="$buildreqs" %{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 \
)}
#==============================================================================