[PATCH] hardware autodetect -- find provides & supplements
Michael E Brown
Michael_E_Brown at dell.com
Tue Feb 27 13:57:44 CST 2007
The attached patch is a further refinement on the previously submitted dkms patch for hardware autodetection.
The basic idea is that we have /usr/sbin/dkms_find_provides which we pass to override the system find_provides. We pass this script command line arguments representing all of the *.ko modules that will be packaged. It runs the system find_provides scripts as well as its own custom script which runs over the *.ko files passed on the cmdline.
This patch also implements "supplements" tags for SUSE. It will only be active on SUSE, and it adds "Supplements" tags in the same format as the SUSE standard supplements tags.
-------------- next part --------------
#!/bin/bash
# This script reads filenames from STDIN and outputs any relevant provides
# information that needs to be included in the package.
do_what=provides
if [ "$1" = "provides" ]; then
shift
elif [ "$1" = "supplements" ]; then
do_what=supplements
shift
fi
filelist=`sed "s/['\"]/\\\&/g"`
# -- run builtin provides script
system_find_provides=$(rpm --eval %{__find_$do_what})
[ -x $system_find_provides ] &&
echo $filelist | tr '[:blank:]' \\n | grep '\.pm$' | $system_find_provides $* | sort -u
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"
}
IFS=$'\n'
for module in $(grep -E '/lib/modules/.+\.ko$') $*; do
# | head -n1 because some modules have *two* version tags. *cough*b44*cough*
modver=$(/sbin/modinfo -F version "$module"| head -n1)
modver=${modver// /_}
# only add version tag if it has a version
if [ -n "$modver" ]; then
/sbin/modinfo -F alias "$module" \
| grep ":" \
| sed -nre "s,(.+),modalias(\\1) = $modver,p"
else
/sbin/modinfo -F alias "$module" \
| grep ":" \
| sed -nre "s,(.+),modalias(\\1),p"
fi
done \
| sort -u \
| combine_modaliases
-------------- next part --------------
--- /usr/sbin/dkms 2006-06-29 11:12:46.000000000 -0500
+++ ./dkms 2007-02-27 13:45:58.000000000 -0600
@@ -2384,10 +2384,24 @@
fi
echo $"Marking ${kernelver_array[$i]} (${arch_array[$i]}) for RPM..."
mktarball_line="-k ${kernelver_array[$i]} -a ${arch_array[$i]} $mktarball_line"
+
+ # save off module names to generate RPM Provides later
+ set_module_suffix "${kernelver_array[$i]}"
+ local base_dir="$dkms_tree/$module/$module_version/${kernelver_array[0]}/${arch_array[0]}"
+ local kernel_module_name=$base_dir/module/${dest_module_name[$count]}$module_suffix
+ kernel_modules="$kernel_module_name $kernel_modules"
+
i=$(($i + 1))
done
fi
- RPMS=`invoke_command "rpmbuild --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_versions ${kernelver_array[*]}\" --define \"mktarball_line $mktarball_line\" -ba $SPECFILE 2>&1|grep ^Wrote" "rpmbuild"`
+
+ # test to see if we use our find-provides.modalias or use system one:
+ local override_find_provides=
+ local our_find_provides=$(cd $(dirname $0);pwd)/dkms_find_provides
+ override_find_provides="--define \"_use_internal_dependency_generator 0\" --define \"__find_provides $our_find_provides provides $kernel_modules\""
+ override_find_provides="$override_find_provides --define \"__find_supplements $our_find_provides supplements $kernel_modules\""
+
+ RPMS=`invoke_command "rpmbuild --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_versions ${kernelver_array[*]}\" --define \"mktarball_line $mktarball_line\" $override_find_provides -ba $SPECFILE 2>&1|grep ^Wrote" "rpmbuild"`
if [ "$?" -eq 0 ]; then
echo $""
echo $"$RPMS"
More information about the DKMS-devel
mailing list