rpm/modalias-kernel_module.diff

62 lines
1.5 KiB
Diff

Index: scripts/find-supplements.ksyms
===================================================================
--- scripts/find-supplements.ksyms
+++ scripts/find-supplements.ksyms
@@ -1,5 +1,6 @@
#! /bin/sh
+RPM_SOURCE_DIR=/usr/src/packages/SOURCES
IFS=$'\n'
case "$1" in
@@ -46,11 +47,43 @@ combine_modaliases() {
print_modaliases "$class" "$variants" "$pos"
}
-for module in $(grep -E '/lib/modules/.+\.ko$'); do
- vermagic=$(/sbin/modinfo -F vermagic "$module")
- krel=${vermagic%% *}
- /sbin/modinfo -F alias "$module" \
- | sed -nre "s,(.+:.+),modalias(kernel-${krel##*-}:\\1),p"
-done \
+aliases_of_filelist() {
+ for module in $(grep -E '/lib/modules/.+\.ko$'); do
+ vermagic=$(/sbin/modinfo -F vermagic "$module")
+ krel=${vermagic%% *}
+ /sbin/modinfo -F alias "$module" \
+ | sed -nre "s,(.+:.+),modalias(kernel-${krel##*-}:\\1),p"
+ done
+}
+
+aliases_of_specfile_macro() {
+ declare regex
+
+ regex=$(
+ set -o noglob
+ set -- $(sed -ne 's:^%supplements_kernel_module[ \t]::p' \
+ $RPM_SOURCE_DIR/$1.spec)
+ while [ $# -ge 1 ]; do
+ regex=$(echo "$1" \
+ | sed -e 's:[.]:\\.:g' \
+ -e 's:?:.:g' \
+ -e 's:\*:.*:g' \
+ -e 's:\\:\\\\:g')
+ echo -n "^$regex\$"
+ [ $# -ge 2 ] && echo -n "|"
+ shift
+ done
+ )
+
+ if [ -n "$regex" ]; then
+ awk '
+ $1 == "alias" && $3 ~ regex { print $2 }
+ ' regex="$regex" /lib/modules/*/modules.alias
+ fi
+}
+
+( aliases_of_filelist
+ aliases_of_specfile_macro "$1"
+) \
| sort -u \
| combine_modaliases