Skip to content

This is for Incremental OTAs only #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## System requirement

- Python3, pip
- google protobuf for python `pip3 install protobuf`

### Full OTA

- LD_LIBRARY_PATH=./lib64/ ./extract.py --output_dir output/ payload.bin
- This will start to extract the images within the payload.bin file to the output folder you are in.

### Incremental OTA

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

NOTE: this has been fixed for Incremental updates. Just ensure you use the ROM that was meant to be PATCHED in the old/ directory
AS THE HASH CHECKS ARE TURNED OFF. The original project never worked because the HASH of the Incremental update and the prior full ROM
always had different signatures. So there is NO ERROR CHECKING HAPPENING. Works as of 8/2021, tested on Op8T.
3 changes: 3 additions & 0 deletions add_img_extension_output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd output
find . -type f -exec mv '{}' '{}'.img \;
cd ..
Binary file added bspatch
Binary file not shown.
28 changes: 16 additions & 12 deletions extract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3

import argparse
import errno
Expand All @@ -18,7 +18,7 @@ def list_content(payload_file_name):
part.new_partition_info.size))


def extract(payload_file_name, output_dir="output", partition_names=None):
def extract(payload_file_name, output_dir="output", old_dir="old", partition_names=None):
try:
os.makedirs(output_dir)
except OSError as e:
Expand All @@ -29,28 +29,32 @@ def extract(payload_file_name, output_dir="output", partition_names=None):
payload = update_payload.Payload(payload_file)
payload.Init()

if payload.IsDelta():
print("Delta payloads are not supported")
exit(1)

helper = applier.PayloadApplier(payload)
for part in payload.manifest.partitions:
if partition_names and part.partition_name not in partition_names:
continue
print("Extracting {}".format(part.partition_name))
output_file = os.path.join(output_dir, part.partition_name)
helper._ApplyToPartition(
part.operations, part.partition_name,
'install_operations', output_file,
part.new_partition_info)

if payload.IsDelta():
old_file = os.path.join(old_dir, part.partition_name)
helper._ApplyToPartition(
part.operations, part.partition_name,
'install_operations', output_file,
part.new_partition_info, old_file, part.old_partition_info)
else:
helper._ApplyToPartition(
part.operations, part.partition_name,
'install_operations', output_file,
part.new_partition_info)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("payload", metavar="payload.bin",
help="Path to the payload.bin")
parser.add_argument("--output_dir", default="output",
help="Output directory")
parser.add_argument("--old_dir", default="old",
help="Old directory")
parser.add_argument("--partitions", type=str, nargs='+',
help="Name of the partitions to extract")
parser.add_argument("--list_partitions", action="store_true",
Expand All @@ -60,4 +64,4 @@ def extract(payload_file_name, output_dir="output", partition_names=None):
if args.list_partitions:
list_content(args.payload)
else:
extract(args.payload, args.output_dir, args.partitions)
extract(args.payload, args.output_dir, args.old_dir, args.partitions)
Binary file added lib64/libbase.so
Binary file not shown.
Binary file added lib64/libbrillo.so
Binary file not shown.
Binary file added lib64/libc++.so
Binary file not shown.
Binary file added lib64/libchrome.so
Binary file not shown.
Binary file added lib64/libevent-host.so
Binary file not shown.
Binary file added lib64/liblog.so
Binary file not shown.
Binary file added lib64/libprotobuf-cpp-lite.so
Binary file not shown.
Binary file added puffin
Binary file not shown.
3 changes: 3 additions & 0 deletions remove_img_extension_old.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd old
for i in ./*.img; do mv -i "$i" "${i%.img}"; done
cd ..
2 changes: 2 additions & 0 deletions update_payload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"""Library for processing, verifying and applying Chrome OS update payloads."""

# Just raise the interface classes to the root namespace.
from __future__ import absolute_import

from update_payload.checker import CHECKS_TO_DISABLE
from update_payload.error import PayloadError
from update_payload.payload import Payload
Loading