Bug#422759: grub: sorting suffixes w/ mixed numeric and non-numeric
characters
dann frazier
dannf at debian.org
Tue May 8 06:00:04 UTC 2007
Package: grub
Version: 0.97-27
Severity: normal
If a suffix has non-numeric and numeric characters, CompareVersions() will
replace the non-numeric characters with '99' but the numeric characters will
remain appended.
I ran into this issue when comparing 2.6.18-4-amd64 and 2.6.18-4-telco-amd64.
CompareVersions converted these into the following components:
v1: 2 6 18 4 99 9964
v2: 2 6 18 4 9964
It converted 'amd' to 99, while I think the intent was to convert 'amd64' to
99. The patch below fixes this by converting any string that contains a
non-numeric character to '99'. It seems to do what I would expect for the
various test cases I threw at it.
This table compares the sort order produced by both versions of update-grub
executing on the same set of kernel names.
original w/ my patch
----------------------------------------------------------------------
/boot/vmlinuz-2.6.20-1-686 /boot/vmlinuz-2.6.20-1-686
/boot/vmlinuz-2.6.18-4-amd64 /boot/vmlinuz-2.6.18-4-686
/boot/vmlinuz-2.6.18-4-dannf10 /boot/vmlinuz-2.6.18-4-telco-amd64
/boot/vmlinuz-2.6.18-4-dannf2 /boot/vmlinuz-2.6.18-4-dannf10
/boot/vmlinuz-2.6.18-4-686 /boot/vmlinuz-2.6.18-4-dannf2
/boot/vmlinuz-2.6.18-4-telco-amd64 /boot/vmlinuz-2.6.18-4-amd64
/boot/vmlinuz-2.6.18-4-rc10 /boot/vmlinuz-2.6.18-4-rc10
/boot/vmlinuz-2.6.18-4-rc2 /boot/vmlinuz-2.6.18-4-rc2
/boot/vmlinuz-2.4.32 /boot/vmlinuz-2.4.32
--- /usr/sbin/update-grub~ 2007-03-29 23:41:47.000000000 -0600
+++ /usr/sbin/update-grub 2007-05-07 23:31:47.000000000 -0600
@@ -484,9 +484,9 @@ CompareVersions()
# rc = -40
# test = -60
# others are given 99
- v1=$(echo $v1 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc! -40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^-0-9 ]\+!99!g')
+ v1=$(echo $v1 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc! -40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^ ]*[^-0-9 ][^ ]*!99!g')
- v2=$(echo $v2 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc! -40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^-0-9 ]\+!99!g')
+ v2=$(echo $v2 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc! -40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^ ]*[^-0-9 ][^ ]*!99!g')
result=0; v1finished=0; v2finished=0;
while [ $result -eq 0 ] && [ $v1finished -eq 0 ] && [ $v2finished -eq 0 ];
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.20-1-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages grub depends on:
ii libc6 2.5-5 GNU C Library: Shared libraries
ii libncurses5 5.5-5 Shared libraries for terminal hand
grub recommends no packages.
-- no debconf information
More information about the Pkg-grub-devel
mailing list