Skip to content

Commit cbfc437

Browse files
superrCaptainThrowback
authored andcommitted
New command line argument "--skip_hash"
Just add it to the beginning of the command (./extract.py --skip_hash) and the hash will be skipped. Fixed bug where if the old file that matches the new file does not exist we get a crash. Now we attempt to extract the new file without the old file. Added automatic file renaming. You can put your .img files in the "old" directory and they will be renamed automatically, and back at the end of the extraction. Additionally, the "output" directory will get .img appended to their file names after the extraction. Removed the need for the "LD_LIBRARY_PATH=./lib64/" part of the command by setting it within the script. Updated README.md to reflect all changes.
1 parent da90251 commit cbfc437

15 files changed

Lines changed: 36 additions & 17 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
### Full OTA
77

8-
- LD_LIBRARY_PATH=./lib64/ ./extract.py --output_dir output/ payload.bin
8+
- ./extract.py [--skip_hash] --output_dir output/ payload.bin
99
- This will start to extract the images within the payload.bin file to the output folder you are in.
1010

1111
### Incremental OTA
1212

13-
- Copy original images (from full OTA or dumped from devices) to old folder (with part name without file extension, ex: boot, system)
14-
- LD_LIBRARY_PATH=./lib64/ ./extract.py --output_dir output/ --old_dir old/ payload.bin
13+
- Copy original images (from full OTA or dumped from devices) to old folder
14+
- ./extract.py [--skip_hash] --output_dir output/ --old_dir old/ payload.bin

bspatch

100755100644
File mode changed.

extract.py

100755100644
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import argparse
44
import errno
5+
import glob
56
import os
67

78
import update_payload
89
from update_payload import applier
910

11+
os.environ['LD_LIBRARY_PATH'] = './lib64/'
1012

1113
def list_content(payload_file_name):
1214
with open(payload_file_name, 'rb') as payload_file:
@@ -18,13 +20,16 @@ def list_content(payload_file_name):
1820
part.new_partition_info.size))
1921

2022

21-
def extract(payload_file_name, output_dir="output", old_dir="old", partition_names=None):
23+
def extract(payload_file_name, output_dir="output", old_dir="old", partition_names=None, skip_hash=None):
2224
try:
2325
os.makedirs(output_dir)
2426
except OSError as e:
2527
if e.errno != errno.EEXIST:
2628
raise
2729

30+
for i in glob.glob(old_dir + '/*.img'):
31+
os.rename(i, i[:-4])
32+
2833
with open(payload_file_name, 'rb') as payload_file:
2934
payload = update_payload.Payload(payload_file)
3035
payload.Init()
@@ -40,12 +45,20 @@ def extract(payload_file_name, output_dir="output", old_dir="old", partition_nam
4045
helper._ApplyToPartition(
4146
part.operations, part.partition_name,
4247
'install_operations', output_file,
43-
part.new_partition_info, old_file, part.old_partition_info)
48+
part.new_partition_info, old_file,
49+
part.old_partition_info, skip_hash)
4450
else:
4551
helper._ApplyToPartition(
4652
part.operations, part.partition_name,
4753
'install_operations', output_file,
48-
part.new_partition_info)
54+
part.new_partition_info,
55+
skip_hash=skip_hash)
56+
57+
for i in glob.glob(old_dir + '/*'):
58+
os.rename(i, i + '.img')
59+
60+
for i in glob.glob(output_dir + '/*'):
61+
os.rename(i, i + '.img')
4962

5063
if __name__ == '__main__':
5164
parser = argparse.ArgumentParser()
@@ -59,9 +72,11 @@ def extract(payload_file_name, output_dir="output", old_dir="old", partition_nam
5972
help="Name of the partitions to extract")
6073
parser.add_argument("--list_partitions", action="store_true",
6174
help="List the partitions included in the payload.bin")
75+
parser.add_argument("--skip_hash", action="store_true",
76+
help="Skip the hash check for individual img files")
6277

6378
args = parser.parse_args()
6479
if args.list_partitions:
6580
list_content(args.payload)
6681
else:
67-
extract(args.payload, args.output_dir, args.old_dir, args.partitions)
82+
extract(args.payload, args.output_dir, args.old_dir, args.partitions, args.skip_hash)

lib64/libbase.so

100755100644
File mode changed.

lib64/libbrillo.so

100755100644
File mode changed.

lib64/libc++.so

100755100644
File mode changed.

lib64/libchrome.so

100755100644
File mode changed.

lib64/libevent-host.so

100755100644
File mode changed.

lib64/liblog.so

100755100644
File mode changed.

lib64/libprotobuf-cpp-lite.so

100755100644
File mode changed.

0 commit comments

Comments
 (0)