home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
rescue
/
usr
/
lib
/
rpm
/
find-supplements.ksyms
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
90 lines
#! /bin/sh
RPM_SOURCE_DIR=/usr/src/packages/SOURCES
IFS=$'\n'
case "$1" in
kernel-module-*) ;; # Fedora kernel module package names start with
# kernel-module.
kernel*) is_kernel_package=1 ;;
esac
if ! [ -z "$is_kernel_package" ]; then
cat > /dev/null
exit 0
fi
print_modaliases() {
declare class=$1 variants=$2 pos=$3
if [ -n "$variants" ]; then
echo "${class:0:pos}[$variants]${class:pos+1}"
else
[ -z "$class" ] || echo "$class"
fi
}
combine_modaliases() {
declare tag class variants pos n
read class
while read tag; do
for ((n=0; n<${#class}; n++)); do
if [ "*" != "${class:n:1}" -a \
"${class:0:n}" = "${tag:0:n}" -a \
"${class:n+1}" = "${tag:n+1}" ] &&
( [ -z "$pos" ] || [ $n = $pos ] ); then
variants="${variants:-${class:n:1}}${tag:n:1}"
pos=$n
break
fi
done
if [ $n -eq ${#class} ]; then
print_modaliases "$class" "$variants" "$pos"
variants=
pos=
class=$tag
fi
done
print_modaliases "$class" "$variants" "$pos"
}
aliases_of_filelist() {
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_specfile_macro() {
declare regex
regex=$(
set -o noglob
set -- $(sed -ne 's:^%supplements_kernel_module[ \t]::p' \
$RPM_SOURCE_DIR/$1.spec)
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