cleaned up boot entries in relchk, added todo for bootsync

This commit is contained in:
brent s. 2021-01-20 23:55:11 -05:00
parent 06b32e7154
commit 6c0f0fb195
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
1 changed files with 47 additions and 0 deletions

47
TODO Normal file
View File

@ -0,0 +1,47 @@
Incorporate prep.txt with config file?
should look something like this:

#!/usr/bin/env python

import os
import re
import shutil
import subprocess

esp = {'/dev/vdb': ('Arch (Fallback)', '/mnt/boot2'),
'/dev/vda': ('Arch', '/mnt/boot1')}
part = 1

for dev, (label, mnt) in esp.items():
grubdir = os.path.join(mnt, 'grub')
if os.path.isdir(grubdir):
shutil.rmtree(grubdir)
efi = subprocess.run(['efibootmgr'], stdout = subprocess.PIPE)
efi_lines = efi.stdout.decode('utf-8').strip().splitlines()
efi_entries = {}
for l in efi_lines:
i = l.split(None, 1)
k = i[1].strip()
v = re.sub(r'^Boot(?P<boot_id>[A-Fa-f0-9]+).*$', r'\g<boot_id>', i[0])
efi_entries[k] = v
boot_id = efi_entries.get(label)
if not boot_id:
print('Could not find {0}'.format(label))
else:
cmd = subprocess.run(['efibootmgr',
'-b', boot_id,
'-B'],
stdout = subprocess.PIPE)
cmd = subprocess.run(['grub-install',
'--boot-directory={0}'.format(mnt),
'--bootloader-id=Arch',
'--efi-directory={0}'.format(mnt),
'--target=x86_64-efi',
'--no-nvram',
'--recheck'])
cmd = subprocess.run(['efibootmgr',
'--create',
'--disk', dev,
'--part', str(part),
'--loader', '/EFI/Arch/grubx64.efi',
'--label', label])