From 1208dd48a6cd6791320f0e9a6458f4ad975291f6 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Wed, 17 Nov 2021 12:38:00 +0100 Subject: [PATCH] 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 --- brp-kmod-restore-perms | 1 + find-provides.ksyms | 5 ++++- find-requires.ksyms | 5 ++++- firmware.prov | 2 +- kmod.attr | 4 ++-- kmodtool | 4 ++-- modalias.attr | 2 +- modalias.prov | 2 +- provided_ksyms.attr | 2 +- required_ksyms.attr | 2 +- 10 files changed, 18 insertions(+), 11 deletions(-) diff --git a/brp-kmod-restore-perms b/brp-kmod-restore-perms index 3822fa4..ffabefc 100755 --- a/brp-kmod-restore-perms +++ b/brp-kmod-restore-perms @@ -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" diff --git a/find-provides.ksyms b/find-provides.ksyms index 479e634..af98b90 100755 --- a/find-provides.ksyms +++ b/find-provides.ksyms @@ -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 ;; diff --git a/find-requires.ksyms b/find-requires.ksyms index ae45d94..533fac0 100755 --- a/find-requires.ksyms +++ b/find-requires.ksyms @@ -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) diff --git a/firmware.prov b/firmware.prov index c4aa26f..8c5b7e4 100644 --- a/firmware.prov +++ b/firmware.prov @@ -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 diff --git a/kmod.attr b/kmod.attr index 993777e..23b1289 100644 --- a/kmod.attr +++ b/kmod.attr @@ -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..") ") diff --git a/kmodtool b/kmodtool index 6c43725..3066987 100755 --- a/kmodtool +++ b/kmodtool @@ -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 < /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 <