summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Rosenkränzer2016-02-23 13:54:35 -0600
committerBernhard Rosenkränzer2016-02-23 15:39:35 -0600
commitc434cf82d526f07cd3dcebf53582eeddf12b0a74 (patch)
treec05c7d467092ca7a6a1c8c687e5405ffa5351315 /mkbootimg
parent72d6269b6efda3e43a119de048b87758ff970184 (diff)
downloadplatform-system-core-c434cf82d526f07cd3dcebf53582eeddf12b0a74.tar.gz
platform-system-core-c434cf82d526f07cd3dcebf53582eeddf12b0a74.tar.xz
platform-system-core-c434cf82d526f07cd3dcebf53582eeddf12b0a74.zip
Allow building with Python 3.x
Allow the scripts to run with both python 2.x and 3.x Change-Id: I911118bcf370d09bdb2fb46afa21af64257f1ffb Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Diffstat (limited to 'mkbootimg')
-rwxr-xr-xmkbootimg/mkbootimg7
1 files changed, 5 insertions, 2 deletions
diff --git a/mkbootimg/mkbootimg b/mkbootimg/mkbootimg
index aea258593..f95d7039c 100755
--- a/mkbootimg/mkbootimg
+++ b/mkbootimg/mkbootimg
@@ -19,6 +19,7 @@ from argparse import ArgumentParser, FileType, Action
19from os import fstat 19from os import fstat
20from struct import pack 20from struct import pack
21from hashlib import sha1 21from hashlib import sha1
22import sys
22 23
23def filesize(f): 24def filesize(f):
24 if f is None: 25 if f is None:
@@ -133,8 +134,10 @@ def main():
133 img_id = write_header(args) 134 img_id = write_header(args)
134 write_data(args) 135 write_data(args)
135 if args.id: 136 if args.id:
136 print('0x' + ''.join('{:02x}'.format(ord(c)) for c in img_id)) 137 if isinstance(img_id, str):
137 138 # Python 2's struct.pack returns a string, but py3 returns bytes.
139 img_id = [ord(x) for x in img_id]
140 print('0x' + ''.join('{:02x}'.format(c) for c in img_id))
138 141
139if __name__ == '__main__': 142if __name__ == '__main__':
140 main() 143 main()