The command 'grubonce' is a custom method to boot a bootloader entry once, found in OpenSUSE 12.1. Let's try to use it if found, then fall back to the more standard (and sane) method.
This fixes an issue booting new kernels on OpenSUSE 12.1. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/tools/boottool | 78 ++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/client/tools/boottool b/client/tools/boottool index 5789869..a68e414 100755 --- a/client/tools/boottool +++ b/client/tools/boottool @@ -1397,41 +1397,53 @@ class Grubby(object): ''' Implements the boot once feature for the grub bootloader ''' - # XXX: check the type of default set (numeric or "saved") - grub_instructions = ['savedefault --default=%s --once' % entry_index, - 'quit'] - grub_instructions_text = '\n'.join(grub_instructions) - 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) - - complete_out = '' - if out is not None: - complete_out = out - if err is not None: - complete_out += err - - if complete_out: - harmless = [grub_instructions, - 'Probing devices to guess BIOS drives. ' - 'This may take a long time.'] - err_lines = complete_out.splitlines() - err_harmful = [l for l in err_lines if l and l not in harmless] - - if err_harmful: - self.log.error("Error while running grub to set boot once: %s", - "\n".join(err_harmful)) + # grubonce is a hack present in distros like OpenSUSE + grubonce_cmd = find_executable('grubonce') + if grubonce_cmd is None: + # XXX: check the type of default set (numeric or "saved") + grub_instructions = ['savedefault --default=%s --once' % + entry_index, 'quit'] + grub_instructions_text = '\n'.join(grub_instructions) + grub_binary = find_executable('grub') + if grub_binary is None: + self.log.error("Could not find the 'grub' binary, aborting") return -1 - self.log.debug('No error detected while running grub to set boot once') - return 0 + p = subprocess.Popen([grub_binary, '--batch'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = p.communicate(grub_instructions_text) + + complete_out = '' + if out is not None: + complete_out = out + if err is not None: + complete_out += err + + if complete_out: + harmless = [grub_instructions, + 'Probing devices to guess BIOS drives. ' + 'This may take a long time.'] + err_lines = complete_out.splitlines() + err_harmful = [l for l in err_lines if l and l not in harmless] + + if err_harmful: + self.log.error("Error while running grub to set boot " + "once: %s", "\n".join(err_harmful)) + return -1 + + self.log.debug('No error detected while running grub to set boot ' + 'once') + return 0 + else: + rc = self._run_get_return([grubonce_cmd, entry_index]) + if rc: + self.log.error('Error running %s', grubonce_cmd) + else: + self.log.debug('No error detected while running %s', + grubonce_cmd) + return rc def boot_once_grub2(self, entry_index): -- 1.7.10.2 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
