Skip to content

Commit

Permalink
Support writing loader.conf when using unified kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Aug 28, 2022
1 parent 57bee01 commit ee54d36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kernelstub/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' +
Expand Down
14 changes: 13 additions & 1 deletion kernelstub/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit ee54d36

Please sign in to comment.