diff options
author | Bo Hu <bohu@google.com> | 2019-05-29 16:34:49 +0000 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2019-09-06 13:40:30 +0200 |
commit | 54abbe0f41f1431bca34d89a700f299d0b4df019 (patch) | |
tree | 4bbf2f50f2683ea8e0db933fd0f04e8b4ff7b73c | |
parent | e4adeedcf353d50988959cd17ed99ff64746833f (diff) | |
download | android_device_generic_goldfish-54abbe0f41f1431bca34d89a700f299d0b4df019.tar.gz android_device_generic_goldfish-54abbe0f41f1431bca34d89a700f299d0b4df019.tar.bz2 android_device_generic_goldfish-54abbe0f41f1431bca34d89a700f299d0b4df019.zip |
Revert "Revert "goldfish: speed up system-qemu.img packaging""
This reverts commit f66e1c3cc8fff570729cc72dfe2214a428d30edb.
Reason for revert: fixed mac build and full-eng
Change-Id: Ia8537733f8d02b7b20075dc600c22103deb32662
-rwxr-xr-x | tools/extract_head_tail.sh | 20 | ||||
-rwxr-xr-x | tools/mk_combined_img.py | 26 | ||||
-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, 44 insertions, 2 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..8c74436 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]) @@ -129,7 +133,7 @@ def main(): config.close() # take a shortcut in build environment - if os.path.exists(output_filename): + if os.path.exists(output_filename) and len(partitions) == 2: print "updating " + output_filename + " ..." shell_command(['dd', "if=" + partitions[0]["path"], "of=" + output_filename, "conv=notrunc,sync", "ibs=1024k", "obs=1024k", "seek=1"]) @@ -137,6 +141,24 @@ def main(): "conv=notrunc,sync", "ibs=1024k", "obs=1024k", "seek=2"]) print "done" sys.exit(0) + elif len(partitions) == 2: + 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=1024k", + "conv=notrunc,sync", "count=1"]) + shell_command(['dd', "if=" + partitions[0]["path"], "of=" + output_filename, + "bs=1024k", "conv=notrunc,sync", "seek=1"]) + shell_command(['dd', "if=" + partitions[1]["path"], "of=" + output_filename, + "bs=1024k", "conv=notrunc,sync", "seek=" + str(1 + int(partitions[0]["sizeByMb"]))]) + shell_command(['dd', "if=" + gpt_tail, "of=" + output_filename, + "bs=1024k", "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 |