#! /bin/bash
#############################################################################
# Copyright (c) 2006 Novell, Inc.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#############################################################################
#
# Invoke with a complete set of kernel RPMs as arguments, e.g.,
# update-supported.conf /work/CDs/all/full-sles10-*/suse/*/kernel-*.rpm
#
export LC_ALL=C
if [ "$1" = -v ]; then
shift
exec 3>&2
else
exec 3>/dev/null
fi
unset ${!mod_*}
for rpm in $(printf "%s\n" "$@" | sort); do
for module in $(rpm -qlp "$rpm" \
| sed -n -e 's:^/lib/modules/[^/]*/::' \
-e 's:\.ko$::p'); do
m=${module##*/}
m=${m//-/_}
eval "mod_$m=\"$module\""
done
done
#for module in ${!mod_*}; do
# echo ${!module}
#done \
#| sort >&3
tmpfile=$(mktemp -t "${0##*/}.XXXXXX")
trap "rm -f $tmpfile" EXIT
IFS=
while read line; do
module=$(echo "$line" \
| sed -e 's:^#.*\|[ \t]#.*::' \
-e 's:^\([ \t]*[-+][^ \t]*\)*[ \t]*::' \
-e 's:[ \t]*$::')
if [ -z "$module" ]; then
echo "$line"
continue
fi
m=${module##*/}
m=${m%.ko}
m=mod_${m//-/_}
if [ "${!m}" = "$module" ]; then
echo "| $module" >&3
echo "$line"
elif [ -n "${!m}" ]; then
echo "|R $module ${!m}" >&3
a=${module//\//\\/}
b=${!m}
echo "${line//$a/$b}"
else
echo "|- $module" >&3
fi
done < supported.conf \
| sort -t $'\t' -k 2