libcamera/utils/gen-ipa-pub-key.py
Laurent Pinchart 3cb20bc230 libcamera: Drop remaining file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment blocks in all
remaining locations that were not caught by the automated script as they
are out of sync with the file name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-09 23:31:15 +03:00

48 lines
1.2 KiB
Python
Executable file

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# Generate the IPA module signing public key
import string
import subprocess
import sys
def main(argv):
if len(argv) != 4:
print('Usage: %s priv-key template output' % argv[0])
return 1
priv_key = argv[1]
template = argv[2]
output = argv[3]
try:
ret = subprocess.run(['openssl', 'rsa', '-pubout', '-in', priv_key,
'-outform', 'DER'],
stdout=subprocess.PIPE)
except FileNotFoundError:
print('Please install openssl to sign IPA modules')
return 1
ipa_key = ['0x%02x' % c for c in ret.stdout]
ipa_key = [', '.join(ipa_key[bound:bound + 8]) for bound in range(0, len(ipa_key), 8)]
ipa_key = ',\n\t'.join(ipa_key)
data = {'ipa_key': ipa_key}
template = open(template, 'rb').read()
template = template.decode('utf-8')
template = string.Template(template)
f = open(output, 'wb')
f.write(template.substitute(data).encode('utf-8'))
f.close()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))