Commit Graph

13 Commits

Author SHA1 Message Date
Denys Vlasenko
5683c50270 modalias.prov: use standard "match any char not in set" glob pattern, and sed -E option
[^set] is not correct in glob (it's regexp construct). [!set] is.

sed: -n is not necessary. -e too. manpage recommends using -E instead of -r.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:56:30 +02:00
Denys Vlasenko
35e1f2fc73 modalias.prov: speed up, explain and make more correct combining code
The time to run on tests/* data decreased from 34.517s to 30.201s.

Do not allow combining of any glob meta characters, either in first
or second line.

The code is still buggy, it may attempt to combine
    modalias(abc[def]123)
    modalias(abc[dXf]123)
into
    modalias(abc[d[eX]f]123)
(presumably there won't be any such cases in real modules, but still).

Eliminate "| head -n1" - do it with bash string ops.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:49:24 +02:00
Denys Vlasenko
7cd7d838cf modalias.prov: group modalias lines by length
On my machine, out of 2604 modules, this reduces number of
"provides" items by ~800 (to 12689 items).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:29:18 +02:00
Denys Vlasenko
c2b1f3e458 modalias.prov: avoid a subshell (fork) in position check
This creates a subshell: ... && ( [ -z "$pos" ] || [ $n = $pos ] )

For example, processing ath9k.ko needed ~80 forks here.
Rather expensive.

This should do the same: ... && [ -z "$pos" -o "$n" = "$pos" ]

While at it, explain algorithm in comments.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 18:17:29 +02:00
Denys Vlasenko
653ec7d086 modalias.prov: use "local" builtin rather than "declare"
While (in this case) their effect is the same,
many more people know that "local" makes variables function-local,
than that "declare" in bash does the same. I didn't know.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:40:03 +02:00
Denys Vlasenko
510e0c8261 modalias.prov: make sort locale-independent with LC_ALL=C
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:35:42 +02:00
Denys Vlasenko
6a6920aed2 modalias.prov: use "command" rather than "which" to check existence of commands
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:34:05 +02:00
Denys Vlasenko
9d75b962fc modalias.prov: fix spurious exitcode of 1 on reaching EOF
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-03 11:30:18 +02:00
Eugene Syromiatnikov
f218d75450 modalias.prov: stricter module aliase/version mangling
* modalias.prov: Replace everyithing that is not "0-9a-zA-Z.:"
in a kernel module version with underscores;  replace everything
that is not "][0-9a-zA-Z.:*_?/-" in a kernel module alias with
underscores.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
52ba5a74f2 modalias.prov: change interpreter to /bin/bash -efu
* modalias.prov: Chnge interpreter from "/bin/sh" to "/bin/bash" because
it uses bashisms;  add "-efu" flags to keep things in check; initialise
is_kernel_package variable; check for presence of /sbin/modinfo, sed,
and sort.
(combine_modaliases): Initialise the "variants" and "pos" variables.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
1208dd48a6 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>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
ce2a205fbd modalias.prov: process compressed kmods
* modalias.prov: Add "(\.gz|\.bz2|\.xz)?" to the end of the module path
matching regular expression, use "$@" instead of $*.

Resolves: #1942537
Resolves: #2024117
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:38:10 +01:00
Michal Domonkos
33b5f1bcf4 Adopt kernel-rpm-macros subpackage from redhat-rpm-config
This has been done in CentOS Stream already:
https://gitlab.com/redhat/centos-stream/rpms/kernel-srpm-macros/-/merge_requests/1
2021-06-03 17:21:53 +02:00