History log of /build/make/tools/releasetools/add_img_to_target_files.py
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
dba59eeabd21c91d67d6a6ce365141deb56ed0f7 09-Jan-2018 Tao Bao <tbao@google.com> releasetools: Don't return ZipFile from common.UnzipTemp().

In addition to the unzipping work, common.UnzipTemp() kindly bundles an
open ZipFile object as part of the return value. It doesn't look very
helpful to the callers though. It also looks less obvious that the
caller needs to properly close the handle (missing the close here is
benign though). This CL just removes the ZipFile object out of the
return value, and leaves the work to callers.

Test: `m dist` on both of A/B and non-A/B target.
Test: python -m unittest test_add_img_to_target_files
Test: python -m unittest test_common
Test: python -m unittest test_ota_from_target_files
Test: Check the callers to common.UnzipTemp() in code search.
Change-Id: Id47da3fd42a0e76d6ae8851f05780db319ee48cf
/build/make/tools/releasetools/add_img_to_target_files.py
886d883d61bd1abbecffed39a6434bfbaa91da9a 27-Feb-2018 Tao Bao <tbao@google.com> releasetools: Remove the unneeded 'prefix' parameters.

... from the following functions in add_img_to_target_files.py.

AddSystem
AddSystemOther
AddVendor
AddProduct
AddDtbo
AddUserdata
AddVBMeta
AddPartitionTable
AddCache

The last user of the parameter in img_from_target_files.py has been
removed in commit 2bb109709ad9c6c92a48abee589d74945f774118 (in O).

Test: pylint --rcfile=pylintrc add_img_to_target_files.py
Test: Check all the callers to the above functions.
Test: m dist
Change-Id: I551d1683def8f8535062fc90f68dafa0f4252822
/build/make/tools/releasetools/add_img_to_target_files.py
63c18fead80fc7a710380f157529f01ea6500d48 22-Feb-2018 Tao Bao <tbao@google.com> releasetools: Add unittests for GetCareMap() and AddCareMapTxtForAbOta().

With test_utils.construct_sparse_image(), creating valid sparse image is
no longer a blocker for testing these functions.

Test: python -m unittest test_add_img_to_target_files
Change-Id: Iff1f15837cc744bad52e2120f9a9ad94d7db50d5
/build/make/tools/releasetools/add_img_to_target_files.py
12d87fc174d8c2f47a1f738f0d6514c2ceb4d241 31-Jan-2018 Tao Bao <tbao@google.com> releasetools: Move the AVB salt setup into common.LoadInfoDict().

We used to do this in add_img_to_target_files.AddImagesToTargetFiles(),
which didn't cover the path when calling from make_recovery_patch. As a
result, /system/bin/install-recovery.sh contains different SHA values
from the actual images.

Test: Set up aosp_bullhead to use AVB. `m dist`, then run the following
command to verify the generated install-recovery.sh.

$ ./build/make/tools/releasetools/validate_target_files.py \
out/dist/aosp_bullhead-target_files-eng.zip

Change-Id: Id7be8fb17072252fcd4d08db2057b8c4af053376
/build/make/tools/releasetools/add_img_to_target_files.py
b7735d81054002961b681f4bdf296d4de2701135 27-Nov-2017 Jaekyun Seok <jaekyun@google.com> Support /product partition

This CL adds the following build flags to support building product partition
from Android build system.
- BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
- BOARD_AVB_PRODUCT_KEY_PATH
- BOARD_AVB_PRODUCT_ALGORITHM
- BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION
- BOARD_PREBUILT_PRODUCTIMAGE
- BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT
- BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
- BOARD_PRODUCTIMAGE_PARTITION_SIZE
- BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE
- BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR
- BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT
- BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN
- BOARD_USES_PRODUCTIMAGE
- LOCAL_PRODUCT_MODULE
- PRODUCT_FOOTER_ARGS
- PRODUCT_PRODUCT_BASE_FS_PATH
- PRODUCT_PRODUCT_VERITY_PARTITION
- TARGET_COPY_OUT_PRODUCT
- TARGET_OUT_PRODUCT*

And PRODUCT_PRODUCT_PROPERTIES is added to save product-specific
properties in /product/build.prop.

Bug: 64195575
Test: succeeded building product.img with BOARD_PRODUCTIMAGE_PARTITION_SIZE,
BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE and PRODUCT_PRODUCT_VERITY_PARTITION.

Change-Id: I774e6a38003734421591e51bed103802ff84f432
/build/make/tools/releasetools/add_img_to_target_files.py
a2ff4c9b0648c60952889dfed526e1f6e606ee97 17-Jan-2018 Tao Bao <tbao@google.com> releasetools: Clean up three functions in add_img_to_target_files.py.

This CL makes the following changes:
(a) cleans up the similar codes in AddCareMapTxtForAbOta() that handle
'system' and 'vendor' partitions;
(b) fixes an issue with the arcname in AddPackRadioImages() and
AddRadioImagesForAbOta(), where forward slash should always be used
in zip entry names;
(c) refactors the branching statements in AddRadioImagesForAbOta() to
reduce indentation levels.

Test: python -m unittest test_add_img_to_target_files
Test: `m dist` with aosp_marlin-userdebug. Check META/care_map.txt in the
generated target_files.zip.
Change-Id: I3d6f794962d0c68390fbd18eb13c2622acab3ff5
/build/make/tools/releasetools/add_img_to_target_files.py
bea20ac722f60c29fc9475b76996eab85bbcac20 18-Jan-2018 Tao Bao <tbao@google.com> releasetools: Refactor AddImagesToTargetFiles().

Separate three functions out of AddImagesToTargetFiles(), into
AddCareMapTxtForAbOta(), AddRadioImagesForAbOta() and
AddPackRadioImages() respectively. This CL tries to apply minimal
changes for the refactoring purpose.

Also add tests for AddRadioImagesForAbOta() and AddPackRadioImages().
The tests for AddCareMapTxtForAbOta() require better testing support to
mock sparse_img.SparseImage, which will be added in later CLs.

Test: python -m unittest test_add_img_to_target_files
Test: `m dist` with aosp_marlin-userdebug. Check META/care_map.txt in
the generated target_files.zip.
Change-Id: I1bb723c15237ff721f165cfce0ce996008ce9948
/build/make/tools/releasetools/add_img_to_target_files.py
1c830bfbaa92f23bde31e6b40e72c13e61085ba7 25-Dec-2017 Tao Bao <tbao@google.com> releasetools: Add common.MakeTempDir().

This simplifies the work to track mkdtemp()'d dirs. This CL also cleans
up the temporary file creation in build_image.py.

Test: `m dist`
Test: python -m unittest test_common
Change-Id: Ied7d86126714b9b26e5df7bcca1dfdea21cfcf60
/build/make/tools/releasetools/add_img_to_target_files.py
89d7ab23e85ba0594738622487f898e80ed89735 15-Dec-2017 Tao Bao <tbao@google.com> releasetools: Add common.ZipDelete().

We have been shelling out to 'zip -d' to delete existing ZIP entries in
add_img_to_target_files.py. This CL moves the function into common.py,
and calls that for the similar work in ota_from_target_files.py. This CL
also adds unittests for the newly added function.

Test: `m dist`
Test: python -m unittest test_common
Test: ota_from_target_files.py generates identical packages w/ and w/o
the CL (so we know the streaming property computation is intact).
Test: Run 'add_img_to_target_files.py -a' that triggers a call to
ReplaceUpdatedFiles().
Change-Id: Icaa6c3ea3ee2166023f78fa79275295f837ea842
/build/make/tools/releasetools/add_img_to_target_files.py
6b9fef52432e0943d9021a5e830885f7c2a19bfb 02-Dec-2017 Tao Bao <tbao@google.com> releasetools: Address pylint warnings in add_img_to_target_files.py.

