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
1diff --git a/bin/boot_mode_test b/bin/boot_mode_test
2index d4c2956..330bb2b 100755
3--- a/bin/boot_mode_test
4+++ b/bin/boot_mode_test
5@@ -24,6 +24,35 @@ import os
6 import sys
7 import logging
8 from argparse import ArgumentParser
9+from platform import linux_distribution
10+
11+
12+def version_check(check):
13+ """Check the installed Ubuntu version to see if it is older than 16.04
14+ (Xenial) and run the requested check
15+
16+ :returns:
17+ 0 if if the installed version is older than 16.04 regardless of return
18+ code from the requested check
19+
20+ return code from requested check if the installed version is 16.04 or
21+ newer.
22+ """
23+ installed_version = int(linux_distribution()[1].split()[0])
24+ if installed_version < 16:
25+ logging.info("This system appears to be older than 16.04 LTS so this "
26+ "will not block a certification in progress.")
27+ if check == 'efi':
28+ efi_boot_check()
29+ else:
30+ secure_boot_check()
31+
32+ return 0
33+ else:
34+ if check == 'efi':
35+ return efi_boot_check()
36+ else:
37+ return secure_boot_check()
38
39
40 def efi_boot_check():
41@@ -86,11 +115,7 @@ def main():
42
43 FORMAT = '%(levelname)s: %(message)s'
44 logging.basicConfig(level=logging.INFO, format=FORMAT)
45- if args.check == 'efi':
46- return efi_boot_check()
47- else:
48- return secure_boot_check()
49-
50+ return version_check(args.check)
51
52 if __name__ == '__main__':
53 sys.exit(main())

Subscribers

People subscribed via source and target branches