[PATCH] fix version comparison
Matt Domsch
Matt_Domsch at dell.com
Fri Apr 14 12:04:27 CDT 2006
Two things have bothered me for a while.
1) DKMS was *requiring* that modules have modinfo lines like:
version: 38.0 abcdef0123456
which correspond to both the version and srcversion fields. If the
srcversion field isn't present (as it isn't on RHEL4 < U3), then it
wouldn't bother doing any comparison on the version field. Presumably
this was because the value in the version field couldn't be trusted
completely (which is kind of strange).
2) because of 1), the version check would fail on more recent kernels
that put the srcversion data into its own modinfo line (just as it
did for modules with no MODULE_VERSION() tag defined.
Patch below addresses both concerns. Please review.
Thanks,
Matt
--
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
--- dkms-2.0.11 Mon Apr 3 16:09:50 2006
+++ dkms Fri Apr 14 11:54:13 2006
@@ -514,14 +514,33 @@ function check_version_sanity ()
local kernels_module=`find $lib_tree -name ${dest_module_name[$count]}$module_suffix`
local kernels_ver_string=`modinfo $kernels_module | grep "^version:"`
local kernels_ver_value=`echo $kernels_ver_string | awk {'print $2'}`
- local kernels_ver_checksum=`echo $kernels_ver_string | awk {'print $3'}`
local dkms_module="$dkms_tree/$module/$module_version/$1/$2/module/${dest_module_name[$count]}$module_suffix"
local dkms_ver_string=`modinfo $dkms_module | grep "^version:"`
local dkms_ver_value=`echo $dkms_ver_string | awk {'print $2'}`
- local dkms_ver_checksum=`echo $dkms_ver_string | awk {'print $3'}`
- if [ -n "$kernels_ver_checksum" ] && [ -n "$dkms_ver_checksum" ]; then
+
+ # there are 2 possible srcversion checksums
+ # one in the 'srcversion' tag alone (preferred)
+ # and one following the version field in the 'version' tag (deprecated)
+ local kernels_ver_checksum=`modinfo $kernels_module | awk /^srcversion:/ {print $2}`
+ local dkms_ver_checksum=`modinfo $dkms_module | awk /^srcversion:/ {print $2}`
+ if [ -z "$kernels_ver_checksum" -a -z "$dkms_ver_checksum" ]; then
+ kernels_ver_checksum=`echo $kernels_ver_string | awk {'print $3'}`
+ dkms_ver_checksum=`echo $dkms_ver_string | awk {'print $3'}`
+ fi
+
+ if [ -n "$kernels_ver_checksum" -a -n "$dkms_ver_checksum" -a
+ "$kernels_ver_checksum" == "$dkms_ver_checksum" -a -z "$force" ]; then
+ echo $"" >&2
+ echo $"Good news! Module version $dkms_ver_value for ${dest_module_name[$count]}$module_suffix" >&2
+ echo $"exactly matches what is already found in kernel $1." >&2
+ echo $"DKMS will not replace this module." >&2
+ echo $"You may override by specifying --force." >&2
+ exit 101
+ fi
+
+ if [ -n "$kernels_ver_value" -a -n "$dkms_ver_value" ]; then
if [[ ! ( $(VER $dkms_ver_value) > \
- $(VER $kernels_ver_value) ) && -z "$force" ]]; then
+ $(VER $kernels_ver_value) ) && -z "$force" ]]; then
echo $"" >&2
echo $"Error! Module version $dkms_ver_value for ${dest_module_name[$count]}$module_suffix" >&2
echo $"is not newer than what is already found in kernel $1 ($kernels_ver_value)." >&2
More information about the DKMS-devel
mailing list