|
|
936cd0 |
#! /bin/bash -efu
|
|
|
67e50c |
|
|
|
67e50c |
# heavily based upon find-suggests.ksyms by Andreas Gruenbacher <agruen@suse.de>.
|
|
|
67e50c |
# with modifications by Michael Brown <Michael_E_Brown@dell.com>
|
|
|
67e50c |
#
|
|
|
67e50c |
# -- added module versioning info to modalias() symbols
|
|
|
67e50c |
# -- removed code which inspects spec files.
|
|
|
67e50c |
|
|
|
67e50c |
IFS=$'\n'
|
|
|
67e50c |
|
|
|
67e50c |
#
|
|
|
67e50c |
# Initially, dont generate modalias() lines for kernel package. This needs
|
|
|
67e50c |
# additional discussion. Would like to eventually add them for
|
|
|
67e50c |
# completeness, so that we can determine when drivers are folded into
|
|
|
67e50c |
# mainline kernel.
|
|
|
67e50c |
#
|
|
|
936cd0 |
is_kernel_package=""
|
|
|
936cd0 |
case "${1:-}" in
|
|
|
67e50c |
kernel-module-*) ;; # Fedora kernel module package names start with
|
|
|
67e50c |
# kernel-module.
|
|
|
67e50c |
kernel*) is_kernel_package=1 ;;
|
|
|
67e50c |
esac
|
|
|
67e50c |
|
|
|
67e50c |
if ! [ -z "$is_kernel_package" ]; then
|
|
|
67e50c |
cat > /dev/null
|
|
|
67e50c |
exit 0
|
|
|
67e50c |
fi
|
|
|
67e50c |
|
|
|
936cd0 |
# Check for presence of the commands used
|
|
|
936cd0 |
which /sbin/modinfo >/dev/null || exit 0
|
|
|
936cd0 |
which sed >/dev/null || exit 0
|
|
|
936cd0 |
which sort >/dev/null || exit 0
|
|
|
936cd0 |
|
|
|
67e50c |
print_modaliases() {
|
|
|
67e50c |
declare class=$1 variants=$2 pos=$3
|
|
|
67e50c |
if [ -n "$variants" ]; then
|
|
|
67e50c |
echo "${class:0:pos}[$variants]${class:pos+1}"
|
|
|
67e50c |
else
|
|
|
67e50c |
[ -z "$class" ] || echo "$class"
|
|
|
67e50c |
fi
|
|
|
67e50c |
}
|
|
|
67e50c |
|
|
|
67e50c |
combine_modaliases() {
|
|
|
936cd0 |
declare tag class variants="" pos="" n
|
|
|
67e50c |
read class
|
|
|
67e50c |
while read tag; do
|
|
|
67e50c |
for ((n=0; n<${#class}; n++)); do
|
|
|
67e50c |
if [ "*" != "${class:n:1}" -a \
|
|
|
67e50c |
"${class:0:n}" = "${tag:0:n}" -a \
|
|
|
67e50c |
"${class:n+1}" = "${tag:n+1}" ] &&
|
|
|
67e50c |
( [ -z "$pos" ] || [ $n = $pos ] ); then
|
|
|
67e50c |
variants="${variants:-${class:n:1}}${tag:n:1}"
|
|
|
67e50c |
pos=$n
|
|
|
67e50c |
break
|
|
|
67e50c |
fi
|
|
|
67e50c |
done
|
|
|
67e50c |
if [ $n -eq ${#class} ]; then
|
|
|
67e50c |
print_modaliases "$class" "$variants" "$pos"
|
|
|
67e50c |
variants=
|
|
|
67e50c |
pos=
|
|
|
67e50c |
class=$tag
|
|
|
67e50c |
fi
|
|
|
67e50c |
done
|
|
|
67e50c |
print_modaliases "$class" "$variants" "$pos"
|
|
|
67e50c |
}
|
|
|
67e50c |
|
|
|
936cd0 |
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
|
|
|
67e50c |
# | head -n1 because some modules have *two* version tags. *cough*b44*cough*
|
|
|
67e50c |
modver=$(/sbin/modinfo -F version "$module"| head -n1)
|
|
|
936cd0 |
modver=${modver//[^0-9a-zA-Z._]/_}
|
|
|
67e50c |
# only add version tag if it has a version
|
|
|
936cd0 |
[ -z "$modver" ] || modver=" = $modver"
|
|
|
936cd0 |
|
|
|
936cd0 |
/sbin/modinfo -F alias "$module" \
|
|
|
936cd0 |
| sed -nre "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver,p"
|
|
|
67e50c |
done \
|
|
|
67e50c |
| sort -u \
|
|
|
67e50c |
| combine_modaliases
|