aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2020-06-02 08:30:44 +0200
committerÁlvaro Fernández Rojas <noltari@gmail.com>2020-06-02 08:33:11 +0200
commit58bdbe73212a7f1c2755cf640e21b01e9b2d7b04 (patch)
tree9974fd9a878f4ae0d3a5d9cc299fa3a1950e471a /scripts
parent8d2c031f21d48505a58807bcafae13f2f6cf628f (diff)
downloadupstream-58bdbe73212a7f1c2755cf640e21b01e9b2d7b04.tar.gz
upstream-58bdbe73212a7f1c2755cf640e21b01e9b2d7b04.tar.bz2
upstream-58bdbe73212a7f1c2755cf640e21b01e9b2d7b04.zip
scripts: support Sercomm partition tags
Sercomm uses a custom layout for partition tags: char part_name[32]; char size[32]; char part_version[32]; char reserved[32]; char rootfs_version[32]; Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sercomm-partition-tag.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/scripts/sercomm-partition-tag.py b/scripts/sercomm-partition-tag.py
new file mode 100755
index 0000000000..ef49af8c05
--- /dev/null
+++ b/scripts/sercomm-partition-tag.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import struct
+
+def create_header(args, size):
+ header = struct.pack('32s32s32s32s32s',
+ args.part_name.encode('ascii'),
+ str(size).encode('ascii'),
+ args.part_version.encode('ascii'),
+ "".encode('ascii'),
+ args.rootfs_version.encode('ascii'))
+
+ return header
+
+def create_output(args):
+ in_st = os.stat(args.input_file)
+ in_size = in_st.st_size
+
+ header = create_header(args, in_size)
+ print(header)
+
+ in_f = open(args.input_file, 'r+b')
+ in_bytes = in_f.read(in_size)
+ in_f.close()
+
+ out_f = open(args.output_file, 'w+b')
+ out_f.write(header)
+ out_f.write(in_bytes)
+ out_f.close()
+
+def main():
+ global args
+
+ parser = argparse.ArgumentParser(description='')
+
+ parser.add_argument('--input-file',
+ dest='input_file',
+ action='store',
+ type=str,
+ help='Input file')
+
+ parser.add_argument('--output-file',
+ dest='output_file',
+ action='store',
+ type=str,
+ help='Output file')
+
+ parser.add_argument('--part-name',
+ dest='part_name',
+ action='store',
+ type=str,
+ help='Partition Name')
+
+ parser.add_argument('--part-version',
+ dest='part_version',
+ action='store',
+ type=str,
+ help='Partition Version')
+
+ parser.add_argument('--rootfs-version',
+ dest='rootfs_version',
+ action='store',
+ type=str,
+ help='RootFS lib version')
+
+ args = parser.parse_args()
+
+ if not args.rootfs_version:
+ args.rootfs_version = ""
+
+ if ((not args.input_file) or
+ (not args.output_file) or
+ (not args.part_name) or
+ (not args.part_version)):
+ parser.print_help()
+
+ create_output(args)
+
+main()