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