diff --git a/kernelstub/application.py b/kernelstub/application.py index 8e2ee43..f9c6e4b 100755 --- a/kernelstub/application.py +++ b/kernelstub/application.py @@ -335,12 +335,14 @@ def main(self, args): # Do the thing installer.setup_unified_kernel( kopts, old=False, + overwrite=force, simulate=no_run ) try: installer.setup_unified_kernel( kopts, old=True, + overwrite=force, simulate=no_run) except Exception as e: log.debug('Couldn\'t back up old kernel. \nThis might just mean ' + diff --git a/kernelstub/installer.py b/kernelstub/installer.py index bf635c6..b62a635 100644 --- a/kernelstub/installer.py +++ b/kernelstub/installer.py @@ -58,7 +58,7 @@ def __init__(self, nvram, opsys, drive): if not os.path.exists(self.entry_dir): os.makedirs(self.entry_dir) - def setup_unified_kernel(self, kernel_opts, old=False, simulate=False): + def setup_unified_kernel(self, kernel_opts, old=False, overwrite=False, simulate=False): if old: suffix = 'previous' kernel_path = self.opsys.old_kernel_path @@ -124,6 +124,18 @@ def setup_unified_kernel(self, kernel_opts, old=False, simulate=False): simulate=simulate ) + if not overwrite and not simulate: + if not os.path.exists('%s/loader.conf' % self.loader_dir): + overwrite = True + + if overwrite and not old and not simulate: + self.ensure_dir(self.loader_dir) + with open( + '%s/loader.conf' % self.loader_dir, mode='w') as loader: + + default_line = 'default %s\n' % kernel_efi_name + loader.write(default_line) + def backup_old(self, kernel_opts, setup_loader=False, simulate=False): self.log.info('Backing up old kernel')