C:661, 0: Wrong hanging indentation (add 2 spaces).
OPTIONS.input_tmp, "VENDOR_IMAGES")
^ | (bad-continuation)
C:673, 0: Wrong continued indentation (add 14 spaces).
os.path.join("IMAGES", img_name))
^ | (bad-continuation)
C: 54, 0: Import "import datetime" should be placed at the top of the module (wrong-import-position)
C: 55, 0: Import "import hashlib" should be placed at the top of the module (wrong-import-position)
C: 56, 0: Import "import os" should be placed at the top of the module (wrong-import-position)
C: 57, 0: Import "import shlex" should be placed at the top of the module (wrong-import-position)
C: 58, 0: Import "import shutil" should be placed at the top of the module (wrong-import-position)
C: 59, 0: Import "import subprocess" should be placed at the top of the module (wrong-import-position)
C: 60, 0: Import "import tempfile" should be placed at the top of the module (wrong-import-position)
C: 61, 0: Import "import uuid" should be placed at the top of the module (wrong-import-position)
C: 62, 0: Import "import zipfile" should be placed at the top of the module (wrong-import-position)
C: 64, 0: Import "import build_image" should be placed at the top of the module (wrong-import-position)
C: 65, 0: Import "import common" should be placed at the top of the module (wrong-import-position)
C: 66, 0: Import "import rangelib" should be placed at the top of the module (wrong-import-position)
C: 67, 0: Import "import sparse_img" should be placed at the top of the module (wrong-import-position)
W:391,12: Redefining built-in 'dir' (redefined-builtin)

After this CL, it still gives the warning below, which is to be
addressed with follow-ups.

R:635, 2: Too many nested blocks (6/5) (too-many-nested-blocks)

Test: `m dist`
Test: pylint --rcfile=pylintrc add_img_to_target_files.py
Change-Id: I64da184b6b69e93449dbfc989a5d7f46d5223f42
/build/make/tools/releasetools/add_img_to_target_files.py
bf70c318b7526f11b7fdcf555bd6db20e23571d6 12-Jul-2017 Tao Bao <tbao@google.com> releasetools: Allow building AVB-enabled recovery.img.

Bug: 68224784
Test: Enable AVB on aosp_bullhead-userdebug. `m dist`. Note that the
prebuilt vendor.img needs to be AVB-signed first.
Test: `m dist` with aosp_walleye-userdebug.
Change-Id: I18235e4d0dde6af71a96e46ec434480cc9a22bef
/build/make/tools/releasetools/add_img_to_target_files.py
ae396d9b0cbc5b49aea4c2d0d8146b77160354d4 20-Nov-2017 Tao Bao <tbao@google.com> releasetools: Always create IMAGES/ directory.

AddImagesToTargetFiles() takes either a zip file, or a zip root as
input. We used to create IMAGES/ directory only when working with zip
root input. Commit 262bf3f0b53b2a8d89fd76f1f37775673b6f0370 has changed
to also stage boot / recovery images there when working with a zip file.
This CL makes sure the directory is always available under both modes.

Bug: 63456822
Test: zip -d target_files.zip IMAGES/\*;
add_img_to_target_files.py target_files.zip
Test: sign_target_files_apks.py target_files.zip signed-target_files.zip
Change-Id: Iea91d0403cdec1b16bb93bb71d3ed06856b8f7c3
/build/make/tools/releasetools/add_img_to_target_files.py
262bf3f0b53b2a8d89fd76f1f37775673b6f0370 12-Jul-2017 Tao Bao <tbao@google.com> releasetools: Fix the rebuilding of vbmeta.img.

If only vbmeta.img is missing from the target_files.zip,
'add_img_to_target_files.py -a' will fail to re-create vbmeta.img.

++++ vbmeta ++++

Traceback (most recent call last):
File "./build/make/tools/releasetools/add_img_to_target_files.py", line 693, in <module>
main(sys.argv[1:])
File "./build/make/tools/releasetools/add_img_to_target_files.py", line 687, in main
AddImagesToTargetFiles(args[0])
File "./build/make/tools/releasetools/add_img_to_target_files.py", line 584, in AddImagesToTargetFiles
boot_contents = boot_image.WriteToTemp()
AttributeError: 'NoneType' object has no attribute 'WriteToTemp'

Because it has skipped loading the boot.img, which leads to the above error.

Bug: 63456822
Test: As follows:
$ zip -d target_files.zip vbmeta.img
$ add_img_to_target_files.py -a target_files.zip
Test: `m dist` on aosp_arm64-userdebug
Change-Id: Ieba5f0b6848c3ec5d8bcfd24d48cc5af8b39f06c
/build/make/tools/releasetools/add_img_to_target_files.py
fa863c86b7e57838621bc9b62ffaf3ad15ae72d2 24-May-2017 Tao Bao <tbao@google.com> releasetools: Remove the workarounds for mkyaffs2image.

