mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
The self signed images generated when running 'make BOARD=cr50' use constant default values for the epoch, major and minor image header fields. For the purposes of continuous testing we need the generated images have sensible values in those header fields. Since adding a full blown C++ based parser to the signer image is too much trouble, let's just have a very basic Python based parser, which pays attention only to the required fields from the current manifest. BRANCH=cr50 BUG=none TEST=built the new image and checked its version: $ make BOARD=cr50 ... $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin read 524288(0x80000) bytes from build/cr50/ec.bin RO_A:0.0.23 RW_A:0.0.23[00000000:00000000:00000000] RO_B:-1.-1.-1 ... Change-Id: I822475ed0a3c481b08e9268f9c13663b0b132d4a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/651132 Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
54 lines
1.3 KiB
Python
Executable File
54 lines
1.3 KiB
Python
Executable File
#!/usr/bin/python
|
|
# Copyright 2017 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
"""Poor man's JSON parser.
|
|
|
|
This module reads the input JSON file, retrieves from it some name/value pairs
|
|
and generates a .h file to allow a C code use the definitions.
|
|
|
|
The JSON file name is required to be passed in in the command line, the nodes
|
|
this script pays attention to are included in required_keys tuple below.
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
|
|
required_keys = ('epoch', 'major', 'minor')
|
|
|
|
|
|
def main(json_file_name):
|
|
# get rid of the comments
|
|
json_text = []
|
|
h_file_text = ['''
|
|
/*
|
|
* Copyright %d The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* This file was autogenerated, do not edit. */
|
|
''',]
|
|
|
|
json_file = open(json_file_name, 'r')
|
|
for line in json_file.read().splitlines():
|
|
json_text.append(line.split('//')[0])
|
|
|
|
j = json.loads('\n'.join(json_text))
|
|
|
|
for key in required_keys:
|
|
if key in j.keys():
|
|
value = j[key]
|
|
else:
|
|
value = '0'
|
|
|
|
h_file_text.append('#define MANIFEST_%s %s' % (key.upper(), value))
|
|
|
|
h_file_text.append('')
|
|
return '\n'.join(h_file_text)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print main(sys.argv[1])
|