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 <[email protected]>

LGTM.
Acked-by: Amos Kong <[email protected]>

> ---
>  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
> @@ -1401,13 +1401,16 @@ 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,
>                               stdout=subprocess.PIPE,
>                               stderr=subprocess.PIPE)
> -        out, err = p.communicate(grub_instructions_text)
> +        _, err = p.communicate(grub_instructions_text)
>  
>          if err is not None:
>              harmless = ['Probing devices to guess BIOS drives. '
> @@ -1418,7 +1421,7 @@ class Grubby(object):
>              if err_harmful:
>                  self.log.error("Error while running grub to set boot once: 
> %s",
>                                 "\n".join(err_harmful))
> -                return False
> +                return -1
>  
>          self.log.debug('No error detected while running grub to set boot 
> once')
>          return 0


-- 
                        Amos.
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to