Bug#410464: update-grub: a.b.c-rcN is sorted before a.b.c final version

Thue Janus Kristensen thuejk at gmail.com
Sat Feb 10 21:39:24 CET 2007


Package: grub
Version: 0.97-22
Severity: normal


When running update-grub with the kernels 2.6.20 and 2.6.20-rc7,
2.6.20-rc7 is currently sorted above 2.6.20. It is obvious that 2.6.20
should be sorted above 2.6.20-rc7, as 2.6.20 is newer.

Actually update-grub does have code to do this, but it is buggy. The
fundamental bug does not seem to be in update-grup, but a simple
work-around in update-grub can fix it.

The problem is in CompareVersions(), around line 466:

1        #First a space is put after the version number
2        v1=$(echo $1 | sed -e 's!^\(.*-\([0-9]\+\.\)\{2,3\}[0-9]\+\)\(.*\)!\1 \3!g')
3        v2=$(echo $2 | sed -e 's!^\(.*-\([0-9]\+\.\)\{2,3\}[0-9]\+\)\(.*\)!\1 \3!g')
4        #If the version number only has 3 digits then put in another .0
5        v1=$(echo $v1 | sed -e 's!^\(.*-\([0-9]\+\.\)\{2\}[0-9]\+\)\( .*\)\?!\1.0 \3!g')
6        v2=$(echo $v2 | sed -e 's!^\(.*-\([0-9]\+\.\)\{2\}[0-9]\+\)\( .*\)\?!\1.0 \3!g')

However, the space added in line 2/3 seems to be stripped in line 5/6
by echo, if the space is the last character. Adding quotes to line 5/6
such as this:

5        v1=$(echo "$v1" | sed -e 's!^\(.*-\([0-9]\+\.\)\{2\}[0-9]\+\)\( .*\)\?!\1.0 \3!g')
6        v2=$(echo "$v2" | sed -e 's!^\(.*-\([0-9]\+\.\)\{2\}[0-9]\+\)\( .*\)\?!\1.0 \3!g')

Makes the script work, with 2.6.20 sorted before 2.6.20-rc7.

Regards, Thue

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.20
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages grub depends on:
ii  libc6                       2.3.6.ds1-11 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