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

Henrique de Moraes Holschuh hmh at debian.org
Thu Aug 7 21:42:35 UTC 2008


On Thu, 07 Aug 2008, Robert Millan wrote:
> 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)

I may not be able to test it until after I arrive in Argentina for debconf8,
i.e. on Sunday.

You don't need to care for the API if the users all do just a -gt 0
comparison anyway :)

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh





More information about the Pkg-grub-devel mailing list