From 52ba5a74f22341b4226b4ce9fc9670668756986f Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Wed, 17 Nov 2021 12:22:33 +0100 Subject: [PATCH] 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 --- modalias.prov | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modalias.prov b/modalias.prov index aa33cab..b131b09 100644 --- a/modalias.prov +++ b/modalias.prov @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash -efu # heavily based upon find-suggests.ksyms by Andreas Gruenbacher . # with modifications by Michael Brown @@ -14,7 +14,8 @@ IFS=$'\n' # completeness, so that we can determine when drivers are folded into # mainline kernel. # -case "$1" in +is_kernel_package="" +case "${1:-}" in kernel-module-*) ;; # Fedora kernel module package names start with # kernel-module. kernel*) is_kernel_package=1 ;; @@ -25,6 +26,11 @@ if ! [ -z "$is_kernel_package" ]; then exit 0 fi +# Check for presence of the commands used +which /sbin/modinfo >/dev/null || exit 0 +which sed >/dev/null || exit 0 +which sort >/dev/null || exit 0 + print_modaliases() { declare class=$1 variants=$2 pos=$3 if [ -n "$variants" ]; then @@ -35,7 +41,7 @@ print_modaliases() { } combine_modaliases() { - declare tag class variants pos n + declare tag class variants="" pos="" n read class while read tag; do for ((n=0; n<${#class}; n++)); do