Skip to content

Commit

Permalink
Enable skipping enrollment
Browse files Browse the repository at this point in the history
This is so testing and enrollment can be separated into distinct parts of
a build process.

Signed-off-by: Patrick Uiterwijk <[email protected]>
  • Loading branch information
puiterwijk committed Apr 3, 2018
1 parent 3ef2627 commit ae0512b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ jobs:
command: |
python3 ./ovmf-vars-generator --verbose --print-output --kernel-path vmlinuz output3.vars
- run:
name: run enrollment-only
command: |
python3 ./ovmf-vars-generator --verbose --print-output --kernel-path vmlinuz outputsplit.vars --skip-testing
- run:
name: run testing-only
command: |
python3 ./ovmf-vars-generator --verbose --print-output --kernel-path vmlinuz outputsplit.vars --skip-enrollment
- store_artifacts:
path: output2.vars

Expand Down
34 changes: 24 additions & 10 deletions ovmf-vars-generator
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def parse_args():
default='/usr/share/edk2/ovmf/OVMF_VARS.fd')
parser.add_argument('--uefi-shell-iso', help='Path to uefi shell iso',
default='/usr/share/edk2/ovmf/UefiShell.iso')
parser.add_argument('--skip-enrollment',
help='Skip enrollment, only test', action='store_true')
parser.add_argument('--skip-testing',
help='Skip testing generated "VARS" file',
action='store_true')
Expand All @@ -203,9 +205,14 @@ def parse_args():


def validate_args(args):
if os.path.exists(args.output) and not args.force:
if (os.path.exists(args.output)
and not args.force
and not args.skip_enrollment):
raise Exception('%s already exists' % args.output)

if args.skip_enrollment and not os.path.exists(args.output):
raise Exception('%s does not yet exist' % args.output)

verbosity = (args.verbose or 1) - (args.quiet or 0)
if verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
Expand All @@ -216,10 +223,13 @@ def validate_args(args):
else:
logging.basicConfig(level=logging.WARN)

temped = tempfile.mkstemp(prefix='qosb.', suffix='.vars')
os.close(temped[0])
args.out_temp = temped[1]
logging.debug('Temp output: %s', args.out_temp)
if args.skip_enrollment:
args.out_temp = args.output
else:
temped = tempfile.mkstemp(prefix='qosb.', suffix='.vars')
os.close(temped[0])
args.out_temp = temped[1]
logging.debug('Temp output: %s', args.out_temp)


def move_to_dest(args):
Expand All @@ -229,14 +239,18 @@ def move_to_dest(args):

def main():
args = parse_args()
enroll_keys(args)
if not args.skip_enrollment:
enroll_keys(args)
if not args.skip_testing:
test_keys(args)
move_to_dest(args)
if args.skip_testing:
logging.info('Created %s' % args.output)
if not args.skip_enrollment:
move_to_dest(args)
if args.skip_testing:
logging.info('Created %s' % args.output)
else:
logging.info('Created and verified %s' % args.output)
else:
logging.info('Created and verified %s' % args.output)
logging.info('Verified %s', args.output)


if __name__ == '__main__':
Expand Down

0 comments on commit ae0512b

Please sign in to comment.