Merge pull request #542 from dylanmtaylor/bootloader-directory-creation

Add some safeguards to create directories before writing files
This commit is contained in:
Anton Hvornum 2021-06-03 13:52:29 +02:00 committed by GitHub
commit 7b4564c0fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -2,8 +2,8 @@ from .disk import *
from .hardware import *
from .locale_helpers import verify_keyboard_layout, verify_x11_keyboard_layout
from .mirrors import *
from .storage import storage
from .plugins import plugins
from .storage import storage
from .user_interaction import *
# Any package that the Installer() is responsible for (optional and the default ones)
@ -54,7 +54,6 @@ class Installer:
for kernel in kernels:
self.base_packages.append(kernel)
self.post_base_install = []
storage['session'] = self
@ -442,6 +441,10 @@ class Installer:
# Fallback, try creating the boot loader without touching the EFI variables
SysCommand(f'/usr/bin/arch-chroot {self.target} bootctl --no-variables --path=/boot install')
# Ensure that the /boot/loader directory exists before we try to create files in it
if not os.path.exists(f'{self.target}/boot/loader'):
os.makedirs(f'{self.target}/boot/loader')
# Modify or create a loader.conf
if os.path.isfile(f'{self.target}/boot/loader/loader.conf'):
with open(f'{self.target}/boot/loader/loader.conf', 'r') as loader:
@ -462,6 +465,10 @@ class Installer:
else:
loader.write(f"{line}\n")
# Ensure that the /boot/loader/entries directory exists before we try to create files in it
if not os.path.exists(f'{self.target}/boot/loader/entries'):
os.makedirs(f'{self.target}/boot/loader/entries')
for kernel in self.kernels:
# Setup the loader entry
with open(f'{self.target}/boot/loader/entries/{self.init_time}_{kernel}.conf', 'w') as entry: