Lucas Meneghel Rodrigues | 26 Jun 2012 03:31
Picon
Favicon
Gravatar

[PATCH] boottool: Search for installed grub in the system

Current boottool assumes a hardcoded path for grub,
/sbin/grub. Distros such as OpenSUSE install it on
/usr/sbin/grub, so this will cause a grub setup to
flat out fail on those distros.

So let's leverage find_executable, that is already
present, to take care of actually finding the
appropriate grub path.

Signed-off-by: Lucas Meneghel Rodrigues <lmr <at> redhat.com>
---
 client/tools/boottool |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/client/tools/boottool b/client/tools/boottool
index 794377b..53f7d94 100755
--- a/client/tools/boottool
+++ b/client/tools/boottool
 <at>  <at>  -1401,13 +1401,16  <at>  <at>  class Grubby(object):
         grub_instructions = ['savedefault --default=%s --once' % entry_index,
                              'quit']
         grub_instructions_text = '\n'.join(grub_instructions)
-        grub_binary = '/sbin/grub'
+        grub_binary = find_executable('grub')
+        if grub_binary is None:
+            self.log.error("Could not find the 'grub' binary, aborting")
+            return -1

         p = subprocess.Popen([grub_binary, '--batch'],
                              stdin=subprocess.PIPE,
(Continue reading)

Amos Kong | 26 Jun 2012 03:36
Picon
Favicon
Gravatar

Re: [PATCH] boottool: Search for installed grub in the system

On 06/26/2012 09:31 AM, Lucas Meneghel Rodrigues wrote:
> Current boottool assumes a hardcoded path for grub,
> /sbin/grub. Distros such as OpenSUSE install it on
> /usr/sbin/grub, so this will cause a grub setup to
> flat out fail on those distros.
> 
> So let's leverage find_executable, that is already
> present, to take care of actually finding the
> appropriate grub path.
> 
> Signed-off-by: Lucas Meneghel Rodrigues <lmr <at> redhat.com>

LGTM.
Acked-by: Amos Kong <akong <at> redhat.com>

> ---
>  client/tools/boottool |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/client/tools/boottool b/client/tools/boottool
> index 794377b..53f7d94 100755
> --- a/client/tools/boottool
> +++ b/client/tools/boottool
>  <at>  <at>  -1401,13 +1401,16  <at>  <at>  class Grubby(object):
>          grub_instructions = ['savedefault --default=%s --once' % entry_index,
>                               'quit']
>          grub_instructions_text = '\n'.join(grub_instructions)
> -        grub_binary = '/sbin/grub'
> +        grub_binary = find_executable('grub')
> +        if grub_binary is None:
(Continue reading)


Gmane