extract_android_ota_payload.py: don't keep temporary payload.bin file
It takes up a couple of gigabytes of space per-device.
This commit is contained in:
parent
55c15c81e6
commit
7eceea9041
1 changed files with 5 additions and 0 deletions
|
@ -102,10 +102,12 @@ def parse_payload(payload_f, partition, out_f):
|
||||||
update_metadata_pb2.InstallOperation.Type.Name(operation.type)))
|
update_metadata_pb2.InstallOperation.Type.Name(operation.type)))
|
||||||
|
|
||||||
def main(filename, output_dir):
|
def main(filename, output_dir):
|
||||||
|
is_tmp_payload_file = False
|
||||||
if filename.endswith('.zip'):
|
if filename.endswith('.zip'):
|
||||||
print("Extracting 'payload.bin' from OTA file...")
|
print("Extracting 'payload.bin' from OTA file...")
|
||||||
ota_zf = zipfile.ZipFile(filename)
|
ota_zf = zipfile.ZipFile(filename)
|
||||||
payload_file = open(ota_zf.extract('payload.bin', output_dir), 'rb')
|
payload_file = open(ota_zf.extract('payload.bin', output_dir), 'rb')
|
||||||
|
is_tmp_payload_file = True
|
||||||
else:
|
else:
|
||||||
payload_file = open(filename, 'rb')
|
payload_file = open(filename, 'rb')
|
||||||
|
|
||||||
|
@ -145,6 +147,9 @@ def main(filename, output_dir):
|
||||||
out_f.close()
|
out_f.close()
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
|
|
||||||
|
if is_tmp_payload_file:
|
||||||
|
os.unlink(os.path.join(output_dir, 'payload.bin'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
|
|
Loading…
Reference in a new issue