|
|
67e50c |
#! /bin/sh
|
|
|
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 |
#
|
|
|
67e50c |
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 |
|
|
|
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() {
|
|
|
67e50c |
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 |
|
|
|
67e50c |
for module in $(grep -E '/lib/modules/.+\.ko$') $*; do
|
|
|
67e50c |
# | head -n1 because some modules have *two* version tags. *cough*b44*cough*
|
|
|
67e50c |
modver=$(/sbin/modinfo -F version "$module"| head -n1)
|
|
|
67e50c |
modver=${modver// /_}
|
|
|
67e50c |
|
|
|
67e50c |
# only add version tag if it has a version
|
|
|
67e50c |
if [ -n "$modver" ]; then
|
|
|
67e50c |
/sbin/modinfo -F alias "$module" \
|
|
|
67e50c |
| sed -nre "s,(.+),modalias(\\1) = $modver,p"
|
|
|
67e50c |
else
|
|
|
67e50c |
/sbin/modinfo -F alias "$module" \
|
|
|
67e50c |
| sed -nre "s,(.+),modalias(\\1),p"
|
|
|
67e50c |
fi
|
|
|
67e50c |
done \
|
|
|
67e50c |
| sort -u \
|
|
|
67e50c |
| combine_modaliases
|