Merge ~sylvain-pineau/plainbox-provider-resource:more_lk_fixes into plainbox-provider-resource:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 7c142ebf466b4181e6ff57ecb885b0ef56f5ce62
Merged at revision: 42b09a1c71c8b22de02881f403b914e2ed38db57
Proposed branch: ~sylvain-pineau/plainbox-provider-resource:more_lk_fixes
Merge into: plainbox-provider-resource:master
Diff against target: 46 lines (+4/-18)
1 file modified
bin/bootloader_resource.py (+4/-18)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+374055@code.launchpad.net

Description of the change

improved lk support by importing shared code from checkbox-support

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

self-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/bootloader_resource.py b/bin/bootloader_resource.py
index cc1fef3..dd9b995 100755
--- a/bin/bootloader_resource.py
+++ b/bin/bootloader_resource.py
@@ -20,6 +20,7 @@ import re
20import subprocess as sp20import subprocess as sp
2121
22from checkbox_support.parsers.kernel_cmdline import parse_kernel_cmdline22from checkbox_support.parsers.kernel_cmdline import parse_kernel_cmdline
23from checkbox_support.snap_utils.system import get_lk_bootimg_path
2324
24# Supported bootloaders and detected files taken from:25# Supported bootloaders and detected files taken from:
25# https://github.com/snapcore/snapd/blob/master/bootloader/bootloader.go26# https://github.com/snapcore/snapd/blob/master/bootloader/bootloader.go
@@ -55,23 +56,8 @@ def booted_kernel_location(bl_name):
55 elif bl_name == 'androidboot':56 elif bl_name == 'androidboot':
56 pass57 pass
57 elif bl_name == 'lk':58 elif bl_name == 'lk':
58 with open('/proc/cmdline', 'r') as f:
59 cmdline = f.readline()
60 result = parse_kernel_cmdline(cmdline)
61 snap_kernel = result.params['snap_kernel']
62 # get the bootimg matrix using `lk-boot-env -r`
63 try:
64 snap_boot_selection = sp.run(
65 ['lk-boot-env', '-r', os.path.join(*bootloaders['lk'])],
66 check=True, stdout=sp.PIPE).stdout.decode()
67 match = re.search(
68 'bootimg_matrix\s+\[(.*?)\]\[{}\]'.format(snap_kernel),
69 snap_boot_selection, re.M)
70 if match:
71 path = os.path.join(bootloaders['lk'][0], match.group(1))
72 except FileNotFoundError:
73 path = 'unknown'
74 type = 'raw'59 type = 'raw'
60 path = get_lk_bootimg_path()
75 return (path, type)61 return (path, type)
7662
7763
@@ -79,6 +65,6 @@ if __name__ == "__main__":
79 bl_name = detect_bootloader()65 bl_name = detect_bootloader()
80 print('name: {}'.format(bl_name))66 print('name: {}'.format(bl_name))
81 path, type = booted_kernel_location(bl_name)67 path, type = booted_kernel_location(bl_name)
82 print('booted-kernel-path: {}'.format(path))68 print('booted_kernel_path: {}'.format(path))
83 print('booted-kernel-partition-type: {}'.format(type))69 print('booted_kernel_partition_type: {}'.format(type))
84 print()70 print()

Subscribers

People subscribed via source and target branches