Add zstd kmod compression support

* brp-kmod-restore-perms: Add chech for "$RPM_BUILD_ROOT/$path.zst".
* find-provides.ksyms: Add "\.zst" to the kernel module path matching
regular expression; process kernel module with zstd if its file name
ends with "zst".
* find-requires.ksyms: Likewise.
* firmware.prov: Add "\.zst" to the kernel module path matching
regular expression.
* kmodtool (%post, %preun): Likewise.
* modalias.prov: Likewise.
* modalias.attr (%__modalias_path): Add "ko\.zst" to the kernel module
path matching regular expression.
* provided_ksyms.attr (%__provided_ksyms_path): Likewise.
* required_ksyms.attr (%__required_ksyms_path): Likewise.
* kmod.attr (%__kmod_path): Add ".*\.ko\.zst" to the kernel module path
matching regular expression.
(strip_compress_sfx): Strip "\.zst" suffix, if present.

Resolves: #1942537
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
This commit is contained in:
Eugene Syromiatnikov 2021-11-17 12:38:00 +01:00
parent 6bc05248ec
commit bebabb191d
10 changed files with 18 additions and 11 deletions

View File

@ -19,6 +19,7 @@ while read perm path; do
[ \! -e "$RPM_BUILD_ROOT/$path.gz" ] || path="$path.gz"
[ \! -e "$RPM_BUILD_ROOT/$path.bz2" ] || path="$path.bz2"
[ \! -e "$RPM_BUILD_ROOT/$path.xz" ] || path="$path.xz"
[ \! -e "$RPM_BUILD_ROOT/$path.zst" ] || path="$path.zst"
}
chmod "$perm" "$RPM_BUILD_ROOT/$path"

View File

@ -2,7 +2,7 @@
IFS=$'\n'
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') "$@"; do
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 \
@ -13,6 +13,9 @@ for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') "$@"; do
tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
proc_bin=
case "${module##*.}" in
zst)
proc_bin=zstd
;;
xz)
proc_bin=xz
;;

View File

@ -15,6 +15,9 @@ all_provides() {
tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
proc_bin=
case "${module##*.}" in
zst)
proc_bin=zstd
;;
xz)
proc_bin=xz
;;
@ -123,7 +126,7 @@ check_kabi() {
fi
}
modules=($(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') "$@")
modules=($(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@")
if [ ${#modules[@]} -gt 0 ]; then
kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q)

View File

@ -5,7 +5,7 @@
IFS=$'\n'
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') $*;
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') $*;
do
for firmware in `/sbin/modinfo -F firmware $module`;
do

View File

@ -1,10 +1,10 @@
%__kmod_path ^/lib/modules/.*/(modules.builtin|.*\.ko|.*\.ko\.gz|.*\.ko\.bz2|.*\.ko\.xz)$
%__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)?$", "%1")
return string.gsub(fn, "(.*)(\.gz|\.bz2|\.xz|\.zst)?$", "%1")
end
function printdep(mod)
print("kmod("..mod..") ")

View File

@ -211,7 +211,7 @@ if [ -e "/boot/System.map-${verrel}${dotvariant}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-${verrel}${dotvariant}" "${verrel}${dotvariant}" > /dev/null || :
fi
modules=( \$(find /lib/modules/${verrel}${dotvariant}/extra/${kmod_name} | grep -E '\.ko(\.gz|\.bz2|\.xz)?$') )
modules=( \$(find /lib/modules/${verrel}${dotvariant}/extra/${kmod_name} | grep -E '\.ko(\.gz|\.bz2|\.xz|\.zst)?$') )
if [ -x "/usr/sbin/weak-modules" ]; then
printf '%s\n' "\${modules[@]}" \
| /usr/sbin/weak-modules --add-modules
@ -220,7 +220,7 @@ EOF
cat <<EOF
%preun -n kmod-${kmod_name}${dashvariant}
rpm -ql kmod-${kmod_name}${dashvariant}-%{kmod_version}-%{kmod_release}.$(arch) | grep -E '\.ko(\.gz|\.bz2|\.xz)?$' > /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
rpm -ql kmod-${kmod_name}${dashvariant}-%{kmod_version}-%{kmod_release}.$(arch) | grep -E '\.ko(\.gz|\.bz2|\.xz|\.zst)?$' > /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
EOF
cat <<EOF

View File

@ -1,2 +1,2 @@
%__modalias_provides /usr/lib/rpm/redhat/find-provides.d/modalias.prov
%__modalias_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz)$
%__modalias_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz|ko\.zst)$

View File

@ -58,7 +58,7 @@ combine_modaliases() {
print_modaliases "$class" "$variants" "$pos"
}
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$') "$@"; do
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// /_}

View File

@ -1,2 +1,2 @@
%__provided_ksyms_provides /usr/lib/rpm/redhat/find-provides.ksyms
%__provided_ksyms_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz)$
%__provided_ksyms_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz|ko\.zst)$

View File

@ -1,4 +1,4 @@
%__required_ksyms_requires /usr/lib/rpm/redhat/find-requires.ksyms
%__required_ksyms_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz)$
%__required_ksyms_path .*\.(ko|ko\.gz|ko\.bz2|ko\.xz|ko\.zst)$
# Exclude built-in kernel modules
%__required_ksyms_exclude_path ^/lib/modules/[1-9][^/]*/kernel/.*