kmod.attr: add compressed kmod support

* kmod.attr (%__kmod_path): Add ".*\.ko\.gz|.*\.ko\.bz2|.*\.ko\.xz"
to he module path matching regular expression endings.
(%__kmod_provides) <strip_compress_sfx>: New function.
(%__kmod_provides): Generate dependencies with module file name without
compressed extension (just ".ko") for compressed modules.

Resolves: #1942537
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
This commit is contained in:
Eugene Syromiatnikov 2021-11-16 00:19:11 +01:00
parent 2aa8019903
commit f9fcd7463c
1 changed files with 13 additions and 3 deletions

View File

@ -1,21 +1,31 @@
%__kmod_path ^/lib/modules/.*/(modules.builtin|.*ko)
%__kmod_path ^/lib/modules/.*/(modules.builtin|.*\.ko|.*\.ko\.gz|.*\.ko\.bz2|.*\.ko\.xz)$
%__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")
end
function printdep(mod)
print("kmod("..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
printdep(basename(l))
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
}