diff options
author | bohu <bohu@google.com> | 2019-05-24 10:19:42 -0700 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2019-09-06 13:40:20 +0200 |
commit | 8c059810dc9eadf84306cb739d502f1db9cd528b (patch) | |
tree | e353a1f3f34b7c708334bd6ffcf465d4198f0674 | |
parent | beae054097d61bf085cb31c62f8423817d8066d8 (diff) | |
download | android_device_generic_goldfish-8c059810dc9eadf84306cb739d502f1db9cd528b.tar.gz android_device_generic_goldfish-8c059810dc9eadf84306cb739d502f1db9cd528b.tar.bz2 android_device_generic_goldfish-8c059810dc9eadf84306cb739d502f1db9cd528b.zip |
goldfish: speed up system-qemu.img packaging
by using prebuilt/gpt/<size>/head.img, tail.img
Change-Id: I589ea65329373db8065de6c3af9a44365883ab77
Merged-In: I589ea65329373db8065de6c3af9a44365883ab77
-rwxr-xr-x | tools/extract_head_tail.sh | 20 | ||||
-rwxr-xr-x | tools/mk_combined_img.py | 24 | ||||
-rw-r--r-- | tools/prebuilt/gpt/1_3080/head.img | bin | 0 -> 1048576 bytes | |||
-rw-r--r-- | tools/prebuilt/gpt/1_3080/tail.img | bin | 0 -> 1048576 bytes |
4 files changed, 43 insertions, 1 deletions
diff --git a/tools/extract_head_tail.sh b/tools/extract_head_tail.sh new file mode 100755 index 0000000..5941da7 --- /dev/null +++ b/tools/extract_head_tail.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +if [ "$#" -ne 3 ]; then + echo "$0 src.img head.img tail.img" >&2 + exit 1 +fi + +srcimg=$1 +headimg=$2 +tailimg=$3 + +disksize=$(stat -c %s $srcimg) + +mycount=`expr $disksize \/ 1024 \/ 1024 - 1` + +dd if=$srcimg of=$headimg ibs=1M obs=1M count=1 +dd if=$srcimg of=$tailimg ibs=1M obs=1M count=1 skip=$mycount +#dd if=/dev/zero of=file.txt count=3083 bs=1M diff --git a/tools/mk_combined_img.py b/tools/mk_combined_img.py index be19cd7..719f305 100755 --- a/tools/mk_combined_img.py +++ b/tools/mk_combined_img.py @@ -16,7 +16,8 @@ def check_sparse(filename): return False def shell_command(comm_list): - command = Popen(comm_list) + command = Popen(comm_list, stdout=PIPE, stderr=PIPE) + command.communicate() execute = command.wait() if command.returncode != 0: sys.exit(1) @@ -41,6 +42,9 @@ def parse_input(input_file): partition_info = dict() partition_info["path"] = line[0] partition_info["label"] = line[1] + # round up by 1M + sizeByMb = str((1024 * 1024 - 1 + os.path.getsize(line[0])) / 1024 / 1024) + partition_info["sizeByMb"] = sizeByMb try: partition_info["num"] = int(line[2]) @@ -137,6 +141,24 @@ def main(): "conv=notrunc,sync", "ibs=1024k", "obs=1024k", "seek=2"]) print "done" sys.exit(0) + else: + gptprefix = partitions[0]["sizeByMb"] + "_" + partitions[1]["sizeByMb"] + prebuilt_gpt_dir = os.path.dirname(os.path.abspath( __file__ )) + "/prebuilt/gpt/" + gptprefix + gpt_head = prebuilt_gpt_dir + "/head.img" + gpt_tail = prebuilt_gpt_dir + "/head.img" + if os.path.exists(gpt_head) and os.path.exists(gpt_tail): + print "found prebuilt gpt header and footer, use it" + shell_command(['dd', "if=" + gpt_head, "of=" + output_filename, "bs=1M", + "conv=notrunc,sync", "count=1"]) + shell_command(['dd', "if=" + partitions[0]["path"], "of=" + output_filename, + "bs=1M", "conv=notrunc,sync", "seek=1"]) + shell_command(['dd', "if=" + partitions[1]["path"], "of=" + output_filename, + "bs=1M", "conv=notrunc,sync", "seek=" + str(1 + int(partitions[0]["sizeByMb"]))]) + shell_command(['dd', "if=" + gpt_tail, "of=" + output_filename, + "bs=1M", "conv=notrunc,sync", + "seek=" + str(1 + int(partitions[0]["sizeByMb"]) + int(partitions[1]["sizeByMb"]))]) + print "done" + sys.exit(0) # combine the images # add padding diff --git a/tools/prebuilt/gpt/1_3080/head.img b/tools/prebuilt/gpt/1_3080/head.img Binary files differnew file mode 100644 index 0000000..f16ea54 --- /dev/null +++ b/tools/prebuilt/gpt/1_3080/head.img diff --git a/tools/prebuilt/gpt/1_3080/tail.img b/tools/prebuilt/gpt/1_3080/tail.img Binary files differnew file mode 100644 index 0000000..2f69829 --- /dev/null +++ b/tools/prebuilt/gpt/1_3080/tail.img |