|
1 | 1 | import os
|
| 2 | +import re |
2 | 3 |
|
3 | 4 | from leapp.libraries.stdlib import run, api
|
4 | 5 | from leapp.actors import Actor
|
@@ -38,6 +39,11 @@ def process(self):
|
38 | 39 | 'aarch64': 'shimaa64.efi'
|
39 | 40 | }
|
40 | 41 |
|
| 42 | + def devparts(dev): |
| 43 | + part = next(re.finditer(r'\d+$', dev)).group(0) |
| 44 | + dev = dev[:-len(part)] |
| 45 | + return [dev, part]; |
| 46 | + |
41 | 47 | with open('/etc/system-release', 'r') as sr:
|
42 | 48 | release_line = next(line for line in sr if 'release' in line)
|
43 | 49 | distro = release_line.split(' release ', 1)[0]
|
@@ -69,19 +75,27 @@ def process(self):
|
69 | 75 | break
|
70 | 76 |
|
71 | 77 | if is_system_efi and has_shim:
|
| 78 | + efidevlist = [] |
72 | 79 | with open('/proc/mounts', 'r') as fp:
|
73 | 80 | for line in fp:
|
74 | 81 | if '/boot/efi' in line:
|
75 | 82 | efidevpath = line.split(' ', 1)[0]
|
76 |
| - efidev = efidevpath.split('/')[-1] |
| 83 | + efidevpart = efidevpath.split('/')[-1] |
77 | 84 | if os.path.exists('/proc/mdstat'):
|
78 | 85 | with open('/proc/mdstat', 'r') as mds:
|
79 | 86 | for line in mds:
|
80 |
| - if line.startswith(efidev): |
81 |
| - mddev = line.split(' ')[-1] |
82 |
| - newefidev = mddev.split('[', 1)[0] |
83 |
| - efidevpath = efidevpath.replace(efidev, newefidev) |
84 |
| - run(['/sbin/efibootmgr', '-c', '-d', efidevpath, '-p 1', '-l', bootmgr_path, '-L', efi_bootentry_label]) |
| 87 | + if line.startswith(efidevpart): |
| 88 | + mddev = line.split(' ') |
| 89 | + for md in mddev: |
| 90 | + if '[' in md: |
| 91 | + efimd = md.split('[', 1)[0] |
| 92 | + efidp = efidevpath.replace(efidevpart, efimd) |
| 93 | + efidevlist.append(efidp) |
| 94 | + if len(efidevlist) == 0: |
| 95 | + efidevlist.append(efidevpath) |
| 96 | + for devpath in efidevlist: |
| 97 | + efidev, efipart = devparts(devpath) |
| 98 | + run(['/sbin/efibootmgr', '-c', '-d', efidev, '-p', efipart, '-l', bootmgr_path, '-L', efi_bootentry_label]) |
85 | 99 |
|
86 | 100 | if not has_grub_cfg:
|
87 | 101 | run(['/sbin/grub2-mkconfig', '-o', grub_cfg_path])
|
0 commit comments