Compare commits
No commits in common. "c9-beta" and "c10s" have entirely different histories.
79
README.md
Normal file
79
README.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# kernel-srpm-macros
|
||||||
|
|
||||||
|
The kernel-srpm-macros package
|
||||||
|
|
||||||
|
This source package results in two "binary" packages, kernel-rpm-macros
|
||||||
|
and kernel-srpm-macros. The role and locations of files is as follows:
|
||||||
|
|
||||||
|
kernel-srpm-macros:
|
||||||
|
|
||||||
|
/usr/lib/rpm/fileattrs/kmod.attr
|
||||||
|
For /lib/modules/XYZ/modules.builtin and .../MODULE.ko.XYZ
|
||||||
|
specifies a Lua script to generate kmod(MODULE.ko)
|
||||||
|
"Provides:" deps
|
||||||
|
/usr/lib/rpm/macros.d/macros.kernel-srpm
|
||||||
|
Automatically included by all rpm invocations.
|
||||||
|
Defines %kernel_arches (try rpm --eval '%kernel_arches')
|
||||||
|
Question: what uses this macro? I didn't find any users.
|
||||||
|
|
||||||
|
kernel-rpm-macros:
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/find-provides.ksyms
|
||||||
|
Runs from rpmbuild at the end of kernel builds and 3rd party module
|
||||||
|
builds, to extract
|
||||||
|
kernel(SYMBOL)=0xHASH "Provides:" deps from modules in kernel packages,
|
||||||
|
and ksym(SYMBOL)=0xHASH for 3rd party modules.
|
||||||
|
Takes input list of files on stdin.
|
||||||
|
/usr/lib/rpm/fileattrs/provided_ksyms.attr
|
||||||
|
For newer rpmbuild with "internal dependency generators",
|
||||||
|
this file specifies that find-provides.ksyms should be run
|
||||||
|
only on .ko.XYZ files
|
||||||
|
(with "external dependency generators", the script needs to
|
||||||
|
filter out the files by itself).
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/find-requires.ksyms
|
||||||
|
?
|
||||||
|
/usr/lib/rpm/fileattrs/required_ksyms.attr
|
||||||
|
For newer rpmbuild with "internal dependency generators",
|
||||||
|
this file specifies that find-requires.ksyms should be run
|
||||||
|
only on .ko.XYZ files, and not for /lib/modules/XYZ/kernel/*
|
||||||
|
(IOW: only for building 3rd-party modules)
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/find-provides.d/modalias.prov
|
||||||
|
Runs from rpmbuild at the end of kernel builds and 3rd party module
|
||||||
|
builds, to extract
|
||||||
|
modalias(pci:SOMETHING)=OPTIONALLY_VERSION "Provides:" deps from modules
|
||||||
|
in kernel and 3rd party modules packages.
|
||||||
|
Takes input list of files on stdin.
|
||||||
|
Question: what uses these deps?
|
||||||
|
/usr/lib/rpm/fileattrs/modalias.attr
|
||||||
|
For newer rpmbuild with "internal dependency generators",
|
||||||
|
this file specifies that modalias.prov should be run
|
||||||
|
only on .ko.XYZ files
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/find-provides.d/firmware.prov
|
||||||
|
?
|
||||||
|
|
||||||
|
/usr/lib/rpm/kabi.sh
|
||||||
|
Runs from rpmbuild at the end of kernel build to extract
|
||||||
|
kernel(SYMBOL)=0xHASH "Provides:" deps.
|
||||||
|
/usr/lib/rpm/fileattrs/kabi.attr
|
||||||
|
For newer rpmbuild with "internal dependency generators",
|
||||||
|
this file specifies that kabi.sh should be run on
|
||||||
|
/boot/symvers-* and /lib/modules/XYZ/symvers.gz
|
||||||
|
|
||||||
|
/usr/lib/rpm/macros.d/macros.kmp
|
||||||
|
Automatically included by all rpm invocations.
|
||||||
|
Defines a number of macros.
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/brp-kmod-restore-perms
|
||||||
|
?
|
||||||
|
/usr/lib/rpm/redhat/brp-kmod-set-exec-bit
|
||||||
|
?
|
||||||
|
|
||||||
|
/usr/lib/rpm/redhat/kmodtool
|
||||||
|
?
|
||||||
|
/usr/lib/rpm/redhat/rpmsort
|
||||||
|
?
|
||||||
|
/usr/lib/rpm/redhat/symset-table
|
||||||
|
?
|
@ -1,91 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
IFS=$'\n'
|
|
||||||
export LC_ALL=C
|
|
||||||
|
|
||||||
# Prevent elfutils from trying to download debuginfos
|
|
||||||
unset DEBUGINFOD_URLS
|
|
||||||
|
|
||||||
|
|
||||||
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
|
||||||
dep_pfx="ksym"
|
|
||||||
# For built-in kmods, "kernel()" syntax is used instead of "ksym()"
|
|
||||||
printf "%s" "$module" | grep -v "^${RPM_BUILD_ROOT}/\?lib/modules/[1-9][^/]*/kernel" > /dev/null \
|
|
||||||
|| dep_pfx="kernel"
|
|
||||||
|
|
||||||
tmpfile=""
|
|
||||||
if [ "x${module%.ko}" = "x${module}" ]; then
|
|
||||||
tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
|
|
||||||
proc_bin=
|
|
||||||
case "${module##*.}" in
|
|
||||||
zst)
|
|
||||||
proc_bin=zstd
|
|
||||||
;;
|
|
||||||
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
|
|
||||||
|
|
||||||
# awk script return code:
|
|
||||||
# 0 - absolute __crc_* symbols have been found, output has been
|
|
||||||
# generated;
|
|
||||||
# 23 - a non-absolute __crc_* symbold has been found;
|
|
||||||
# 42 - no __crc_* symbols have been found.
|
|
||||||
nm "$module" \
|
|
||||||
| awk \
|
|
||||||
-v 'dep_pfx='"$dep_pfx" \
|
|
||||||
--non-decimal-data \
|
|
||||||
'BEGIN { exit_code = 42 }
|
|
||||||
match($0, /^([0-9a-f]+) (.) __crc_(.+)/, a) {
|
|
||||||
if (a[2] == "A") {
|
|
||||||
printf("%s(%s) = 0x%08x\n", dep_pfx, a[3], strtonum("0x" a[1]));
|
|
||||||
exit_code = 0;
|
|
||||||
} else {
|
|
||||||
exit_code = 23;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END { exit exit_code }'
|
|
||||||
|
|
||||||
[ 23 = "$?" ] && {
|
|
||||||
kmod_elf_hdr="$(readelf -h "$module")"
|
|
||||||
[ "x$kmod_elf_hdr" = "x${kmod_elf_hdr%Data:*little endian*}" ]
|
|
||||||
revbytes="$?"
|
|
||||||
|
|
||||||
objdump -t "$module" \
|
|
||||||
| awk \
|
|
||||||
-v 'dep_pfx='"$dep_pfx" \
|
|
||||||
-v 'module='"$module" \
|
|
||||||
-v 'revbytes='"$revbytes" \
|
|
||||||
--non-decimal-data \
|
|
||||||
'function readsect(name, a, t) {
|
|
||||||
a = "";
|
|
||||||
while (("readelf -R \"" name "\" \"" module "\"" | getline t) > 0) {
|
|
||||||
if (match(t, /^ 0x[0-9a-f]{8}/))
|
|
||||||
a = a substr(t, 14, 8) substr(t, 23, 8) substr(t, 32, 8) substr(t, 41, 8);
|
|
||||||
}
|
|
||||||
if (revbytes) { a = gensub(/(..)(..)(..)(..)/, "\\4\\3\\2\\1", "g", a); }
|
|
||||||
sectdata[name] = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
match($0, /^([0-9a-f]+) [gl]...... (.*) [0-9a-f]+ __crc_(.*)$/, a) {
|
|
||||||
if (!(a[2] in sectdata)) { readsect(a[2]) }
|
|
||||||
printf("%s(%s) = 0x%08s\n", dep_pfx, a[3], substr(sectdata[a[2]], (strtonum("0x" a[1]) * 2) + 1, 8))
|
|
||||||
}'
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -z "$tmpfile" ] || rm -f -- "$tmpfile"
|
|
||||||
done \
|
|
||||||
| sort -k1,1 -u
|
|
@ -1,31 +0,0 @@
|
|||||||
%__kmod_path ^/lib/modules/.*/(modules.builtin|.*\.ko|.*\.ko\.gz|.*\.ko\.bz2|.*\.ko\.xz|.*\.ko\.zst)$
|
|
||||||
%__kmod_provides() %{lua:
|
|
||||||
function basename(fn)
|
|
||||||
return string.gsub(fn, "(.*/)(.*)", "%2")
|
|
||||||
end
|
|
||||||
function strip_compress_sfx(fn)
|
|
||||||
return string.gsub(fn, "(.*)(\.gz|\.bz2|\.xz|\.zst)?$", "%1")
|
|
||||||
end
|
|
||||||
function printdep(mod)
|
|
||||||
print("kmod("..mod..") ")
|
|
||||||
end
|
|
||||||
local fn = rpm.expand("%{1}")
|
|
||||||
local bn = basename(fn)
|
|
||||||
if bn == "modules.builtin" then
|
|
||||||
for l in io.lines(fn) do
|
|
||||||
local builtin_mod = basename(l)
|
|
||||||
printdep(builtin_mod)
|
|
||||||
if strip_compress_sfx(builtin_mod) ~= builtin_mod then
|
|
||||||
printdep(strip_compress_sfx(builtin_mod))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local mod = string.match(bn, "%g+.ko")
|
|
||||||
if mod then
|
|
||||||
printdep(mod)
|
|
||||||
if strip_compress_sfx(mod) ~= mod then
|
|
||||||
printdep(strip_compress_sfx(mod))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
#! /bin/bash -efu
|
|
||||||
|
|
||||||
# heavily based upon find-suggests.ksyms by Andreas Gruenbacher <agruen@suse.de>.
|
|
||||||
# with modifications by Michael Brown <Michael_E_Brown@dell.com>
|
|
||||||
#
|
|
||||||
# -- added module versioning info to modalias() symbols
|
|
||||||
# -- removed code which inspects spec files.
|
|
||||||
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
#
|
|
||||||
# Initially, dont generate modalias() lines for kernel package. This needs
|
|
||||||
# additional discussion. Would like to eventually add them for
|
|
||||||
# completeness, so that we can determine when drivers are folded into
|
|
||||||
# mainline kernel.
|
|
||||||
#
|
|
||||||
is_kernel_package=""
|
|
||||||
case "${1:-}" in
|
|
||||||
kernel-module-*) ;; # Fedora kernel module package names start with
|
|
||||||
# kernel-module.
|
|
||||||
kernel*) is_kernel_package=1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if ! [ -z "$is_kernel_package" ]; then
|
|
||||||
cat > /dev/null
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for presence of the commands used
|
|
||||||
which /sbin/modinfo >/dev/null || exit 0
|
|
||||||
which sed >/dev/null || exit 0
|
|
||||||
which sort >/dev/null || exit 0
|
|
||||||
|
|
||||||
print_modaliases() {
|
|
||||||
declare class=$1 variants=$2 pos=$3
|
|
||||||
if [ -n "$variants" ]; then
|
|
||||||
echo "${class:0:pos}[$variants]${class:pos+1}"
|
|
||||||
else
|
|
||||||
[ -z "$class" ] || echo "$class"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
combine_modaliases() {
|
|
||||||
declare tag class variants="" pos="" n
|
|
||||||
read class
|
|
||||||
while read tag; do
|
|
||||||
for ((n=0; n<${#class}; n++)); do
|
|
||||||
if [ "*" != "${class:n:1}" -a \
|
|
||||||
"${class:0:n}" = "${tag:0:n}" -a \
|
|
||||||
"${class:n+1}" = "${tag:n+1}" ] &&
|
|
||||||
( [ -z "$pos" ] || [ $n = $pos ] ); then
|
|
||||||
variants="${variants:-${class:n:1}}${tag:n:1}"
|
|
||||||
pos=$n
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ $n -eq ${#class} ]; then
|
|
||||||
print_modaliases "$class" "$variants" "$pos"
|
|
||||||
variants=
|
|
||||||
pos=
|
|
||||||
class=$tag
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
print_modaliases "$class" "$variants" "$pos"
|
|
||||||
}
|
|
||||||
|
|
||||||
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
|
||||||
# | head -n1 because some modules have *two* version tags. *cough*b44*cough*
|
|
||||||
modver=$(/sbin/modinfo -F version "$module"| head -n1)
|
|
||||||
modver=${modver//[^0-9a-zA-Z._]/_}
|
|
||||||
# only add version tag if it has a version
|
|
||||||
[ -z "$modver" ] || modver=" = $modver"
|
|
||||||
|
|
||||||
/sbin/modinfo -F alias "$module" \
|
|
||||||
| sed -nre "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver,p"
|
|
||||||
done \
|
|
||||||
| sort -u \
|
|
||||||
| combine_modaliases
|
|
138
find-provides.ksyms
Executable file
138
find-provides.ksyms
Executable file
@ -0,0 +1,138 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
# Prevent elfutils from trying to download debuginfos
|
||||||
|
unset DEBUGINFOD_URLS
|
||||||
|
|
||||||
|
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
||||||
|
dep_pfx="ksym"
|
||||||
|
# For built-in kmods, "kernel()" syntax is used instead of "ksym()"
|
||||||
|
printf "%s" "$module" | grep -v "^${RPM_BUILD_ROOT}/\?lib/modules/[1-9][^/]*/kernel" > /dev/null \
|
||||||
|
|| dep_pfx="kernel"
|
||||||
|
|
||||||
|
tmpfile=""
|
||||||
|
if [ "x${module%.ko}" = "x${module}" ]; then
|
||||||
|
tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
|
||||||
|
proc_bin=
|
||||||
|
case "${module##*.}" in
|
||||||
|
zst)
|
||||||
|
proc_bin=zstd
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
|
||||||
|
# A modversion can be stored as an ELF symbol in various ways:
|
||||||
|
# - An immediate symbol whose value is available directly; it shows up
|
||||||
|
# in the nm or objdump -t output, for example:
|
||||||
|
# $ nm mlx5_core_5.14.x86_64.ko | grep '__crc_' | head -n 3
|
||||||
|
# 0000000092f175ca A __crc_mlx5_access_reg
|
||||||
|
# 000000005b88c9f1 A __crc_mlx5_add_flow_rules
|
||||||
|
# 00000000e7c0ec8a A __crc_mlx5_alloc_bfreg
|
||||||
|
# $ objdump -t lib/modules/mlx5_core_5.14.x86_64.ko | grep __crc_ | sort -k 5,5 | head -n 3
|
||||||
|
# 0000000092f175ca g *ABS* 0000000000000000 __crc_mlx5_access_reg
|
||||||
|
# 000000005b88c9f1 g *ABS* 0000000000000000 __crc_mlx5_add_flow_rules
|
||||||
|
# 00000000e7c0ec8a g *ABS* 0000000000000000 __crc_mlx5_alloc_bfreg
|
||||||
|
# $ zgrep mlx5_access_reg ./lib/modules/5.14.0-284.15.1.el9_2.x86_64/symvers.gz
|
||||||
|
# 0x92f175ca mlx5_access_reg drivers/net/ethernet/mellanox/mlx5/core/mlx5_core EXPORT_SYMBOL_GPL
|
||||||
|
# This approach was being used on x86 and arm before Linux 5.19,
|
||||||
|
# for example.
|
||||||
|
#
|
||||||
|
# - A globally or locally visible symbol in a read-only (or not;
|
||||||
|
# sometimes .rodata is not a read-only section, after all, as binutils
|
||||||
|
# commit binutils-2_33~1385 has revealed (and binutils-2_35~1768 hasn't
|
||||||
|
# concealed back)) section (historically .rodata, __kcrctab/__kcrctab_gpl
|
||||||
|
# since Linux v5.19-rc1~139^2~2):
|
||||||
|
# $ nm mlx5_core_5.14.s390x.ko | grep '__crc_' | head -n 3
|
||||||
|
# 0000000000002f7c R __crc_mlx5_access_reg
|
||||||
|
# 0000000000003304 R __crc_mlx5_add_flow_rules
|
||||||
|
# 0000000000002d2c R __crc_mlx5_alloc_bfreg
|
||||||
|
# This layout is used on ppc since Linux v4.10-rc7~15^2~1, for example,
|
||||||
|
# and on all architectures since Linux 5.19. To extract the symbol
|
||||||
|
# versions in this case, we get the offset and the section name
|
||||||
|
# from the "objdump -t" output:
|
||||||
|
# $ objdump -t lib/modules/mlx5_core_5.14.s390x.ko | grep '__crc_' | sort -k 5,5 | head -n 2
|
||||||
|
# 0000000000002f7c g .rodata 0000000000000000 __crc_mlx5_access_reg
|
||||||
|
# 0000000000003304 g .rodata 0000000000000000 __crc_mlx5_add_flow_rules
|
||||||
|
# and the section contents from the "readelf -R" call:
|
||||||
|
# $ readelf -R .rodata mlx5_core_5.14.s390x.ko
|
||||||
|
# [... skipped output ...]
|
||||||
|
# 0x00002f70 6c6f635f 6e6f6465 00000000 ed6560a8 loc_node.....e`.
|
||||||
|
# ^^^^^^^^
|
||||||
|
# comparison with the contents
|
||||||
|
# of lib/modules/5.14.0-284.15.1.el9_2.s390x/symvers.gz corroborates
|
||||||
|
# its correctness:
|
||||||
|
# 0xed6560a8 mlx5_access_reg drivers/net/ethernet/mellanox/mlx5/core/mlx5_core EXPORT_SYMBOL_GPL
|
||||||
|
# As mentioned earlier, for the later kernel versions, __kcrctab{,_gpl}
|
||||||
|
# sections are used:
|
||||||
|
# $ objdump -t lib/modules/mlx5_core_6.4.x86_64.ko | grep '__crc_' | sort -k 5,5 | head -n 2
|
||||||
|
# 0000000000000000 l __kcrctab_gpl 0000000000000000 __crc_mlx5_access_reg
|
||||||
|
# 0000000000000090 l __kcrctab 0000000000000000 __crc_mlx5_add_flow_rules
|
||||||
|
# $ readelf -R __kcrctab_gpl mlx5_core_6.4.x86_64.ko
|
||||||
|
# 0x00000000 38b0d3c3 1840ce35 b99babc7 70b4700c 8....@.5....p.p.
|
||||||
|
# ^^^^^^^^
|
||||||
|
# and in lib/modules/6.4.0-0.rc1.20230511git80e62bc8487b.19.eln126.x86_64/symvers.xz
|
||||||
|
# we see that it is correct (when accounted for the little endianness):
|
||||||
|
# 0xc3d3b038 mlx5_access_reg drivers/net/ethernet/mellanox/mlx5/core/mlx5_core EXPORT_SYMBOL_GPL
|
||||||
|
# This data, after some post-processing, can be used in the awk script
|
||||||
|
# that extracts parts of the section according to the offsets got
|
||||||
|
# from the "objdump -t" output.
|
||||||
|
objdump -t "$module" \
|
||||||
|
| awk \
|
||||||
|
-v 'dep_pfx='"$dep_pfx" \
|
||||||
|
-v 'module='"$module" \
|
||||||
|
--non-decimal-data \
|
||||||
|
'BEGIN { revbytes = 0 }
|
||||||
|
|
||||||
|
function check_endianness( t) {
|
||||||
|
if (revbytes) return revbytes;
|
||||||
|
|
||||||
|
revbytes = -1;
|
||||||
|
while (("readelf -h \"" module "\"" | getline t) > 0) {
|
||||||
|
if (match(t, /^ Data: *2\047s complement, little endian$/)) {
|
||||||
|
revbytes = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return revbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readsect(name, a, t) {
|
||||||
|
a = "";
|
||||||
|
while (("readelf -R \"" name "\" \"" module "\"" | getline t) > 0) {
|
||||||
|
if (match(t, /^ 0x[0-9a-f]{8}/))
|
||||||
|
a = a substr(t, 14, 8) substr(t, 23, 8) substr(t, 32, 8) substr(t, 41, 8);
|
||||||
|
}
|
||||||
|
if (check_endianness() == 1)
|
||||||
|
a = gensub(/(..)(..)(..)(..)/, "\\4\\3\\2\\1", "g", a);
|
||||||
|
sectdata[name] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
match($0, /^([0-9a-f]+) [gl]...... (.*) [0-9a-f]+ __crc_(.*)$/, a) {
|
||||||
|
if (a[2] == "*ABS*") {
|
||||||
|
printf("%s(%s) = 0x%08x\n", dep_pfx, a[3], strtonum("0x" a[1]));
|
||||||
|
} else {
|
||||||
|
if (!(a[2] in sectdata)) { readsect(a[2]) }
|
||||||
|
printf("%s(%s) = 0x%08s\n", dep_pfx, a[3], substr(sectdata[a[2]], (strtonum("0x" a[1]) * 2) + 1, 8))
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
|
[ -z "$tmpfile" ] || rm -f -- "$tmpfile"
|
||||||
|
done \
|
||||||
|
| sort -k1,1 -u
|
84
SOURCES/find-requires.ksyms → find-requires.ksyms
Normal file → Executable file
84
SOURCES/find-requires.ksyms → find-requires.ksyms
Normal file → Executable file
@ -11,7 +11,6 @@ export LC_ALL=C
|
|||||||
# Prevent elfutils from trying to download debuginfos
|
# Prevent elfutils from trying to download debuginfos
|
||||||
unset DEBUGINFOD_URLS
|
unset DEBUGINFOD_URLS
|
||||||
|
|
||||||
|
|
||||||
# Extract all of the symbols provided by this module.
|
# Extract all of the symbols provided by this module.
|
||||||
all_provides() {
|
all_provides() {
|
||||||
for module in "$@"; do
|
for module in "$@"; do
|
||||||
@ -40,53 +39,45 @@ all_provides() {
|
|||||||
module="$tmpfile"
|
module="$tmpfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# awk script return code:
|
objdump -t "$module" \
|
||||||
# 0 - absolute __crc_* symbols have been found, output has been
|
|
||||||
# generated;
|
|
||||||
# 23 - a non-absolute __crc_* symbold has been found;
|
|
||||||
# 42 - no __crc_* symbols have been found.
|
|
||||||
nm "$module" \
|
|
||||||
| awk \
|
| awk \
|
||||||
-v 'dep_pfx='"$dep_pfx" \
|
-v 'dep_pfx='"$dep_pfx" \
|
||||||
--non-decimal-data \
|
-v 'module='"$module" \
|
||||||
'BEGIN { exit_code = 42 }
|
--non-decimal-data \
|
||||||
match($0, /^([0-9a-f]+) (.) __crc_(.+)/, a) {
|
'BEGIN { revbytes = 0 }
|
||||||
if (a[2] == "A") {
|
|
||||||
printf("%s(%s) = 0x%08x\n", dep_pfx, a[3], strtonum("0x" a[1]));
|
|
||||||
exit_code = 0;
|
|
||||||
} else {
|
|
||||||
exit_code = 23;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END { exit exit_code }'
|
|
||||||
|
|
||||||
[ 23 = "$?" ] && {
|
function check_endianness( t) {
|
||||||
kmod_elf_hdr="$(readelf -h "$module")"
|
if (revbytes) return revbytes;
|
||||||
[ "x$kmod_elf_hdr" = "x${kmod_elf_hdr%Data:*little endian*}" ]
|
|
||||||
revbytes="$?"
|
|
||||||
|
|
||||||
objdump -t "$module" \
|
revbytes = -1;
|
||||||
| awk \
|
while (("readelf -h \"" module "\"" | getline t) > 0) {
|
||||||
-v 'dep_pfx='"$dep_pfx" \
|
if (match(t, /^ Data: *2\047s complement, little endian$/)) {
|
||||||
-v 'module='"$module" \
|
revbytes = 1;
|
||||||
-v 'revbytes='"$revbytes" \
|
break;
|
||||||
--non-decimal-data \
|
|
||||||
'function readsect(name, a, t) {
|
|
||||||
a = "";
|
|
||||||
while (("readelf -R \"" name "\" \"" module "\"" | getline t) > 0) {
|
|
||||||
if (match(t, /^ 0x[0-9a-f]{8}/))
|
|
||||||
a = a substr(t, 14, 8) substr(t, 23, 8) substr(t, 32, 8) substr(t, 41, 8);
|
|
||||||
}
|
}
|
||||||
if (revbytes) { a = gensub(/(..)(..)(..)(..)/, "\\4\\3\\2\\1", "g", a); }
|
|
||||||
sectdata[name] = a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match($0, /^([0-9a-f]+) [gl]...... (.*) [0-9a-f]+ __crc_(.*)$/, a) {
|
return revbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readsect(name, a, t) {
|
||||||
|
a = "";
|
||||||
|
while (("readelf -R \"" name "\" \"" module "\"" | getline t) > 0) {
|
||||||
|
if (match(t, /^ 0x[0-9a-f]{8}/))
|
||||||
|
a = a substr(t, 14, 8) substr(t, 23, 8) substr(t, 32, 8) substr(t, 41, 8);
|
||||||
|
}
|
||||||
|
if (revbytes) { a = gensub(/(..)(..)(..)(..)/, "\\4\\3\\2\\1", "g", a); }
|
||||||
|
sectdata[name] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
match($0, /^([0-9a-f]+) [gl]...... (.*) [0-9a-f]+ __crc_(.*)$/, a) {
|
||||||
|
if (a[2] == "*ABS*") {
|
||||||
|
printf("%s(%s) = 0x%08x\n", dep_pfx, a[3], strtonum("0x" a[1]));
|
||||||
|
} else {
|
||||||
if (!(a[2] in sectdata)) { readsect(a[2]) }
|
if (!(a[2] in sectdata)) { readsect(a[2]) }
|
||||||
printf("%s(%s) = 0x%08s\n", dep_pfx, a[3], substr(sectdata[a[2]], (strtonum("0x" a[1]) * 2) + 1, 8))
|
printf("%s(%s) = 0x%08s\n", dep_pfx, a[3], substr(sectdata[a[2]], (strtonum("0x" a[1]) * 2) + 1, 8))
|
||||||
}'
|
}
|
||||||
}
|
}'
|
||||||
|
|
||||||
[ -z "$tmpfile" ] || rm -f -- "$tmpfile"
|
[ -z "$tmpfile" ] || rm -f -- "$tmpfile"
|
||||||
done \
|
done \
|
||||||
@ -186,9 +177,12 @@ if [ ${#modules[@]} -gt 0 ]; then
|
|||||||
join -t $'\t' -j 1 -v 2 $symvers "$mod_req" | sort -u \
|
join -t $'\t' -j 1 -v 2 $symvers "$mod_req" | sort -u \
|
||||||
| awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }'
|
| awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }'
|
||||||
|
|
||||||
# Check kABI if the kabi-stablelists package is installed
|
os_id=$(sed -nr '/^ID[[:space:]]*=/{ s/ID[[:space:]]*=[[:space:]]*//; s/^"(.*)"$/\1/; p }' /etc/os-release)
|
||||||
# Do this last so we can try to output this error at the end
|
if [ "rhel" = "$os_id" ]; then
|
||||||
kabi_check_symbols=($(join -t $'\t' -j 1 $symvers "$mod_req" | sort -u \
|
# Check kABI if the kabi-stablelists package is installed
|
||||||
| awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print $1 }'))
|
# Do this last so we can try to output this error at the end
|
||||||
check_kabi "${kabi_check_symbols[@]}"
|
kabi_check_symbols=($(join -t $'\t' -j 1 $symvers "$mod_req" | sort -u \
|
||||||
|
| awk 'BEGIN { FS = "[\t:]" ; OFS = "\t" } { print $1 }'))
|
||||||
|
check_kabi "${kabi_check_symbols[@]}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
6
gating.yaml
Normal file
6
gating.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
--- !Policy
|
||||||
|
product_versions:
|
||||||
|
- rhel-10
|
||||||
|
decision_context: osci_compose_gate
|
||||||
|
rules:
|
||||||
|
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
@ -1,6 +1,7 @@
|
|||||||
Name: kernel-srpm-macros
|
Name: kernel-srpm-macros
|
||||||
Version: 1.0
|
Version: 1.0
|
||||||
Release: 13%{?dist}
|
# when bumping version and resetting release, don't forget to bump version of kernel-rpm-macros as well
|
||||||
|
Release: 25%{?dist}
|
||||||
Summary: RPM macros that list arches the full kernel is built on
|
Summary: RPM macros that list arches the full kernel is built on
|
||||||
# This package only exist in Fedora repositories
|
# This package only exist in Fedora repositories
|
||||||
# The license is the standard (MIT) specified in
|
# The license is the standard (MIT) specified in
|
||||||
@ -10,10 +11,10 @@ License: MIT
|
|||||||
URL: https://src.fedoraproject.org/rpms/kernel-srpm-macros
|
URL: https://src.fedoraproject.org/rpms/kernel-srpm-macros
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
# We are now the ones shipping kmod.attr
|
# We are now the ones shipping kmod.attr
|
||||||
Conflicts: redhat-rpm-config <= 184
|
Conflicts: redhat-rpm-config < 205
|
||||||
# macros.kmp, kmodtool and rpmsort were moved from kernel-rpm-macros
|
# macros.kmp, kmodtool and rpmsort were moved from kernel-rpm-macros
|
||||||
# to kernel-srpm-macros in 1.0-9/185-9
|
# to kernel-srpm-macros in 1.0-9/185-9
|
||||||
Conflicts: kernel-rpm-macros < 185-9
|
Conflicts: kernel-rpm-macros < 205
|
||||||
|
|
||||||
# Macros
|
# Macros
|
||||||
Source0: macros.kernel-srpm
|
Source0: macros.kernel-srpm
|
||||||
@ -53,10 +54,11 @@ the full kernel is built on.
|
|||||||
The variable to use is kernel_arches.
|
The variable to use is kernel_arches.
|
||||||
|
|
||||||
%package -n kernel-rpm-macros
|
%package -n kernel-rpm-macros
|
||||||
Version: 185
|
Version: 205
|
||||||
Release: %{release}
|
|
||||||
Summary: Macros and scripts for building kernel module packages
|
Summary: Macros and scripts for building kernel module packages
|
||||||
Requires: redhat-rpm-config >= 13
|
# rpmsort is GPL-2.0-or-later
|
||||||
|
License: MIT AND GPL-2.0-or-later
|
||||||
|
Requires: redhat-rpm-config >= 205
|
||||||
|
|
||||||
# for brp-kmod-compress
|
# for brp-kmod-compress
|
||||||
Requires: %{_bindir}/xz
|
Requires: %{_bindir}/xz
|
||||||
@ -113,12 +115,10 @@ install -p -m 644 -t "%{buildroot}%{_fileattrsdir}" modalias.attr
|
|||||||
|
|
||||||
%files
|
%files
|
||||||
%{_rpmconfigdir}/macros.d/macros.kernel-srpm
|
%{_rpmconfigdir}/macros.d/macros.kernel-srpm
|
||||||
%{_rpmconfigdir}/macros.d/macros.kmp
|
|
||||||
%{_fileattrsdir}/kmod.attr
|
%{_fileattrsdir}/kmod.attr
|
||||||
%{rrcdir}/kmodtool
|
|
||||||
%{rrcdir}/rpmsort
|
|
||||||
|
|
||||||
%files -n kernel-rpm-macros
|
%files -n kernel-rpm-macros
|
||||||
|
%{_rpmconfigdir}/macros.d/macros.kmp
|
||||||
%{_rpmconfigdir}/kabi.sh
|
%{_rpmconfigdir}/kabi.sh
|
||||||
%{_fileattrsdir}/kabi.attr
|
%{_fileattrsdir}/kabi.attr
|
||||||
%{_fileattrsdir}/modalias.attr
|
%{_fileattrsdir}/modalias.attr
|
||||||
@ -132,52 +132,83 @@ install -p -m 644 -t "%{buildroot}%{_fileattrsdir}" modalias.attr
|
|||||||
%{rrcdir}/find-requires.ksyms
|
%{rrcdir}/find-requires.ksyms
|
||||||
%{rrcdir}/find-provides.d/firmware.prov
|
%{rrcdir}/find-provides.d/firmware.prov
|
||||||
%{rrcdir}/find-provides.d/modalias.prov
|
%{rrcdir}/find-provides.d/modalias.prov
|
||||||
|
%{rrcdir}/kmodtool
|
||||||
|
%{rrcdir}/rpmsort
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Jun 12 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-13
|
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 1.0-25
|
||||||
- Handle symvers.xz in kabi.attr (#2209253).
|
- Bump release for October 2024 mass rebuild:
|
||||||
- Fix indirect __crc_* sumbols parsing in find-provides.ksyms
|
Resolves: RHEL-64018
|
||||||
and find-requires.ksyms to avoid matching multiple sections
|
|
||||||
producing bogus duplicate provides for kmods that have both __kcrctab
|
|
||||||
and __kcrctab_gpl sections (#2115811, #2178935).
|
|
||||||
- Call "readelf -R" on a correct section in find-requires.ksyms.
|
|
||||||
- Rewrite section data extraction in find-provides.ksyms and find-requires.ksyms
|
|
||||||
to avoid garbage at the end of extracted sections, causing unnecessary awk
|
|
||||||
complaints (#2115811).
|
|
||||||
- Perform section parsing inside the awk script in find-provides.ksyms
|
|
||||||
and find-requires.ksyms to avoid hitting command line argument limit
|
|
||||||
when handling large .rodata sections (#2178935).
|
|
||||||
|
|
||||||
* Tue Jan 31 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-12
|
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1.0-24
|
||||||
|
- Bump release for June 2024 mass rebuild
|
||||||
|
|
||||||
|
* Wed Mar 06 2024 David Abdurachmanov <davidlt@rivosinc.com> - 1.0-23
|
||||||
|
- Add riscv64
|
||||||
|
|
||||||
|
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-22
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||||
|
|
||||||
|
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-21
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-20
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue May 09 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-19
|
||||||
|
- Capture local __crc_* symbols for "Provides: kernel()".
|
||||||
|
- Add support for XZ compression for the symvers file.
|
||||||
|
- Fix "Provides: kernel()" generation when both __kcrctab and __kcrctab_gpl
|
||||||
|
are present.
|
||||||
|
- Fix regression for "Provides:" generation in cases when modversions are stored
|
||||||
|
in a section that is over 64K in size.
|
||||||
|
- Speedup and cleanup changes in find-provides.ksyms and find-requires.ksyms.
|
||||||
|
- Fix regex usage in kmod.attr. (Denys Vlasenko)
|
||||||
|
- Implement modalias "Provides:" grouping. (Denys Vlasenko)
|
||||||
|
- Speedup and cleanup changes in modalias.prov and kmod.attr. (Denys Vlasenko)
|
||||||
|
|
||||||
|
* Tue Mar 30 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-18
|
||||||
|
- Avoid triggering debuginfod during elfutils tools usage.
|
||||||
|
|
||||||
|
* Tue Jan 31 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-17
|
||||||
- Support storing of __crc_* symbols in sections other than .rodata.
|
- Support storing of __crc_* symbols in sections other than .rodata.
|
||||||
- Resolves: #2135047
|
|
||||||
|
|
||||||
* Thu Feb 17 2022 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-11
|
|
||||||
- Work around a change in type of __crc_* symbols for some kmods printed by nm
|
- Work around a change in type of __crc_* symbols for some kmods printed by nm
|
||||||
on ppc64le and s390x
|
on ppc64le and s390x.
|
||||||
- Resolves: #2055464
|
|
||||||
|
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-16
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-15
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-14
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Nov 18 2021 Miro Hrončok <mhroncok@redhat.com> - 1.0-13
|
||||||
|
- Bump kernel-rpm-macros to 205 to provide clear upgrade path
|
||||||
|
|
||||||
|
* Thu Nov 18 2021 Miro Hrončok <mhroncok@redhat.com> - 1.0-12
|
||||||
|
- Correct conflicts to redhat-rpm-macros < 205
|
||||||
|
- Move Perl scripts back to kernel-rpm-macros to avoid Perl in the default buildroot
|
||||||
|
|
||||||
|
* Thu Nov 18 2021 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-11
|
||||||
|
- Add conflicts of redhat-rpm-macros < 204 as macros.kmp, kmodtool,
|
||||||
|
and rpmsort were moved from the latter to the former.
|
||||||
|
- Remove RHEL-specific kABI bits from find-requires.ksyms and macros.kmp.
|
||||||
|
|
||||||
* Thu Nov 18 2021 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-10
|
* Thu Nov 18 2021 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-10
|
||||||
- Add conflicts of kernel-srpm-macros with kernel-rpm-macros < 185-9
|
- Add conflicts of kernel-srpm-macros with kernel-rpm-macros < 185-9
|
||||||
as macros.kmp, kmodtool, and rpmsort were moved from the latter
|
as macros.kmp, kmodtool, and rpmsort were moved from the latter
|
||||||
to the former.
|
to the former.
|
||||||
|
|
||||||
* Mon Sep 20 2021 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-9
|
* Thu Nov 18 2021 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-9
|
||||||
- Update scripts with RHEL-specific changes.
|
- Update scripts with RHEL-specific changes.
|
||||||
|
|
||||||
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0-8
|
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-6
|
||||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||||
Related: rhbz#1991688
|
|
||||||
|
|
||||||
* Tue May 25 2021 Michal Domonkos <mdomonko@redhat.com> - 1.0-7
|
* Thu Jun 03 2021 Michal Domonkos <mdomonko@redhat.com> - 1.0-5
|
||||||
- Bump release for a rebuild in a sidetag
|
- Adopt kernel-rpm-macros & kmod.attr subpackage from redhat-rpm-config
|
||||||
|
|
||||||
* Wed May 12 2021 Michal Domonkos <mdomonko@redhat.com> - 1.0-6
|
|
||||||
- Adopt kernel-rpm-macros subpackage & kmod.attr from redhat-rpm-config
|
|
||||||
- Resolves: #1959914
|
|
||||||
|
|
||||||
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.0-5
|
|
||||||
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
|
||||||
|
|
||||||
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-4
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-4
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
54
kmod.attr
Normal file
54
kmod.attr
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
%__kmod_path ^/lib/modules/.*/(modules.builtin|.*\.ko|.*\.ko\.gz|.*\.ko\.bz2|.*\.ko\.xz|.*\.ko\.zst)$
|
||||||
|
|
||||||
|
# Notes on Lua:
|
||||||
|
# The backslash in strings (like "\n" newline) needs to be doubled
|
||||||
|
# because we are inside rpm macro. Single backslashes before most chars
|
||||||
|
# disappear (removed by rpm's parser), so "\n" turns into just "n".
|
||||||
|
# In string.gsub patterns, unlike regexps, backslash has no special meaning.
|
||||||
|
# It can't escape . and such. (Use one-character set [.] to represent
|
||||||
|
# literal period, or lua's percent escape: %.)
|
||||||
|
# Pipe (|) has no special meaning too.
|
||||||
|
|
||||||
|
%__kmod_provides() %{lua:
|
||||||
|
function basename(fn)
|
||||||
|
local b = string.gsub(fn, ".*/", "")
|
||||||
|
-- the above adjusts gsub() result to 1 value
|
||||||
|
-- "return f()" construct would return _all_ values, two in case of gsub()
|
||||||
|
return b
|
||||||
|
end
|
||||||
|
function strip_compress_sfx(fn)
|
||||||
|
local cnt
|
||||||
|
fn, cnt = string.gsub(fn, "%.gz$", "")
|
||||||
|
if cnt == 1 then return fn; end
|
||||||
|
fn, cnt = string.gsub(fn, "%.bz2$", "")
|
||||||
|
if cnt == 1 then return fn; end
|
||||||
|
fn, cnt = string.gsub(fn, "%.xz$", "")
|
||||||
|
if cnt == 1 then return fn; end
|
||||||
|
fn, cnt = string.gsub(fn, "%.zst$", "")
|
||||||
|
return fn
|
||||||
|
end
|
||||||
|
function printdep(mod)
|
||||||
|
print("kmod("..mod..") ")
|
||||||
|
end
|
||||||
|
local fn = rpm.expand("%1")
|
||||||
|
local bn = basename(fn)
|
||||||
|
if bn == "modules.builtin" then
|
||||||
|
for l in io.lines(fn) do
|
||||||
|
local builtin_mod = basename(l)
|
||||||
|
printdep(builtin_mod)
|
||||||
|
local nocompr = strip_compress_sfx(builtin_mod)
|
||||||
|
if nocompr ~= builtin_mod then
|
||||||
|
printdep(nocompr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local mod = string.match(bn, "%g+%.ko")
|
||||||
|
if mod then
|
||||||
|
printdep(mod)
|
||||||
|
local nocompr = strip_compress_sfx(mod)
|
||||||
|
if nocompr ~= mod then
|
||||||
|
printdep(nocompr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
# kernel_arches lists what arches the full kernel is built for.
|
# kernel_arches lists what arches the full kernel is built for.
|
||||||
|
|
||||||
%kernel_arches x86_64 s390x ppc64le aarch64 %{arm}
|
%kernel_arches x86_64 s390x ppc64le aarch64 %{arm} riscv64
|
@ -13,7 +13,7 @@ redhat_kmp_has_post_hooks 1
|
|||||||
# [ -f filelist] [ -x ] [ -p preamble ] flavor flavor ...
|
# [ -f filelist] [ -x ] [ -p preamble ] flavor flavor ...
|
||||||
|
|
||||||
%kernel_module_package_buildreqs %global kmodtool_generate_buildreqs 1 \
|
%kernel_module_package_buildreqs %global kmodtool_generate_buildreqs 1 \
|
||||||
kernel-devel kernel-abi-stablelists redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod
|
kernel-devel redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod
|
||||||
|
|
||||||
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
|
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
|
||||||
## An ugly hack: we want kmods to be processed by find-debuginfo,
|
## An ugly hack: we want kmods to be processed by find-debuginfo,
|
128
modalias.prov
Executable file
128
modalias.prov
Executable file
@ -0,0 +1,128 @@
|
|||||||
|
#! /bin/bash -efu
|
||||||
|
|
||||||
|
# heavily based upon find-suggests.ksyms by Andreas Gruenbacher <agruen@suse.de>.
|
||||||
|
# with modifications by Michael Brown <Michael_E_Brown@dell.com>
|
||||||
|
#
|
||||||
|
# -- added module versioning info to modalias() symbols
|
||||||
|
# -- removed code which inspects spec files.
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Initially, dont generate modalias() lines for kernel package. This needs
|
||||||
|
# additional discussion. Would like to eventually add them for
|
||||||
|
# completeness, so that we can determine when drivers are folded into
|
||||||
|
# mainline kernel.
|
||||||
|
#
|
||||||
|
is_kernel_package=""
|
||||||
|
case "${1:-}" in
|
||||||
|
kernel-module-*) ;; # Fedora kernel module package names start with
|
||||||
|
# kernel-module.
|
||||||
|
kernel*) is_kernel_package=1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if ! [ -z "$is_kernel_package" ]; then
|
||||||
|
cat > /dev/null
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for presence of the commands used.
|
||||||
|
# "command" is a builtin, faster to use than fork+execing "which" - see
|
||||||
|
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
|
||||||
|
command -v /sbin/modinfo >/dev/null || exit 1
|
||||||
|
command -v sed >/dev/null || exit 1
|
||||||
|
command -v sort >/dev/null || exit 1
|
||||||
|
|
||||||
|
print_modaliases() {
|
||||||
|
local class="$1" variants="$2" pos="$3"
|
||||||
|
if [ -n "$variants" ]; then
|
||||||
|
echo "${class:0:pos}[$variants]${class:pos+1}"
|
||||||
|
else
|
||||||
|
[ -z "$class" ] || echo "$class"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Try to make "provides" list a bit smaller:
|
||||||
|
# find "mergeable" strings a-la
|
||||||
|
# modalias(pci:v0000168Cd00000023sv*sd*bc*sc*i*)
|
||||||
|
# modalias(pci:v0000168Cd00000024sv*sd*bc*sc*i*)
|
||||||
|
# modalias(pci:v0000168Cd00000027sv*sd*bc*sc*i*)
|
||||||
|
# modalias(pci:v0000168Cd00000029sv*sd*bc*sc*i*)
|
||||||
|
# replace with
|
||||||
|
# modalias(pci:v0000168Cd0000002[3479]sv*sd*bc*sc*i*)
|
||||||
|
combine_modaliases() {
|
||||||
|
local unused_len next prev variants="" pos="" n end xc
|
||||||
|
|
||||||
|
# Due to set -e, we can exit with exitcode 1 on read EOF
|
||||||
|
# and this makes our caller think we failed. "|| return 0" prevents this:
|
||||||
|
IFS=' ' read unused_len prev || return 0
|
||||||
|
|
||||||
|
# For each line after the first...
|
||||||
|
while IFS=' ' read unused_len next; do
|
||||||
|
if [ -z "$pos" ]; then
|
||||||
|
# 2nd line: after "modalias(" prefix, for each char in prev line...
|
||||||
|
n=9
|
||||||
|
end=${#prev}
|
||||||
|
# TODO speedup? if [ $end != ${#next} ]; then line is not mergeable
|
||||||
|
else
|
||||||
|
# 3rd+ lines: only check the char at the same position
|
||||||
|
n=$pos
|
||||||
|
end=$((pos + 1))
|
||||||
|
fi
|
||||||
|
# Search for aaaNbbb,aaaMbbb line pair, where N and M chars differ.
|
||||||
|
# sort -u guarantees there are no identical line pairs.
|
||||||
|
# We assume that lines will not differ only in " = version" suffix.
|
||||||
|
for ((; n < $end; n++)); do
|
||||||
|
if [ "${prev:0:n}" != "${next:0:n}" ]; then
|
||||||
|
# the prefixes already aren't the same: break
|
||||||
|
n=$end
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# If suffixes differ, go to next char
|
||||||
|
[ x"${prev:n+1}" != x"${next:n+1}" ] && continue
|
||||||
|
# Found aaaNbbb,aaaMbbb. If N and M aren't special...
|
||||||
|
xc=x"${prev:n:1}"
|
||||||
|
[ x"[" = "$xc" -o x"]" = "$xc" ] && continue
|
||||||
|
[ x"?" = "$xc" -o x"*" = "$xc" ] && continue
|
||||||
|
xc=x"${next:n:1}"
|
||||||
|
[ x"[" = "$xc" -o x"]" = "$xc" ] && continue
|
||||||
|
[ x"?" = "$xc" -o x"*" = "$xc" ] && continue
|
||||||
|
# Add M (and maybe N) to $variants, go to next line
|
||||||
|
variants="${variants:-${prev:n:1}}${next:n:1}"
|
||||||
|
pos=$n
|
||||||
|
break
|
||||||
|
done
|
||||||
|
if [ $n -eq $end ]; then
|
||||||
|
# This line is not mergeable with the previous one(s),
|
||||||
|
# print collected merged line and reset the state
|
||||||
|
print_modaliases "$prev" "$variants" "$pos"
|
||||||
|
variants=""
|
||||||
|
pos=""
|
||||||
|
prev=$next
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Print last collected merged line
|
||||||
|
print_modaliases "$prev" "$variants" "$pos"
|
||||||
|
}
|
||||||
|
|
||||||
|
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
||||||
|
modver=$(/sbin/modinfo -F version "$module")
|
||||||
|
# delete possible extra lines because some modules have *two* version tags. *cough*b44*cough*
|
||||||
|
modver=${modver%%$'\n'*} # using $'' bashism, avoid running "head -n1" process
|
||||||
|
# replace any strange chars with underscores.
|
||||||
|
# [!...] is glob's "match any char not in set" pattern
|
||||||
|
# (although bash supports [^...] too, it is not standard)
|
||||||
|
modver=${modver//[!0-9a-zA-Z._]/_}
|
||||||
|
# only add version tag if it indeed has a version
|
||||||
|
[ -z "$modver" ] || modver=" = $modver"
|
||||||
|
|
||||||
|
/sbin/modinfo -F alias "$module" \
|
||||||
|
| sed -E "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver,"
|
||||||
|
|
||||||
|
# Below: combining code can only possibly combine lines of equal length.
|
||||||
|
# Prepend line lengths before sort, so that same-length lines end up next
|
||||||
|
# to each other. (The lengths are discarded by combine_modaliases).
|
||||||
|
done \
|
||||||
|
| { while read line; do echo "${#line} $line"; done } \
|
||||||
|
| LC_ALL=C sort -u \
|
||||||
|
| combine_modaliases
|
31
tests/modalias.prov.collect
Executable file
31
tests/modalias.prov.collect
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#! /bin/bash -efu
|
||||||
|
|
||||||
|
# This fetches test data from current system's /lib/modules
|
||||||
|
# to /tmp/COLLECT
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
find /lib/modules | grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$' \
|
||||||
|
| while IFS='' read -r module; do
|
||||||
|
modver=$(/sbin/modinfo -F version "$module")
|
||||||
|
# delete possible extra lines because some modules have *two* version tags. *cough*b44*cough*
|
||||||
|
modver=${modver%%$'\n'*} # using $'' bashism, avoid running "head -n1" process
|
||||||
|
# replace any strange chars with underscores.
|
||||||
|
# [!...] is glob's "match any char not in set" pattern
|
||||||
|
# (although bash supports [^...] too, it is not standard)
|
||||||
|
modver=${modver//[!0-9a-zA-Z._]/_}
|
||||||
|
# only add version tag if it has a version
|
||||||
|
[ -z "$modver" ] || modver=" = $modver"
|
||||||
|
|
||||||
|
d="/tmp/COLLECT$module"
|
||||||
|
d="${d%/*}"
|
||||||
|
mkdir -p "$d"
|
||||||
|
|
||||||
|
out=`/sbin/modinfo -F alias "$module" \
|
||||||
|
| sed -E "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver,"`
|
||||||
|
|
||||||
|
[ "$out" ] || continue
|
||||||
|
|
||||||
|
echo "/tmp/COLLECT$module.modalias$modver" >&2
|
||||||
|
printf '%s\n' "$out" >"/tmp/COLLECT$module.modalias"
|
||||||
|
done
|
42
tests/modalias.prov.runtest
Executable file
42
tests/modalias.prov.runtest
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
function die()
|
||||||
|
{
|
||||||
|
printf '%s\n' "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd modalias.prov.testdata
|
||||||
|
test -x ../../modalias.prov || die "No ../../modalias.prov"
|
||||||
|
|
||||||
|
# Copy and add -t option to modalias.prov
|
||||||
|
cp ../../modalias.prov modalias.prov
|
||||||
|
patch -p1 <<"EOF"
|
||||||
|
--- a/modalias.prov
|
||||||
|
+++ b/modalias.prov
|
||||||
|
@@ -105,6 +105,17 @@ combine_modaliases() {
|
||||||
|
print_modaliases "$prev" "$variants" "$pos"
|
||||||
|
}
|
||||||
|
|
||||||
|
+if [ "$#" = 2 ] && [ "$1" = "-t" ]; then
|
||||||
|
+ cat -- "$2" \
|
||||||
|
+ | { while read line; do echo "${#line} $line"; done } \
|
||||||
|
+ | LC_ALL=C sort -u \
|
||||||
|
+ | combine_modaliases \
|
||||||
|
+ >"$2.test"
|
||||||
|
+ echo "Comparing results for $2"
|
||||||
|
+ diff -u "$2.right" "$2.test" && rm -- "$2.test"
|
||||||
|
+ exit
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
||||||
|
modver=$(/sbin/modinfo -F version "$module")
|
||||||
|
# delete possible extra lines because some modules have *two* version tags. *cough*b44*cough*
|
||||||
|
EOF
|
||||||
|
|
||||||
|
find | grep '\.ko.*\.modalias$' | xargs -n1 ./modalias.prov -t
|
||||||
|
|
||||||
|
# Rename newly generated .test as .right
|
||||||
|
#find | grep '\.ko.*\.modalias$' | xargs -I'{}' mv '{}'.test '{}'.right
|
BIN
tests/modalias.prov.testdata.tar.xz
Normal file
BIN
tests/modalias.prov.testdata.tar.xz
Normal file
Binary file not shown.
62
tests/sanity/Makefile
Normal file
62
tests/sanity/Makefile
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Description: Gating test for kernel-srpm-macros
|
||||||
|
# Author: Ziqian SUN (Zamir) <zsun@redhat.com>
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 Red Hat, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# This copyrighted material is made available to anyone wishing
|
||||||
|
# to use, modify, copy, or redistribute it subject to the terms
|
||||||
|
# and conditions of the GNU General Public License version 2.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be
|
||||||
|
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public
|
||||||
|
# License along with this program; if not, write to the Free
|
||||||
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
TOPLEVEL_NAMESPACE=kernel
|
||||||
|
PACKAGE_NAME=kernel-srpm-macros
|
||||||
|
RELATIVE_PATH=general/kmod/kernel-srpm-macros/gating
|
||||||
|
|
||||||
|
export TESTVERSION=1.0
|
||||||
|
export TEST=/$(TOPLEVEL_NAMESPACE)/$(RELATIVE_PATH)
|
||||||
|
|
||||||
|
.PHONY: all install download clean
|
||||||
|
|
||||||
|
BUILT_FILES=
|
||||||
|
|
||||||
|
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||||
|
|
||||||
|
run: $(FILES) build
|
||||||
|
./runtest.sh
|
||||||
|
|
||||||
|
build: $(BUILT_FILES)
|
||||||
|
chmod a+x ./runtest.sh
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ *.rpm $(BUILT_FILES)
|
||||||
|
|
||||||
|
include /usr/share/rhts/lib/rhts-make.include
|
||||||
|
|
||||||
|
$(METADATA): Makefile
|
||||||
|
@touch $(METADATA)
|
||||||
|
@echo "Owner: Ziqian SUN (Zamir) <zsun@redhat.com>" > $(METADATA)
|
||||||
|
@echo "Name: $(TEST)" >> $(METADATA)
|
||||||
|
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||||
|
@echo "License: GPLv2" >> $(METADATA)
|
||||||
|
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||||
|
@echo "Description: kernel-srpm-macros gating test">> $(METADATA)
|
||||||
|
@echo "TestTime: 90m" >> $(METADATA)
|
||||||
|
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||||
|
@echo "Requires: kernel-srpm-macros" >> $(METADATA)
|
||||||
|
@echo "RhtsRequires: " >> $(METADATA)
|
1
tests/sanity/PURPOSE
Normal file
1
tests/sanity/PURPOSE
Normal file
@ -0,0 +1 @@
|
|||||||
|
Gating test for kernel-srpm-macros
|
13
tests/sanity/metadata
Normal file
13
tests/sanity/metadata
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[General]
|
||||||
|
name=kernel-srpm-macros
|
||||||
|
owner= Ziqian SUN (Zamir) <zsun@redhat.com>
|
||||||
|
description=Gating test for kernel-srpm-macros
|
||||||
|
license=GPLv2
|
||||||
|
confidential=no
|
||||||
|
destructive=no
|
||||||
|
|
||||||
|
[restraint]
|
||||||
|
entry_point=./runtest.sh
|
||||||
|
max_time=90m
|
||||||
|
dependencies=kernel-srpm-macros
|
||||||
|
repoRequires=
|
38
tests/sanity/runtest.sh
Executable file
38
tests/sanity/runtest.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# runtest.sh for kernel-srpm-macros gating test.
|
||||||
|
# Author: Ziqian SUN (Zamir) <zsun@redhat.com>
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 2 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be
|
||||||
|
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
# Include Beaker environment
|
||||||
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||||
|
|
||||||
|
rlJournalStart
|
||||||
|
rlPhaseStartTest "kernel_arches"
|
||||||
|
rlRun -l "rpm --eval \%kernel_arches"
|
||||||
|
rlRun -l "rpm --eval \%kernel_arches | grep x86_64"
|
||||||
|
popd
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlJournalPrintText
|
||||||
|
rlJournalEnd
|
9
tests/tests.yml
Normal file
9
tests/tests.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
tags:
|
||||||
|
- classic
|
||||||
|
roles:
|
||||||
|
- role: standard-test-beakerlib
|
||||||
|
tests:
|
||||||
|
- sanity
|
||||||
|
required_packages:
|
||||||
|
- kernel-srpm-macros
|
Loading…
Reference in New Issue
Block a user