Merge ~bladernr/plainbox-provider-checkbox:fix-efi-boot-test into plainbox-provider-checkbox:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Jeff Lane 
Approved revision: 9fcd4cb386de8ed076c11405dc3f8cb8f2b0771e
Merged at revision: 77a9fb259af5bc54c1b1ba18fca98de4f2cede61
Proposed branch: ~bladernr/plainbox-provider-checkbox:fix-efi-boot-test
Merge into: plainbox-provider-checkbox:master
Diff against target: 53 lines (+30/-5)
1 file modified
bin/boot_mode_test (+30/-5)
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+309798@code.launchpad.net

Description of the change

bin/boot_mode_test: test now returns 0 regardless of test run when executed on a release older than 16.04. It also provides an output message letting you know that it's not a blocker on releases older than 16.04.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Once concern regarding version check, and one nitpick inline.
+0.999 (that version stuff :)

review: Approve
Revision history for this message
Jeff Lane  (bladernr) wrote :

Good points on both. I changed the version check behaviour. Was really hoping for something programatic like doing deb package version checks, but AFAIK, none such exists.

So the cleanest thing is to just grab the year from each release, cast that to an int and do a straight forward int compare, since ultimately, we only care that the release is newer than 2016 anyway.

Revision history for this message
Jeff Lane  (bladernr) wrote :

Going ahead and setting this to be merged since Maciej already approved and my changes now are just to address the concern he had. Functionality is still the same.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/boot_mode_test b/bin/boot_mode_test
index d4c2956..330bb2b 100755
--- a/bin/boot_mode_test
+++ b/bin/boot_mode_test
@@ -24,6 +24,35 @@ import os
24import sys24import sys
25import logging25import logging
26from argparse import ArgumentParser26from argparse import ArgumentParser
27from platform import linux_distribution
28
29
30def version_check(check):
31 """Check the installed Ubuntu version to see if it is older than 16.04
32 (Xenial) and run the requested check
33
34 :returns:
35 0 if if the installed version is older than 16.04 regardless of return
36 code from the requested check
37
38 return code from requested check if the installed version is 16.04 or
39 newer.
40 """
41 installed_version = int(linux_distribution()[1].split()[0])
42 if installed_version < 16:
43 logging.info("This system appears to be older than 16.04 LTS so this "
44 "will not block a certification in progress.")
45 if check == 'efi':
46 efi_boot_check()
47 else:
48 secure_boot_check()
49
50 return 0
51 else:
52 if check == 'efi':
53 return efi_boot_check()
54 else:
55 return secure_boot_check()
2756
2857
29def efi_boot_check():58def efi_boot_check():
@@ -86,11 +115,7 @@ def main():
86115
87 FORMAT = '%(levelname)s: %(message)s'116 FORMAT = '%(levelname)s: %(message)s'
88 logging.basicConfig(level=logging.INFO, format=FORMAT)117 logging.basicConfig(level=logging.INFO, format=FORMAT)
89 if args.check == 'efi':118 return version_check(args.check)
90 return efi_boot_check()
91 else:
92 return secure_boot_check()
93
94119
95if __name__ == '__main__':120if __name__ == '__main__':
96 sys.exit(main())121 sys.exit(main())

Subscribers

People subscribed via source and target branches