blob: 6b87842d0d51cde48b81105b0c64964e30d7e0f2 [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.')
Vyshu92153902021-06-16 13:31:53 -040022 parser.add_argument('--version', required=True,
23 help='The chromeos version string.')
Jae Hoon Kim2f8c62a2021-06-22 15:10:43 -070024 parser.add_argument('--image', type='path', required=True,
Amin Hassanic7febef2021-05-04 11:26:22 -070025 help='The path to the chromium os image.')
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070026 parser.add_argument('--keys-dir', type='path',
27 help='The path to keyset.',
28 default=constants.VBOOT_DEVKEYS_DIR)
Jae Hoon Kim2f8c62a2021-06-22 15:10:43 -070029 parser.add_argument('--public-key',
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070030 help='Filename to the public key whose private part '\
31 'signed the keyblock.',
32 default=constants.RECOVERY_PUBLIC_KEY )
Jae Hoon Kim2f8c62a2021-06-22 15:10:43 -070033 parser.add_argument('--private-key',
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070034 help='Filename to the private key whose public part is '\
35 'baked into the keyblock.',
Jae Hoon Kim4e35db82021-06-16 13:05:44 -070036 default=constants.MINIOS_DATA_PRIVATE_KEY )
Jae Hoon Kim2f8c62a2021-06-22 15:10:43 -070037 parser.add_argument('--keyblock',
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070038 help='Filename to the kernel keyblock.',
Jae Hoon Kim4e35db82021-06-16 13:05:44 -070039 default=constants.MINIOS_KEYBLOCK)
Jae Hoon Kim39c62d82021-06-16 17:25:19 -070040 parser.add_argument('--serial', type=str,
41 help='Serial port for the kernel console (e.g. printks)')
Amin Hassanic7febef2021-05-04 11:26:22 -070042 return parser
43
44
45def main(argv):
46 parser = GetParser()
47 opts = parser.parse_args(argv)
48 opts.Freeze()
49
50 with tempfile.TemporaryDirectory() as work_dir:
Vyshu92153902021-06-16 13:31:53 -040051 kernel = minios.CreateMiniOsKernelImage(opts.board, opts.version, work_dir,
Jae Hoon Kimd99d9e02021-06-15 13:56:30 -070052 opts.keys_dir, opts.public_key,
Jae Hoon Kim39c62d82021-06-16 17:25:19 -070053 opts.private_key, opts.keyblock,
54 opts.serial)
Amin Hassanic7febef2021-05-04 11:26:22 -070055 minios.InsertMiniOsKernelImage(opts.image, kernel)