bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MERGE] Re: Wrong sorting of suffixed kernels when adding EXTRAVERSION


From: Georgi Georgiev
Subject: [MERGE] Re: Wrong sorting of suffixed kernels when adding EXTRAVERSION
Date: Fri, 16 Mar 2012 00:34:20 +0900
User-agent: Mutt/1.5.21 (2010-09-15)

I see this patch made it in with a small typo, which got exposed now
that kernel 3.2.10 and 3.2.11 are out (grub-mkconfig used the regular
numbered sorting instead of the intended versioned sorting).

Attacing the trivial patch to fix it.

It is easy to verify, since 3.2.10 and 3.2.11 now get sorted as older
than 3.2.9.

Quoting Georgi Georgiev at 29/10/2011-12:08:19(+0900):
> Running this on a Gentoo system with kernel images generated by Gentoo's
> genkernel.
> 
> My kernel has CONFIG_LOCALVERSION="-kvm1" and I end up with the following 
> files
> in /boot (just the relevant section):
> 
> kernel-genkernel-x86_64-2.6.37.1-kvm1
> kernel-genkernel-x86_64-2.6.38.2-kvm1
> kernel-genkernel-x86_64-2.6.38.5-kvm1
> kernel-genkernel-x86_64-2.6.39.1-kvm1
> kernel-genkernel-x86_64-2.6.39.3-kvm1
> kernel-genkernel-x86_64-2.6.39-kvm1
> 
> grub-mkconfig generates the config in this order, with 2.6.39 being on top,
> while it should be lower.
> 
> grep Loading.*2.6. grub.conf | uniq -c
>       2         echo    'Loading Linux x86_64-2.6.39-kvm1 ...'
>       2         echo    'Loading Linux x86_64-2.6.39.3-kvm1 ...'
>       2         echo    'Loading Linux x86_64-2.6.39.1-kvm1 ...'
>       2         echo    'Loading Linux x86_64-2.6.38.5-kvm1 ...'
>       2         echo    'Loading Linux x86_64-2.6.38.2-kvm1 ...'
>       2         echo    'Loading Linux x86_64-2.6.37.1-kvm1 ...'
> 
> I have been using the attached patch for a while now and it solves the
> problem just fine. Simply using "sort -V" does the right thing. If the
> "-V" option is not available - revert to the old behavior.
> 
> This hasn't happened with the 3.x kernels as they don't have EXTRAVERSION but
> you never know when that would start.
> 
> -- 
> (    Georgi Georgiev   (  QOTD: "You want me to put *holes* in my    (
>  ) -------------------  ) ears and hang things from them? How...      )
> (  ------------------- (  tribal."                                   (

> >From 60bcbf59525d311ae1840db15d0fb10f7f1b9ad4 Mon Sep 17 00:00:00 2001
> From: Georgi Georgiev <address@hidden>
> Date: Fri, 18 Feb 2011 22:58:38 +0900
> Subject: [PATCH 1/1] Use proper version sorting if "sort" supports it
> 
> This way 2.6.37-sfx1 will be sorted as older than 2.6.37.1-sfx1.
> Currently it shows as newer.
> ---
>  util/grub-mkconfig_lib.in |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
> index 901b575..605299c 100644
> --- a/util/grub-mkconfig_lib.in
> +++ b/util/grub-mkconfig_lib.in
> @@ -165,6 +165,22 @@ grub_file_is_not_garbage ()
>    return 0
>  }
>  
> +sort_version()
> +{
> +  if [[ ${_sort_has_v:-undef} == "undef" ]]; then
> +    if sort -V < /dev/null &>/dev/null; then
> +      _sort_has_v=1
> +    else
> +      _sort_has_v=0
> +    fi
> +  fi
> +  if [[ ${_sort_has_v} == 1 ]]; then
> +    sort -V
> +  else
> +    sort -n
> +  fi
> +}
> +
>  version_test_numeric ()
>  {
>    local a="$1"
> @@ -181,7 +197,7 @@ version_test_numeric ()
>      a="$b"
>      b="$c"
>    fi
> -  if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
> +  if (echo "$a" ; echo "$b") | sort_version | head -n 1 | grep -qx "$b" ; 
> then
>      return 0
>    else
>      return 1
> -- 
> 1.7.3.4
> 


-- 
(*   Georgi Georgiev   (* "I've seen it. It's rubbish." -- Marvin    (*
*)    address@hidden    *) the Paranoid Android                       *)
(*  +81(90)2877-8845   (*                                            (*

Attachment: Properly-detect-versioned-sort.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]