Merge ~jocave/plainbox-provider-resource:bootloader-error-handling into plainbox-provider-resource:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 8b8e139fb1ca11604852d85a62faf23fc322b7af
Merged at revision: cb370b9745da62272bb03cd90d775eb8b3f4933c
Proposed branch: ~jocave/plainbox-provider-resource:bootloader-error-handling
Merge into: plainbox-provider-resource:master
Diff against target: 29 lines (+17/-1)
1 file modified
bin/bootloader_resource.py (+17/-1)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+378327@code.launchpad.net

Description of the change

Improve bootloader_resource.py when running on classic systems and when the BOOT_IMAGE variable does not contain a bracketed variable.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

(11:27:53 AM) spineau: joc: how can I test it, just classic?
(11:31:55 AM) spineau: joc: '(hd1,gpt1)' looks a bit restrictive. could we wee a system with for example hd0, gpt2 ?
(11:32:03 AM) spineau: wee/see
(11:32:18 AM) joc: i have no idea
(11:32:27 AM) joc: this is a question for the delivery team i think
(11:35:47 AM) spineau: joc: I'm ok to land and revisit the rule when a new project will come and fail with an 'unknown' grub_path. If it solves fortknox that's already an improvement

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/bootloader_resource.py b/bin/bootloader_resource.py
2index dd9b995..5088218 100755
3--- a/bin/bootloader_resource.py
4+++ b/bin/bootloader_resource.py
5@@ -52,7 +52,23 @@ def booted_kernel_location(bl_name):
6 cmdline = f.readline()
7 result = parse_kernel_cmdline(cmdline)
8 grub_path = result.params['BOOT_IMAGE']
9- path = os.path.join('/boot/efi', grub_path[grub_path.index(')')+2:])
10+
11+ # The BOOT_IMAGE parameter is tricky to decipher. It can be absolute
12+ # path or refer or contain a variable expanded by ... initramfs?
13+ if os.path.isabs(grub_path):
14+ path = grub_path
15+ else:
16+ try:
17+ # if we know where the parameter is referencing, replace it
18+ if '(loop)' in grub_path:
19+ # implies of out of the kernel snap (so no FDE)
20+ pass
21+ elif '(hd1,gpt1)' in grub_path:
22+ # used by fortknox
23+ path = os.path.join(
24+ '/boot/efi', grub_path[grub_path.index(')')+2:])
25+ except ValueError:
26+ pass
27 elif bl_name == 'androidboot':
28 pass
29 elif bl_name == 'lk':

Subscribers

People subscribed via source and target branches