rpm/modalias-encode.diff
Marcus Rueckert 4b044876a1 Accepting request 523080 from home:michal-m:branches:Base:System
- Generate ksym() dependencies for SLE if %is_opensuse is unset
  (bsc#981083).

- Drop %supplements_kernel_module, as it is broken, undocumented
  and is not used by anybody (bsc#981083).
  dropped: modalias-kernel_module.diff
  refreshed: modalias-encode.diff
- Split fileattrs for kernel and kmps, do not pass around %name and
  simplify the helpers
  refreshed: fileattrs.diff, modalias.diff
  dropped: symset-table, helperenv.diff, modalias-no-kgraft.diff

OBS-URL: https://build.opensuse.org/request/show/523080
OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=403
2017-09-20 15:29:49 +00:00

36 lines
1.2 KiB
Diff

Module aliases (modinfo -F alias <module>) may contain special characters
that rpm does not allow in dependencies, such as commas. Encode those as
%XX to avoid generating broken dependencies.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
--- scripts/find-supplements.ksyms.orig
+++ scripts/find-supplements.ksyms
@@ -35,10 +35,26 @@ combine_modaliases() {
print_modaliases "$class" "$variants" "$pos"
}
+# Encode all characters other than [*:a-zA-Z0-9] in stdin as %XX.
+# (This includes the % character itself, which becomes %25.)
+hexenc() {
+ local line hex
+
+ while read line; do
+ set -- "" "$line"
+ while [[ "$2" =~ ([*:a-zA-Z0-9]*)([^*:a-zA-Z0-9])(.*) ]]; do
+ hex=$(echo -n "${BASH_REMATCH[2]}" | hexdump -e '"%X"')
+ set -- "$1${BASH_REMATCH[1]}%$hex" "${BASH_REMATCH[3]}"
+ done
+ echo "$1$2"
+ done
+}
+
for module in $(grep -E '/lib/modules/.+\.ko$' | grep -v '/lib/modules/[^/]*/kernel/'); do
vermagic=$(/sbin/modinfo -F vermagic "$module")
krel=${vermagic%% *}
/sbin/modinfo -F alias "$module" \
+ | hexenc \
| sed -nre "s,(.+:.+),modalias(kernel-${krel##*-}:\\1),p"
done \
| sort -u \