blob: 9379eed5101203b974f4d657e221d29011f04876 [file] [log] [blame]
Amin Hassanic7febef2021-05-04 11:26:22 -07001# Copyright 2021 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""A script to generate MiniOS kernel images.
6
7And inserting them into the Chromium OS images.
8"""
9
10import tempfile
11
12from chromite.lib import commandline
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070013from chromite.lib import constants
Amin Hassanic7febef2021-05-04 11:26:22 -070014from chromite.lib import minios
15
16
17def GetParser():
18 """Creates an argument parser and returns it."""
19 parser = commandline.ArgumentParser(description=__doc__)
20 parser.add_argument('--board', '-b', '--build-target', required=True,
21 help='The board name.')
22 parser.add_argument('--image', type='path',
23 help='The path to the chromium os image.')
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070024 parser.add_argument('--keys-dir', type='path',
25 help='The path to keyset.',
26 default=constants.VBOOT_DEVKEYS_DIR)
27 parser.add_argument('--public-key', type='path',
28 help='Filename to the public key whose private part '\
29 'signed the keyblock.',
30 default=constants.RECOVERY_PUBLIC_KEY )
31 parser.add_argument('--private-key', type='path',
32 help='Filename to the private key whose public part is '\
33 'baked into the keyblock.',
34 default=constants.RECOVERY_DATA_PRIVATE_KEY )
35 parser.add_argument('--keyblock', type='path',
36 help='Filename to the kernel keyblock.',
37 default=constants.RECOVERY_KEYBLOCK)
Jae Hoon Kim39c62d82021-06-16 17:25:19 -070038 parser.add_argument('--serial', type=str,
39 help='Serial port for the kernel console (e.g. printks)')
Amin Hassanic7febef2021-05-04 11:26:22 -070040 return parser
41
42
43def main(argv):
44 parser = GetParser()
45 opts = parser.parse_args(argv)
46 opts.Freeze()
47
48 with tempfile.TemporaryDirectory() as work_dir:
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070049 kernel = minios.CreateMiniOsKernelImage(opts.board, work_dir,
50 opts.keys_dir, opts.public_key,
Jae Hoon Kim39c62d82021-06-16 17:25:19 -070051 opts.private_key, opts.keyblock,
52 opts.serial)
Amin Hassanic7febef2021-05-04 11:26:22 -070053 minios.InsertMiniOsKernelImage(opts.image, kernel)