Bug#493389: update-grub: uses wrong ordering algorithm (sorts 1.2.3-foo before 1.2.3.1-foo)

Robert Millan rmh at aybabtu.com
Thu Aug 7 18:51:10 UTC 2008


On Thu, Aug 07, 2008 at 01:10:24PM -0300, Henrique de Moraes Holschuh wrote:
> On Thu, 07 Aug 2008, Felix Zielcke wrote:
> > Just replace the CompareVersion function with this:
> > 
> > CompareVersions()
> > {
> >         dpkg --compare-versions "$1" le "$2"
> >         echo $?
> > }
> 
> That's the minimal fix, yes.
> 
> But if you do it that way, you will lose the special casing of "pre", "ac",
> "rc" and etc.

Hi Henrique,

I think I got it right now, but since we failed an attempt already, and the
code around this is so tricky, I'd appreciate if you could test this first:

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"`
        if [ "$a" = "$b" ] ; then
                echo 0
        elif dpkg --compare-versions "$a" lt "$b" ; then
                echo 1
        else
                echo -1
        fi
}

(former code didn't adjust well to the api of this function, so it needed a
bit of adjustment)

thanks!

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."





More information about the Pkg-grub-devel mailing list