rpm/modalias-encode.diff

41 lines
1.3 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>
Index: rpm-4.4.2.3/scripts/find-supplements.ksyms
===================================================================
--- scripts/find-supplements.ksyms
+++ scripts/find-supplements.ksyms
@@ -48,6 +48,21 @@ 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
+}
+
aliases_of_filelist() {
modlist=$(mktemp)
have_module=1
@@ -60,6 +75,7 @@ aliases_of_filelist() {
fi
have_module=0
/sbin/modinfo -F alias "$module" \
+ | hexenc \
| sed -nre "s,(.+:.+),modalias(kernel-${krel##*-}:\\1),p" | tee -a $modlist
done
if ! test -s "$modlist" && test $have_module = 0; then