Test: `m dist` on Linux and macOS.
Test: Use an existing target_files.zip for bullhead. Remove IMAGES/*
and rebuild the images with 'add_img_to_target_files.py -a'. It
generates idential images as in the original TF.zip.
Change-Id: I803656bf2c924dce53f2271dcb967a94fff48440
/build/make/tools/releasetools/add_img_to_target_files.py
d86e3114fcda83d27937a38ec8c0fad3b15ed20f 23-Sep-2017 Tao Bao <tbao@google.com> Build repeatable system images with mke2fs.

We have added support in mkuserimg_mke2fs.sh that allows specifying
filesystem UUID and hash seed UUID. This CL generates and passes the
UUIDs based on the image name and build fingerprint. This way we can
rebuild and get identical images.

Note that this only applies to images generated with `m dist` and with
signing tools (sign_target_files_apks.py and
add_img_to_target_files.py). Images under $OUT (built with `make`) are
not affected.

Bug: 64994964
Test: lunch marlin-userdebug; run `m dist` twice (after deleting the
intermediate files under $OUT/obj/PACKAGING), and compare the
generated images.
Change-Id: I41cf4e5869582bb930af2f35a8e9c79bff43b2a2
(cherry picked from commit 3aa21e6bb9f46b5c16c4b42757d64e738e506031)
/build/make/tools/releasetools/add_img_to_target_files.py
2b6dfd6689e54b537423a223a693ebe9cdd53f84 28-Sep-2017 Tao Bao <tbao@google.com> Use computed salt for AVB-signed images.

We want the generated images being identical for the same source files.
Currently the generated ext4 image (either from make_ext4fs or mke2fs)
is reproducible, but the AVB footer added by avbtool contain changes
because of the random salt being used.

This CL changes the avbtool invocation to specify "--salt <hexstring>"
(already supported by avbtool) to use reproducible salt that's computed
based on fingerprints (or thumbprints if applicable).

Bug: 67023482
Test: Regenerate images from the same source as follows:
Use a target_files.zip from an AVB-enabled target.
$ zip -d target_files.zip IMAGES/\*
$ ./build/make/tools/releasetools/add_img_to_target_files.py \
-v target_files.zip
Repeat the above commands and compare the generated images.
Change-Id: Id9db17ae0132ca3a820b4be5a5ef06ca3fef71ed
(cherry picked from commit 8f05cca1d9989ecb2e5a5d12f1410b6eca8c75b6)
/build/make/tools/releasetools/add_img_to_target_files.py
b22afea0f0ea3880f9386a837850b13bcffc295c 12-Sep-2017 Tao Bao <tbao@google.com> Consider prebuilt vendor.img as having vendor partition.

vendor.img could be built from the source - in which case we have
unpacked files under VENDOR/ - or dropped in as a prebuilt binary blob.
We should consider either of them as target having a vendor partition.
Because we need to add its AVB hashtree info into vbmeta.img if target
is using AVB. Otherwise libfs_mgr would refuse to mount this
"AVB-enabled" vendor.img.

For targets not using AVB, this change is no-op.

Bug: 65462819
Test: Having vendor.img as prebuilt, `make dist`. Check that the
generated vbmeta.img contains the info from vendor.img.
Test: Build, flash and boot the above image.zip.
Change-Id: Iaeb30e2059cb33fb39f23e5ffd28f338d00ccbfc
/build/make/tools/releasetools/add_img_to_target_files.py
9a5f419ecf593da02b315d4a968ba8b562e2d794 21-Jul-2017 Tao Bao <tbao@google.com> Look for non-existent files listed in avb_vbmeta_args.

In BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS, if we have defined
"--include_descriptors_from_image" with an image file whose path points
to source tree, add_img_to_target_files.py or sign_target_files_apks.py
may fail to find the file. Because these scripts may run without a
source tree, by taking target_files.zip as the only input.

This CL scans additional locations in the input target_files.zip to find
those missing files in avb_vbmeta_args. As long as the files are included
in the target_files.zip, they get a second chance to be found.

Bug: 63910867
Test: As follows:
1. Setup BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS with a local file path;
2. Remove the local file;
3. sign_target_files_apks.py fails without this CL;
4. sign_target_files_apks.py works.
Change-Id: I3c58f80a5535db02b74cfe40d0c0beff72587cf8
(cherry picked from commit 1dc5d47653c319bc148175ce85b3b19b65952851)
/build/make/tools/releasetools/add_img_to_target_files.py
3f72176da0ce367ca6c0110e0be702007eca0822 30-Jun-2017 Tao Bao <tbao@google.com> Track the AVB property name change.

system_avb_hashtree_enable has been renamed to
avb_system_hashtree_enable in commit
3e599ead66fee82837928ed3fb1b46bd7ec13a41. 'care_map.txt' is missing due
to the change.

Bug: 63142730
Test: `m dist` and check IMAGES/care_map.txt exists in target_files zip.
Change-Id: I60c269b41df844b50353d357bf67c20f15548642
/build/make/tools/releasetools/add_img_to_target_files.py
95a95c3a5e96a7c26a4f5cd61d126725363c2c8e 17-Jun-2017 Tao Bao <tbao@google.com> Allow packing custom radio images into target_files zip.

Radio images are added to INSTALLED_RADIOIMAGE_TARGET, which by default
will be packed under RADIO/ in a target_files zip. This CL introduces
BOARD_PACK_RADIOIMAGES that allows additionally copying them into
IMAGES/, which will then be included into <product>-img.zip.

Bug: 62195105
Test: Define BOARD_PACK_RADIOIMAGES and `m dist`. Check the generated
target_files zip and <product>-img.zip.
Change-Id: I3deafd2dfecd1d4dbfdfc2d002fc40ef22fb60ea
/build/make/tools/releasetools/add_img_to_target_files.py
0effed4b9484392994a1169f23a7b282cfad91d7 20-Jun-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "AVB: support chain partition signing"
9ac4cb098460b1dd6bb77895d94351b5478b13e8 10-Jun-2017 Tianjie Xu <xunchang@google.com> Fix duplicate 'META/care_map.txt' when calling add_img_to_target_files

In case the system/vendor image is updated for an A/B target file, we'll
delay the write of META/care_map.txt. Specifically, we'll run "zip -d"
to remove the old entry and then zip in the new one from tmp dir.

Bug: 62345693
Test: Run add_img_to_target_files.py on sailfish target files, and
care_map.txt is updated.

Change-Id: Id2f9997aac50c0740e6944d0d0d43d98f5fc6c29
/build/make/tools/releasetools/add_img_to_target_files.py
3e599ead66fee82837928ed3fb1b46bd7ec13a41 26-May-2017 Bowgo Tsai <bowgotsai@google.com> AVB: support chain partition signing

Current build system will include AVB metadata from each partition and
store them into /vbmeta partiton when BOARD_AVB_ENABLE is set, which makes
each partition tightly-coupled.

Add the support for 'chain partition':
- The vbmeta of each partition is stored on the same partition itself.
- The public key used to verify each partition is stored in /vbmeta.

For example, the following build variables are required to enable chain
partition for system partition:
- BOARD_AVB_SYSTEM_KEY_PATH := path/to/system_private_key
- BOARD_AVB_SYSTEM_ALGORITHM := SHA512_RSA8192
- BOARD_AVB_SYSTEM_ROLLBACK_INDEX := 1
- BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION := 2

The corresponding settings will be added into META/misc_info.txt for
build_image.py and/or add_img_to_target_files.py:
- avb_system_key_path=path/to/system_private_key
- avb_system_algorithm=SHA512_RSA8192
- avb_system_add_hashtree_footer_args=--rollback_index 1
- avb_system_rollback_index_location=2

To enable chain partition for other partitions, just replace SYSTEM with
BOOT, VENDOR and/or DTBO in the build variables.

Also switch from `avbtool make_vbmeta_image --setup_rootfs_from_kernel system.img ...`
to `avbtool add_hashtree_footer --image system.img --setup_as_rootfs_from_kernel...`
when BOARD_BUILD_SYSTEM_ROOT_IMAGE is true. This works for both chained
and no-chained:
- chained: `avbtool add_hashtree_footer --setup_as_rootfs_from_kernel` will
add dm-verity kernel cmdline descriptor to system.img
- no-chained: `avbtool make_vbmeta_image --include_descriptors_from_image
system.img` will include the kernel cmdline descriptor from system.img into
vbmeta.img

Bug: 38399657
Test: `make` pass, flash images from $OUT and boot device without chain partitions
Test: `make` pass, flash images from $OUT and boot device with chain partitions
Test: `make dist` pass, flash images from TF.zip and boot device without chain partitions
Test: `make dist` pass, flash images from TF.zip and boot device with chain partitions
Test: follow the same steps in
https://android-review.googlesource.com/#/c/407572/

Change-Id: I344f79290743d7d47b5e7441b3a21df812a69099
/build/make/tools/releasetools/add_img_to_target_files.py
3ebfddeabe3451b7f33d110023bfc1b207a4760d 24-May-2017 Tao Bao <tbao@google.com> Remove three board_avb_* args from META/misc_info.txt.

board_avb_algorithm and board_avb_key_path are overlapping with
avb_signing_args. In core/Makefile, only avb_signing_args (i.e.
INTERNAL_AVB_SIGNING_ARGS) will be used in the AVB-signing command. It
covers the contents in board_avb_{algorithm,key_path}. We should do the
same thing in tools/releasetools to avoid potential inconsistency.

This CL cleans up the logic in tools/releasetools, by always using
avb_signing_args. This also allows easier signing key replacement (so we
can replace the key/algorithm/signer in 'avb_signing_args').

board_avb_system_add_hashtree_footer_args is unused in releasetools
script, and the same information has been covered by
system_avb_add_hashtree_footer_args. This CL removes this arg as well.

Test: `m dist`. Then a) check the removed three args no longer exist in
META/misc_info.txt; b) check that rebuilding images with
add_img_to_target_files.py uses the same parameters.
Change-Id: I7db890b5c942de5b6868d8d1ebf937586d4729c0
/build/make/tools/releasetools/add_img_to_target_files.py
4536e45f66b7ca4b48be2941ae9f402768ecbd7f 03-Jun-2017 Tao Bao <tbao@google.com> Merge "Support re-generating DTBO image from add_img_to_target_files.py."
6b2e155ee6eb3eaed089e8604e5cfa588e81473e 01-Jun-2017 Tianjie Xu <xunchang@google.com> Generate care_map.txt when AVB is enabled

When AVB is enabled, generate care_map.txt and add it to the target
files. Also copy it into the OTA package where it will later be used
by the update_verifier.

Bug: 62208947
Test: \
1. Run add_img_to_target_files on the TF of a new pixel device,
and care_map.txt generates successfully.

2. Make dist in oc-dr1-release and find care_map.txt in the OTA package.

3. update_verifier succeeds in reading all the blocks on the care_map,
and fails to read out-of-bound blocks.

Change-Id: I2881711e6f87789cb7de150dbeca18b756fed68a
/build/make/tools/releasetools/add_img_to_target_files.py
c633ed0230d4d2ab7d201303e3ad9652326acccd 31-May-2017 Tao Bao <tbao@google.com> Support re-generating DTBO image from add_img_to_target_files.py.

This is a step to enable signing a given target_files zip with release
keys.

When calling sign_target_files_apks.py, we will delete all the entries
under IMAGES/ in order to re-generate them (with the proper release
keys). In order to support that, we need to pack everything in need into
TF.zip.

Steps to test the CL.
a) Choose a target that has both AVB and DTBO enabled.
$ m dist

b) Check IMAGES/dtbo.img and PREBUILT_IMAGES/dtbo.img both exist in the
generated out/dist/TF.zip.

c) Remove the entries under IMAGES/ from the generated TF.zip.
$ zip -d TF.zip IMAGES/\*

d) Re-generate the images with TF.zip.
$ build/make/tools/releasetools/add_img_to_target_files.py TF.zip

e) Check that IMAGES/dtbo.img is re-generated, and it's identical to the
image in b). Note that by default the re-generated image will carry a
different footer, because of the random salt. This CL is verified by
specifying the same salt.

Bug: 38315721
Test: see above.
Change-Id: I0bdc4e1cd4800962dc3902ca550dad6a8ca56c78
/build/make/tools/releasetools/add_img_to_target_files.py
38af07ff20a8ba334a9eed782df4d70ef595ba2a 26-May-2017 Tianjie Xu <xunchang@google.com> Update the recovery files under SYSTEM/ if recovery patch is rebuilt

If we pass "rebuild_recovery" to add_img_to_target_files, the recovery
patch is rebuilt. But related files under SYSTEM/ (e.g.
SYSTEM/recovery-from-boot.p && SYSTEM/bin/install-recovery.sh) are not
updated.

This may cause a mismatch between system.img and SYSTEM/, and
may lead to a failure in validate_target_files.py.

Bug: 62096364
Test: Rebuild the system image in the TF and observe the recovery files
under SYSTEM/ get updated.

Change-Id: I7d679a612a86d02cf2eff81d1d120c0067138ed9
/build/make/tools/releasetools/add_img_to_target_files.py
889ee5e7d3a01bde72335d3f579e674da2c779f6 13-May-2017 Yueyao Zhu <yueyao@google.com> add dtbo support for ota

Test: make dist and locally push ota on a device
Change-Id: I920b98f20e248b437955b2a963eb69ed2ddb8d45
/build/make/tools/releasetools/add_img_to_target_files.py
9b3776017f45b9857067929dac35f4e5f8ffdf17 14-Apr-2017 Bowgo Tsai <bowgotsai@google.com> AVB: support BOARD_BUILD_SYSTEM_ROOT_IMAGE

Passing --setup_rootfs_from_kernel to avbtool when
BOARD_BUILD_SYSTEM_ROOT_IMAGE is true

Bug: 33590159
Test: 'make' sailfish with BOARD_AVB_ENABLE := true
Test: 'make dist' with BOARD_AVB_ENABLE := true
Change-Id: Ieb58dd9ae6be1eceb90a33c739b85cff5cbc6e0a
/build/make/tools/releasetools/add_img_to_target_files.py
8ee4a3db8c76656b0d8bfd6ce8490451e3c10620 31-Mar-2017 Bowgo Tsai <bowgotsai@google.com> AVB: support signing vendor.img

Uses avbtool to sign vendor.img if BOARD_AVB_ENABLE is set.
It also allows appending additional arguments to avbtool via
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS.

e.g.,
BOARD_AVB_ENABLE := true
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS := --generate_fec

Bug: 35415839
Test: "make" with the above variables and use avbtool to check vbmeta is
appended to vendor.img
Test: "make dist" with the above variables

Change-Id: I8ada38dff3def6d34613e77c67944def8a49f464
/build/make/tools/releasetools/add_img_to_target_files.py
2f80e83e98c5d727bd484b8078ec99eb415158eb 16-Mar-2017 Tao Bao <tbao@google.com> releasetools: Remove a dead line.

system_root_image has been dead since commit
2ce63edab715ae4ff34e1a2ef240b05216f6ca5d.

Test: pylint --rcfile=pylintrc add_img_to_target_files.py
Change-Id: Id791747b7313923b82279a21d264a998455a92d4
/build/make/tools/releasetools/add_img_to_target_files.py
2ee00d5f66ad789b7d97bffd2e4b1365597b848d 06-Mar-2017 Dan Willemsen <dwillemsen@google.com> Allow add_img_to_target_files to work on a directory

In addition to the current behavior of add_img_to_target_files working
on an existing zip file, allow passing in a directory where the target
files have already been extracted. When in this mode, it writes the
images out to that directory instead of the zip file.

This allows us to call add_img_to_target_files on the temp directory
used during the build to create the target files package, saving the
time and space of unzipping what we just zipped. This also allows us to
use the parallel soong_zip, which compresses the images much faster.

Test: aosp_marlin target_files zip is the same before/after this change
Test: marlin target_files zip is the same before/after this change
Test: bullhead target_files zip is the same before/after this change
Change-Id: I155654cdc7ad7754ba4ef76ec69c31f504a58198
/build/make/tools/releasetools/add_img_to_target_files.py
955629b4aa650fbdc681346d1f07906fabfb3226 01-Mar-2017 Tianjie Xu <xunchang@google.com> Do not read the block device when generating the care map

This remove the fstab dependency when building the OTA package for
marlin/sailfish.

Bug: 35811655
Test: OTA package builds successfully for sailfish.
Change-Id: If223d11dddca396c47262042c576f9e7d0cb5b33
(cherry picked from commit 7d051adc3be56594ee755bf4ed06b6597fd62268)
/build/make/tools/releasetools/add_img_to_target_files.py
82bdf6c1d7ed5ed2967e0670c1d0a446d6464f91 05-Feb-2017 Tao Bao <tbao@google.com> releasetools: Fix the bug when generating care_map.txt.

Commit f1a13180dba9c0145ac7bec8371340ae303c81c1 intended to remove the
verity blocks from care_map.txt, but it added new code without removing
the old one. This leads to a malformed care_map.txt and causes
update_verifier failure.

Bug: 34391662
Test: 'm -j dist' gives a TF.zip with 4-line META/care_map.txt (as
opposed to a 6-line file).

Change-Id: I7ff1aa525795c4b049af54c1755b0f0ea84f7e0e
/build/make/tools/releasetools/add_img_to_target_files.py
f1a13180dba9c0145ac7bec8371340ae303c81c1 20-Jan-2017 Tianjie Xu <xunchang@google.com> Remove verity blocks from care map

When reading /dev/block/dm-X, update_verifier isn't able to access the
verity meta blocks at the end of the system/vendor partition. So we need
to remove these block ranges from the care_map.

Bug: 34391662
Test: care_map generated successfully without verity meta blocks
Change-Id: Id57c602b7e5fd1b0c9d1e1fe5fcdd74e85b6b255
/build/make/tools/releasetools/add_img_to_target_files.py
89fbb0f6d586b4111b9207438d5d047ba0ad6d5f 10-Jan-2017 Tao Bao <tbao@google.com> releasetools: Replace print stmt with print().

So that it's compatible with Python 3.

Test: pylint --pylint=pylintrc

Change-Id: If06c135a492c94bedd713c8cbdf03155a502d5cd
/build/make/tools/releasetools/add_img_to_target_files.py
d07f9995b823157c7763c7a73b335bda99e603b0 02-Dec-2016 Tao Bao <tbao@google.com> Merge "Build recovery-two-step.img for two-step OTAs."
am: 06e14e438f

Change-Id: I9c5d6e5f71da88bc0f662373335b024a55ca193e
d42e97ebb45fdc5a30799a3f37e482948d318010 30-Nov-2016 Tao Bao <tbao@google.com> Build recovery-two-step.img for two-step OTAs.

In two-step OTAs, we write recovery image to /boot as the first step so
that we can reboot from there and install a new recovery image to
/recovery. However, bootloader will show "Your device is corrupt"
message when booting /boot with the recovery image. Because the recovery
image encodes the path of "/recovery" as part of the signature metadata,
which fails the verified boot.

This CL generates a special "recovery-two-step.img" in addition to the
regular recovery.img. This image encodes "/boot" when being signed,
which will be flashed to /boot at stage 1/3 in a two-step OTA.

Here are the desired changes:

- 'IMAGES/recovery-two-step.img' exists in target_files.zip for non-A/B
targets (e.g. bullhead). The image should not exist for targets that
don't have a recovery partition (e.g. A/B devices like sailfish).

- <device>-img.zip should not contain 'recovery-two-step.img'.

- Nothing should change when building non-two-step OTAs. For two-step
OTAs, 'recovery-two-step.img' should be included in the OTA package;
'updater-script' should flash this image to /boot at stage 1/3.

- When building a two-step OTA with an input TF.zip that doesn't have
IMAGES/recovery-two-step.img, it should use the existing
IMAGES/recovery.img instead.

Bug: 32986477
Test: Tested the steps above on bullhead and sailfish.
Change-Id: I34e6c599bcf2011d4cd5c926999418b3975d6d0f
/build/make/tools/releasetools/add_img_to_target_files.py
f4a88279ed8a3456a3823c75f2f85441b26199e7 24-Oct-2016 Tao Bao <tbao@google.com> Merge "releasetools: Support verity signer args."
am: 02d2d68aec

Change-Id: Ib1aed8ff11eeef2fd64a6520e92cfb30678dadc7
458104266f52e1d92fbde057496f621aa16084cc 18-Oct-2016 Tao Bao <tbao@google.com> releasetools: Support verity signer args.

system/extras/verity/build_verity_metadata.py now accepts
"--signer_args" to specify verity signer args.

Also remove the duplicate "--verity_signer_args" in
add_img_to_target_files.py, as we already have that in common.py.

Bug: 31500665
Test: Building and signing work w/ and w/o --signer_args.

Change-Id: I02f59c50a1ebf15c5505e9fffd5b9bbbbaa785be
/build/make/tools/releasetools/add_img_to_target_files.py
4e9c89ab8772f90924d03e2d012ef570c47cef10 05-Oct-2016 David Zeuthen <zeuthen@google.com> resolve merge conflicts of 86180eb to nyc-mr1-dev-plus-aosp

Change-Id: Ia4bfb2571bac509cebe22f70ff43e6696f832423
4014a9daa742c2fa45c93729fc9d75f488232e3c 30-Sep-2016 David Zeuthen <zeuthen@google.com> Make room for AVB hashtree and metadata.

While the system.img images currently built with AVB support verify
correctly, mounting the filesystem content fails. This is because
'avbtool add_hashtree_footer' used to claim some of the unused /
DONT_CARE space for stashing the verity tables and this resulting in the
mapped device ending up being smaller causing the mount failure.

Fix this by leaving enough room for AVB hashtree and metadata before
building the image. This is achieved by moving the AVB hashtree support
into build_image.py and using a just added '--calc_max_image_size'
option to 'avbtool add_hashtree_footer' to figure out how much space to
leave out.

This depends on https://android-review.googlesource.com/#/c/281821/

Bug: 31264226
Test: Mounting dm-verity set up from system.img now works.

Merged-In: I4c5de1004c1059f8c582e76b3b8517d427aa1a87

Change-Id: I945a5f1f6782791736cd319f216cfa6b448fb04d
/build/make/tools/releasetools/add_img_to_target_files.py
27ac0e34fec282656853e5a1be34a20fbe36e3b6 29-Sep-2016 David Zeuthen <zeuthen@google.com> resolve merge conflicts of c36ab42 to nyc-mr1-dev-plus-aosp

Change-Id: Iaf78fb6c723955fd92cc64194cb32bba73a9dafb
2ce63edab715ae4ff34e1a2ef240b05216f6ca5d 15-Sep-2016 David Zeuthen <zeuthen@google.com> Update for new Android Verified Boot (AVB).

This updates the build system for the new Android Verified Boot
codebase. As this is based on Brillo Verified Boot, this change replaces
the existing BVB support.

Android Verified Boot is enabled by the BOARD_AVB_ENABLE variable

BOARD_AVB_ENABLE := true

This will make the build system create vbmeta.img which will contain a
hash descriptor for boot.img, a hashtree descriptor for system.img, a
kernel-cmdline descriptor for setting up dm-verity for system.img and
append a hash-tree to system.img.

Additionally, the descriptors are left in boot.img and system.img so a
third party can create their own vbmeta.img file linking - using the
option --chain_partition - to these images. If this is not needed
footers can be erased using the 'avbtool erase_footer' command. It's
also harmless to just leave them in the images.

By default, the algorithm SHA256_RSA4096 is used with a test key from
the AVB source directory. This can be overriden by the
BOARD_AVB_ALGORITHM and BOARD_AVB_KEY_PATH variables to use e.g. a
4096-bit RSA key and SHA-512:

BOARD_AVB_ALGORITHM := SHA512_RSA4096
BOARD_AVB_KEY_PATH := /path/to/rsa_key_4096bits.pem

To prevent rollback attacks, the rollback index should be increased on a
regular basis. The rollback index can be set with the
BOARD_AVB_ROLLBACK_INDEX variable:

BOARD_AVB_ROLLBACK_INDEX := 5

If this is not set, the rollback index defaults to 0.

The variable BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS can be used to specify
additional options passed to 'avbtool make_vbmeta_image'. Typical
options to be used here include '--prop', '--prop_from_file', and
'--chain_partition'.

The variable BOARD_AVBTOOL_BOOT_ADD_HASH_FOOTER_ARGS can be used to
specify additional options passed to 'avbtool add_hash_footer' for
boot.img. Typical options to be used here include '--hash_algorithm' and
'--salt'.

The variable BOARD_AVBTOOL_SYSTEM_ADD_HASHTREE_FOOTER_ARGS can be used
to specify additional options passed to 'avbtool add_hashtree_footer'
for systems.img. Typical options to be used here include
'--hash_algorithm', '--salt', and '--block_size'.

BUG=31264226
TEST=Manually tested on edison-eng by inspecting {boot, system,
vbmeta}.img in out/ directory as well as their counterparts in
the IMAGES/ directory of edision-target_files-eng.zeuthen.zip

Merged-In: Ic9a61cfc65c148b12996e57f04da5432eef6b982

Change-Id: I97042655bca15e7eac899f12c5bada2f6184d307
/build/make/tools/releasetools/add_img_to_target_files.py
94a41630ef53df6572a10b0f7b36c935be0477df 25-Aug-2016 Tianjie Xu <xunchang@google.com> resolve merge conflicts of 8532aa4 to nyc-mr1-dev-plus-aosp

Change-Id: I104192d50552612d10e418791515a834266a8262
b48589af571ec760bf1a57aa2dcd7ec031b7427e 04-Aug-2016 Tianjie Xu <xunchang@google.com> Don't regenerate userdata.img when signing

The userdata.img and cache.img entries are not useful in signed builds;
because fastboot doesn't look at these two entries in the *img.zip when
flashing a device. And they aren't used elsewhere. Therefore, skip
building the image files for them when signing the target files with
sign_target_files_apks. Also, add an option "--is_signing" to avoid
adding these two images when we call add_img_to_target_files.

Change-Id: I39ba91a86d9a856d7d01771f6d1403dbf21f2011
Test: Run sign_target_files_apks on a target file and userdata/cache.img doesn't not generate.
Bug: 30642470
/build/make/tools/releasetools/add_img_to_target_files.py
ae3fdd2436854a35951de7c4bd98a2361e1f2123 22-Aug-2016 Tao Bao <tbao@google.com> Merge "releasetools: Allow creating target_files with ZIP64." am: 794c69e603 am: cfab69eb32
am: 59c8c55611

Change-Id: Ibf5b7b4abbb4477fa1d23f15af443ad66772e906
9c84e50f4c5f0fd6cd437c1a5869452c53a51d29 22-Aug-2016 Tao Bao <tbao@google.com> releasetools: Allow creating target_files with ZIP64.

add_img_to_target_files.py fails when the target_files.zip is over 4GiB
when adding IMAGES/ folder. Specify the flag to allow creating
target_files.zip with ZIP64 extension.

Other zip artifacts (-img.zip, -ota.zip etc) remain in non-ZIP64 format.
zip2zip is not affected, which still creates non-ZIP64 zips even when
copying from target_files in ZIP64.

Bug: 30961841
Test: "make dist" with large system image and check the artifacts.

Change-Id: I0568745f01ef8f0239081f783eac92288d4fdd84
/build/make/tools/releasetools/add_img_to_target_files.py
737afb98c9c1be26ef7d8052696673bb657948b8 11-Jul-2016 Tianjie Xu <xunchang@google.com> resolve merge conflicts of 333df6c to nyc-mr1-dev-plus-aosp

Change-Id: Ibe66a7c78073a9c3e9f139bd6b00a0afab075190
cfa86223d62a6afa0eb8f5a1a215e985bb0a8c89 08-Mar-2016 Tianjie Xu <xunchang@google.com> Add care_map to target_files package

Generate a new file containing care_data of system (and vendor)
partition, and add it under META/ of target file package. For
A/B update, copy this file to OTA package for later use by
update_verifier.

Bug: 27175949

Change-Id: I90bb972703afaeb94bc3efe718fd81b1cfbcabcc
/build/make/tools/releasetools/add_img_to_target_files.py
a3e8e9c6f33ecd57221b7fe0ab1bf9c5035351ed 30-Jun-2016 Alex Light <allight@google.com> resolve merge conflicts of 3f7c348 to nyc-mr1-dev-plus-aosp

Bug: 29278988

Change-Id: Icffb9a280311c7d3c45f096243ddf18f7ebecd9d
aaca421ec12eff32d49bff76515322b85282ba72 28-Jun-2016 Tianjie Xu <xunchang@google.com> Skip copying existing vendor images

add_img_to_target_files.py has an option of "-a" to add missing
images only. Under this option, the script should skip copying
the radio images for A/B devices when given image exists already
under "IMAGES/".

Test: Run the command on an A/B device, the existing radio images under "IMAGES/" don't get overwritten; and missing images are added correctly.
Bug: 29608905
Change-Id: Ie034b85a5d777d53e367f99470cea4d19cb1aaaf
/build/make/tools/releasetools/add_img_to_target_files.py
4e358ab2c3635439db5bd1a1ef424d5c1250ce00 16-Jun-2016 Alex Light <allight@google.com> Add system_other partition, install odex files

For AB devices, support flashing two system partitions for factory use.
The normal system image on one partition, but without dex preopt. And a
system_other image that just contains the odex files. The dex files will
not be stripped out of the system image, in case the second system
partition is wiped.

Setting BOARD_USES_SYSTEM_OTHER_ODEX := true in the BoardConfig.mk
enables this behavior.

One can control which directories are placed in system_other by the
SYSTEM_OTHER_ODEX_FILTER configuration variable. Currently we default
to only copying only app and priv-app odexs.

Bug: 29278988
Change-Id: I7f4e87da919e7dc6a89fd8c668193cd4e98631bc
/build/make/tools/releasetools/add_img_to_target_files.py
305b0887294c15513fce6c018fda3abe9c6d507c 16-Jun-2016 Elliott Hughes <enh@google.com> Remove obsolete MTD support from the releasetools scripts.

Bug: http://b/29250988
Change-Id: I653dc306485c6b35411840b53211d42eb6d19e34
/build/make/tools/releasetools/add_img_to_target_files.py
2e735ca34ecf70f5ebdded9e550ca47f78b5e1e6 11-May-2016 Wei Wang <wvw@google.com> Include BRILLO_VENDOR_PARTITIONS in target zip generation

This change will enable the target zip to include partition defined in
BRILLO_VENDOR_PARTITIONS. This is necessary for OTA to support
partitions other than boot and system in ab_partitions.txt.

The target zip will include images in BRILLO_VENDOR_PARTITIONS if
defined, under VENDOR_IMAGES/ with path kept. Also any vendor partitions
defined in AB_OTA_PARTITIONS will be copied to IMAGES/ in the target zip.

BUG: 28623063
Change-Id: Ic479048dfb8ac506acf827865e784fcb0432a1d5
/build/make/tools/releasetools/add_img_to_target_files.py
05e6f679e6736c0cc56740065450b4b43bfab113 11-May-2016 Wei Wang <wvw@google.com> Revert "Include vendor partitions in target zip generation"

This reverts commit 421fe44ae8e90a85b7f60ee6942687a51771b8b5.

Change-Id: Id45781de73735783bc7dfb6fc2838957578d00d3
/build/make/tools/releasetools/add_img_to_target_files.py
421fe44ae8e90a85b7f60ee6942687a51771b8b5 10-May-2016 Wei Wang <wvw@google.com> Include vendor partitions in target zip generation

This change will enable the target zip to include partition defined in
BRILLO_VENDOR_PARTITIONS. This is necessary for OTA to support
partitions other than boot and system in ab_partitions.txt.

BUG: 28623063
Change-Id: I6e0969c31c9ad2e8285c6f560825c160aa8c4d55
/build/make/tools/releasetools/add_img_to_target_files.py
25328627baceed4e09f01bd25ad016c2942669e3 08-Apr-2016 David Zeuthen <zeuthen@google.com> Add support for Brillo partitioning.

To generate partition tables in the Android build system, simply add
the path to a .bpt file to the BOARD_BPT_INPUT_FILES variable.

BOARD_BPT_INPUT_FILES += "hardware/bsp/vendor/soc/board/board-specific.bpt"

The variable BOARD_BPT_DISK_SIZE can be used to specify or override
the disk size, for example:

BOARD_BPT_DISK_SIZE := "10 GiB"

Additional arguments to 'bpttool make_table' can be specified in the
variable BOARD_BPT_MAKE_TABLE_ARGS.

If BOARD_BPT_INPUT_FILES is set, the build system generates two files

partition-table.img
partition-table.bpt

in ${ANDROID_PRODUCT_OUT} using 'bpttool make_table'. The former is
the binary partition tables generated using bptool's --output_gpt
option and the latter is a JSON file generated using the --output_json
option. These files will also be put in the IMAGES/ directory of
target-files.zip when running 'm dist'.

BUG=27831397
TEST=Manually tested.

Change-Id: Iedd15354afb2dd483dcb9bc001360b2a37fd6dc0
/build/make/tools/releasetools/add_img_to_target_files.py
d995f4b04df46d9e9ac1be8d58ca961e94b783d1 29-Jan-2016 David Zeuthen <zeuthen@google.com> Add support for Brillo Verified Boot.

The following variables are introduced

BOARD_BVB_ENABLE: can be set to true to build boot.img and system.img
files compatible with Brillo Verfied Boot.

BOARD_BVB_ROLLBACK_INDEX: can be set to an integer to use for the
rollback index.

BOARD_BVB_KEY_PATH, BOARD_BVB_ALGORITHM: If set, the former must be a
path to the private key used to sign the boot image and the latter must
be the algorithm to use. If unset, a test-key stored in the tree will
be used.

BOARD_BVB_MAKE_BOOT_IMAGE_ARGS: Extra options to pass to 'bvbtool
make_boot_image'.

BOARD_BVB_SIGN_BOOT_IMAGE_ARGS: Extra options to pass to 'bvbtool
sign_boot_image'.

BOARD_BVB_ADD_IMAGE_HASHES_ARGS: Extra options to pass to 'bvbtool
add_image_hashes'.

BOARD_CUSTOM_BVBTOOL: Can be set to specify what bvbtool program to
use.

The existing BOARD_KERNEL_CMDLINE variable is also used, as are existing
kernel and initrd-related variables. Therefore, simply adding

BOARD_BVB_ENABLE := true

to an existing Makefile should do the trick.

Bug: 26185038
TEST=Added 'BOARD_BVB_ENABLE := true' to hardware/bsp/intel/soc/edison/soc.mk
and built an image and then ran bvbtool's info_boot_image and
info_image_hashes commands on the resulting boot.img and system.img
files and verified that the information was correct. Also ran 'm dist'
and verified that the boot.img and system.img files in the resulting
target_files.zip file had similar information.

Change-Id: I08045ed8b0cbddc7c3acdd3a6f2c4bb75cb44bbc
/build/make/tools/releasetools/add_img_to_target_files.py
a0421cd1bd2398589f2292dfd92ba802110e98e1 17-Nov-2015 Tao Bao <tbao@google.com> releasetools: Pack updatable images into IMAGES/ for A/B update.

Vendor-specific images (radio, bootloader and etc) used to stay in
RADIO/ in target_files zip. A/B updater expects them to be available
under IMAGES/. Make a copy for such images when calling
add_img_to_target_files.py.

We cannot move them directly from RADIO/ to IMAGES/, because we will
delete everything under IMAGES/ when signing for release.

Bug: 25674625
Change-Id: I977c879d0ff7e45c83b3f5c63844a5b135caa383
/build/make/tools/releasetools/add_img_to_target_files.py
e5eb4567d408808873d7193fcaf7bfea859ea725 29-Oct-2015 Tao Bao <tbao@google.com> Merge "Honor TARGET_NO_RECOVERY flag."
am: c448e91c3d

* commit 'c448e91c3d3d095f8f200c9925f7db2ad525132f':
Honor TARGET_NO_RECOVERY flag.
db45efa64764c1de5c007384ab172ad817e1d295 28-Oct-2015 Tao Bao <tbao@google.com> Honor TARGET_NO_RECOVERY flag.

Don't generate recovery.img when calling 'make dist' if
TARGET_NO_RECOVERY is set. The build system passes the flag to the
packaging script which then generates recovery.img conditionally.

Bug: 25329471
Change-Id: Ifbc999300d5c31e897878f81e231ae7dd2aca660
/build/make/tools/releasetools/add_img_to_target_files.py
128f01cf5852bf06945e07cca543de936c555493 01-Oct-2015 Tao Bao <tbao@google.com> am ce9635ec: am 2124d7e1: Merge "Only use a fixed timestamp when packaging."

* commit 'ce9635ec7ad6bcc6b9bc74136edb91847fe9e4ff':
Only use a fixed timestamp when packaging.
822f5840c0f498e33829a0a00f383d9be3a7e913 01-Oct-2015 Tao Bao <tbao@google.com> Only use a fixed timestamp when packaging.

[1] changed to use a fixed timestamp for all the generated images
(either the one under $ANDROID_PRODUCT_OUT/ or the one added into the
target_files zip). It makes 'adb sync' after 'fastboot flashall' to
resync all the files. This CL changes to use a fixed timestamp only when
packaging into the target_files zip.

[1]: commit 052ae3542be93d30108e742c5c21d5c45d9b7cf8

Bug: 24377993
Bug: 24536411
Change-Id: I209318966109fd4902468dfe96caf777464f9fe1
/build/make/tools/releasetools/add_img_to_target_files.py
12ab99be0985cd22890e8f75f5e9f95aa1e2c981 17-Sep-2015 Baligh Uddin <baligh@google.com> am aa3d37a1: am 5790d54a: am 59f4ff10: Add verity_signer and verity_key flags to add_img_to_target_files.

* commit 'aa3d37a1d704ab9204de7d76dca784c9b17bd2ee':
Add verity_signer and verity_key flags to add_img_to_target_files.
59f4ff109d7da6d608cb6b1248a4403b13d8b2bc 17-Sep-2015 Baligh Uddin <baligh@google.com> Add verity_signer and verity_key flags to add_img_to_target_files.

The signing process requires the boot and recovery images be signed
by CROS-Signer, which is done after a signed_target_files.zip is
available. Once the boot/recovery images are signed, we need
to insert it back into signed_target_files.zip and regenerate the
system.map and verity tree. The script (add_img_to_target_files) does
this operation and needs to be aware of verity specific flags.

Bug: 23831896
Change-Id: Id24e878161052c768b74da1231b97eb0574b4c8b
/build/make/tools/releasetools/add_img_to_target_files.py
84e7568b1fb6264c8a0b8e38ef8ed4ec78325061 19-Jul-2015 Tao Bao <tbao@google.com> Override properties that point to out/ directory.

A few properties are stored as links to the files in the out/
directory, which are no longer available when (re)packing from
target_files zip. Redirect those properties to the actual files in
the unzipped directory when repacking.

Change-Id: I18e930cbea224ab9c6db8d4e721b1c266a671db6
/build/make/tools/releasetools/add_img_to_target_files.py
2c15d9eefe977db63d7561bde326f24fab31653d 09-Jul-2015 Tao Bao <tbao@google.com> Pack file_contexts into target_files zip.

file_contexts (specified by SELINUX_FC) is needed both when building
and (re)packaging. We used to use the copy in out/ when building, and
looked for the copy in BOOT/RAMDISK/ when packaging from target_files
zip. With system_root_image enabled, the file_contexts needed for
building and packaging might be different from the one on device. So
we explicitly pack the file as META/file_contexts in target_files zip.

Also refactor out the overriding of selinux_fc property into
common.LoadInfoDict().

Change-Id: I94f9ea6671b3792c12c1c21573840743d63da39a
(cherry picked from commit aa7318c3849095aeb3bea00efbf303c0c40a089d)
/build/make/tools/releasetools/add_img_to_target_files.py
2a04839aecb1cbdcf5ca9e76ebfce9448eec0e13 25-Jun-2015 Ying Wang <wangying@google.com> Create userdata.img with real data when SANITIZE_TARGET=address.

Bug: 21785137
Change-Id: Ie0c36988759fe07419ad29bab5a71cdd0d992d2a
/build/make/tools/releasetools/add_img_to_target_files.py
f3282b4a7fda46dfb546f2822e0f2081b4ced7ff 01-Apr-2015 Tao Bao <tbao@google.com> Wrap zipfile.write(), writestr() and close()

In order to work around the zip 2GiB limit, we need to wrap the related
functions in zipfile. Calls to those functions should always be replaced
with calls to the wrappers instead.

Bug: 18015246
Change-Id: I499574cee51ec4804bc10cbefe0b17940afed918
(cherry picked from commit 2ed665a033c587b276b1615516e5354e2ace47cd)
/build/make/tools/releasetools/add_img_to_target_files.py
2ed665a033c587b276b1615516e5354e2ace47cd 01-Apr-2015 Tao Bao <tbao@google.com> Wrap zipfile.write(), writestr() and close()

In order to work around the zip 2GiB limit, we need to wrap the related
functions in zipfile. Calls to those functions should always be replaced
with calls to the wrappers instead.

Bug: 18015246
Change-Id: Ice494371ca6654e88ded2ae0eb680f51082effcb
/build/make/tools/releasetools/add_img_to_target_files.py
99e22a57d0b186cb853d757a058318a8be78918b 27-Mar-2015 Dan Albert <danalbert@google.com> Merge "Make releasetools pylint clean."
a2292c94d1d1c1759fee6ffce28b52fae91035b6 25-Mar-2015 Ying Wang <wangying@google.com> Support to build image of root file system with /system and ramdisk combined.

Added support to build system.img that combines contents of /system and
the ramdisk, and can be mounted at the root of the file system.
To enable this feature, define BoardConfig.mk variable:
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true

Ideally we would just change TARGET_OUT (the path of the staging system
directory) to under TARGET_ROOT_OUT. But at this point many places in
the build system assume TARGET_OUT is independent of TARGET_ROOT_OUT and
we can't make it easily configurable.
Instead this implementation takes the least intrusive approach:
We don't change TARGET_OUT or TARGET_ROOT_OUT. We just assemble a
temporary staging directory that contains contents of both TARGET_OUT
and TARGET_ROOT_OUT, in build_image.BuildImage() of
tools/releasetools/build_image.py.
When build_image.py is directly called from the makefile, we pass in the
parameters from the global dictionary; when build_image.BuildImage() is
called from add_img_to_target_files.py, we need to override values to
point to files extracted from the target_files zip file.
We need to combine the fs_config files of both /system and ramdisk,
when fs_config is enabled.

Also this change refactored build_image.BuildImage() by moving the extra
parameters to the image property dictionary.

(cherry-picked from commit 0eabd4f2c5fe704d3c3212b45b80775a35b55b1b)

Bug:19868522
Change-Id: Iafc467a0e3427b0d6ad3b575abcc98ddcc9ea0f1
/build/make/tools/releasetools/add_img_to_target_files.py
8b72aefb5a8ed4da28c6f83854e8babf53b9cb53 24-Mar-2015 Dan Albert <danalbert@google.com> Make releasetools pylint clean.

This caught a few bugs/syntax errors (a few character classes were not
escaped properly in regex patterns, some indentation was illegal,
etc).

Change-Id: I50637607524e68c4fb9cad7167f58a46b8d26b2c
/build/make/tools/releasetools/add_img_to_target_files.py
8e0178d41b9eeb6754eda07292d78762e3169140 28-Jan-2015 Dan Albert <danalbert@google.com> Allow system images larger than 2GiB.

Python 2.7's zipfile implementation wrongly thinks that zip64 is
required for files larger than 2GiB. We can work around this by
adjusting their limit. Note that `zipfile.writestr()` will not work
for strings larger than 2GiB. The Python interpreter sometimes rejects
strings that large (though it isn't clear to me exactly what
circumstances cause this). `zipfile.write()` must be used directly to
work around this.

This mess can be avoided if we port to python3.

The bug (b/19364241) in original commit has been fixed.

Bug: 18015246
Bug: 19364241
Bug: 19839468

(cherry picked from commit cd082d4bfe917b2e6b97436839cbbbc67c733c83)

Change-Id: I7b5cc310e0a9ba894533b53cb998afd5ce96d8c6
/build/make/tools/releasetools/add_img_to_target_files.py
2de68bbbf49473c09d434a75e669345392e03240 13-Feb-2015 Justin Harrison <astyrrian@google.com> Revert "Allow system images larger than 2GiB."

This reverts commit cd082d4bfe917b2e6b97436839cbbbc67c733c83.

Change-Id: Ie63e1ba70d907d2849164871bc7ec71c245f7af9
/build/make/tools/releasetools/add_img_to_target_files.py
cd082d4bfe917b2e6b97436839cbbbc67c733c83 28-Jan-2015 Dan Albert <danalbert@google.com> Allow system images larger than 2GiB.

Python 2.7's zipfile implementation wrongly thinks that zip64 is
required for files larger than 2GiB. We can work around this by
adjusting their limit. Note that `zipfile.writestr()` will not work
for strings larger than 2GiB. The Python interpreter sometimes rejects
strings that large (though it isn't clear to me exactly what
circumstances cause this). `zipfile.write()` must be used directly to
work around this.

This mess can be avoided if we port to python3.

Bug: 18015246
Change-Id: I8a476d99c5efdef6ea408373b706e9fbd3a798be
/build/make/tools/releasetools/add_img_to_target_files.py
2e0d8fcf08475cc1aac5ca4f47cd3328a9d8c083 14-Nov-2014 Michael Runge <mrunge@google.com> Allow images to be readded to target-files

There may be cases where various partitions were
modified (such as extra signing of boot/recovery)
which require the system partition to be regenerated
with a new recovery patch script. Allow a request
for the recovery patch to be rebuilt, and for
missing images to be readded to the existing images.

Change-Id: Ie93c5bc1161a0d5002002dca23e07742ce2ba468
/build/make/tools/releasetools/add_img_to_target_files.py
5f9c28cad4cc0b499837e91a8eea344c26264e32 22-Aug-2014 Doug Zongker <dougz@google.com> fix build

Change-Id: I1e503406129343bbfddacc1150c81e403b47778c
/build/make/tools/releasetools/add_img_to_target_files.py
fc44a515d46e6f4d5eaa0d32659b1cf3b9492305 26-Aug-2014 Doug Zongker <dougz@google.com> new block OTA system tools

Replace the xdelta/xz-based block OTA generation with a new system
based on the existing bsdiff/imgdiff tools.

Bug: 16984795
Change-Id: Ia9732516ffdfc12be86260b2cc4b1dd2d210e886
/build/make/tools/releasetools/add_img_to_target_files.py
f21cb5a2198b843fe1c8e9577cc2ad61e0f5cfb4 12-Aug-2014 Doug Zongker <dougz@google.com> save file block allocations in target_files

make_ext4fs can now output a file listing the blocks used for each
file in the image. Request this file and save it in the target_files;
it will be used for future improvements to block OTAs.

Bug: 16984795
Change-Id: Id1e60465e3b5a9d126a7934b4d089cf34d8fec44
/build/make/tools/releasetools/add_img_to_target_files.py
3c84f569487c4e59baa332be33b5430fdefb76b3 31-Jul-2014 Doug Zongker <dougz@google.com> store images in target-files

Store sparse images in the target-files, and use those (when they're
available) for building block OTAs.

- New script add_img_to_target_files is added to make the images and
add them to the IMAGES/ subdir in the target-files. It gets run
from the Makefile when building a target-files.

- img_from_target_files becomes mostly vestigial: it creates the
img.zip by just copying the images out of the target-files. (It
still knows how to build images for use on older target-files.)

- ota_from_target_files uses images from the target-files in
preference to rebuilding images from the source files.

- sign_apk_target_files builds images and includes them in its output
target files (even if the input target-files didn't have them).

Bug: 16488065
Change-Id: I444e0d722d636978209467ffc01750a585c6db75
/build/make/tools/releasetools/add_img_to_target_files.py