Bug#494158: [grub2] update-grub: uses wrong ordering algorithm (sorts 1.2.3-foo before 1.2.3.1-foo)

Felix Zielcke fzielcke at z-51.de
Fri Aug 8 11:06:20 UTC 2008


I just stick now to the `cloned to grub2' bug, so Robert doestn't hit
me ;)

Am Freitag, den 08.08.2008, 11:01 +0200 schrieb Felix Zielcke:
> 
> And I concentrate more on grub2 because that's the one we replace
> grub-legacy hopefully soon.
> 
@Henrique: As you can see below grub2's update-grub is a bit different,
Upstream's one only has test_gt() as comparison function and Robert
modified it so it uses CompareVersions()
Even Robert's ported `grub-legacy's update-grub version comparison
thingy' checks only for greater (return value 1 of CompareVersions)



CompareVersions()
{
        local a=`echo $1 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\)/~\1/g"`
        local b=`echo $2 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\)/~\1/g"`

        `dpkg --compare-versions "$a" gt "$b"`
        echo $?
}

test_gt ()
{
  local a=`echo $1 | sed -e "s/vmlinu[zx]-//g"`
  local b=`echo $2 | sed -e "s/vmlinu[zx]-//g"`
  return `CompareVersions "$a" "$b"`
}

This produces me this:

Found linux image: /boot/vmlinuz-2.6.26-1-amd64-mm1
Found linux image: /boot/vmlinuz-2.6.26-1-amd64
Found initrd image: /boot/initrd.img-2.6.26-1-amd64
Found linux image: /boot/vmlinuz-2.6.26-1-amd64-test1
Found linux image: /boot/vmlinuz-2.6.26-1-amd64-rc1
Found linux image: /boot/vmlinuz-2.6.26-1-amd64-rc1-git1
Found linux image: /boot/vmlinuz-2.6.26-1-amd64-pre1
Found linux image: /boot/vmlinuz-2.6.26-1-amd64-git1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-mm1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-test1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-rc1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-rc1-git1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-pre1
Found linux image: /boot/vmlinuz-2.6.25-1-amd64-git1


By the way: I know why again where these -pre comes from, it's the one
kernel.org used before they started with -git and -rcN-git
For lenny we should stick with the ordering of etch or so.
But for lenny+1 we should get rid of this old stuff in at least grub2

Today you get only official patches for -git -rcN -rcN-git and -mmN
and the -mm aren't handled ;)

I don't know where these others come from grub-legacy handles like -test and -ac

I couldn't figure out with playing with this ~ thingy how to tell dpkg that -rc1-git1 is higher then -rc1

So it seems like dpkg --compare-versions isn't that perfect for official kernel.org patch numbering ;)







More information about the Pkg-grub-devel mailing list