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
1diff --git a/bin/bootloader_resource.py b/bin/bootloader_resource.py
2index cc1fef3..dd9b995 100755
3--- a/bin/bootloader_resource.py
4+++ b/bin/bootloader_resource.py
5@@ -20,6 +20,7 @@ import re
6 import subprocess as sp
7
8 from checkbox_support.parsers.kernel_cmdline import parse_kernel_cmdline
9+from checkbox_support.snap_utils.system import get_lk_bootimg_path
10
11 # Supported bootloaders and detected files taken from:
12 # https://github.com/snapcore/snapd/blob/master/bootloader/bootloader.go
13@@ -55,23 +56,8 @@ def booted_kernel_location(bl_name):
14 elif bl_name == 'androidboot':
15 pass
16 elif bl_name == 'lk':
17- with open('/proc/cmdline', 'r') as f:
18- cmdline = f.readline()
19- result = parse_kernel_cmdline(cmdline)
20- snap_kernel = result.params['snap_kernel']
21- # get the bootimg matrix using `lk-boot-env -r`
22- try:
23- snap_boot_selection = sp.run(
24- ['lk-boot-env', '-r', os.path.join(*bootloaders['lk'])],
25- check=True, stdout=sp.PIPE).stdout.decode()
26- match = re.search(
27- 'bootimg_matrix\s+\[(.*?)\]\[{}\]'.format(snap_kernel),
28- snap_boot_selection, re.M)
29- if match:
30- path = os.path.join(bootloaders['lk'][0], match.group(1))
31- except FileNotFoundError:
32- path = 'unknown'
33 type = 'raw'
34+ path = get_lk_bootimg_path()
35 return (path, type)
36
37
38@@ -79,6 +65,6 @@ if __name__ == "__main__":
39 bl_name = detect_bootloader()
40 print('name: {}'.format(bl_name))
41 path, type = booted_kernel_location(bl_name)
42- print('booted-kernel-path: {}'.format(path))
43- print('booted-kernel-partition-type: {}'.format(type))
44+ print('booted_kernel_path: {}'.format(path))
45+ print('booted_kernel_partition_type: {}'.format(type))
46 print()

Subscribers

People subscribed via source and target branches