rpm/modalias-kernel_module.diff
Marcus Meissner f473250138 Accepting request 263477 from home:Ledest:bashisms
- fix bashisms in brp-compress, symset-table and check-rpaths scripts
- fix shebang in find-supplements.ksyms script that contains bash-specific constructions

OBS-URL: https://build.opensuse.org/request/show/263477
OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=349
2015-01-23 17:36:17 +00:00

75 lines
1.9 KiB
Diff

Index: scripts/find-supplements.ksyms
===================================================================
--- scripts/find-supplements.ksyms.orig
+++ scripts/find-supplements.ksyms
@@ -1,6 +1,8 @@
#!/bin/bash
+SPECFILE=${RPMBUILD_SPECFILE:-/usr/src/packages/SOURCES/$1.spec}
IFS=$'\n'
+PACKAGE=$1
case "$1" in
kernel-module-*) ;; # Fedora kernel module package names start with
@@ -46,11 +48,54 @@ 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() {
+ modlist=$(mktemp)
+ have_module=1
+ for module in $(grep -E '/lib/modules/.+\.ko$'); do
+ vermagic=$(/sbin/modinfo -F vermagic "$module")
+ krel=${vermagic%% *}
+ if ! test -x /sbin/modinfo; then
+ echo "ERROR: add module-init-tools to BuildRequires" >&2
+ exit 1
+ fi
+ have_module=0
+ /sbin/modinfo -F alias "$module" \
+ | sed -nre "s,(.+:.+),modalias(kernel-${krel##*-}:\\1),p" | tee -a $modlist
+ done
+ if ! test -s "$modlist" && test $have_module = 0; then
+ echo "packageand(kernel-${krel##*-}:$PACKAGE)"
+ fi
+ rm -f $modlist
+}
+
+aliases_of_specfile_macro() {
+ declare regex
+
+ regex=$(
+ set -o noglob
+ set -- $(sed -ne 's:^%supplements_kernel_module[ \t]::p' \
+ $SPECFILE)
+ 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