Commit graph

6247 commits

Author SHA1 Message Date
Kiyoung Kim
7cbeda728d Split merge_target_files function
Split merge_target_files function into several steps, so we can increate
readability and add conditional flows for other *SSI mixed build with less effort

Test: m -j & atest passed
Change-Id: I558f9dd5bca31b132a09cb36d9dfcd30c92efbc9
2019-07-08 12:13:05 +09:00
Tao Bao
48a2feb670 Change the condition for building super_empty.img.
This CL changes the condition for building super_empty.img from
PRODUCT_BUILD_SUPER_PARTITION to PRODUCT_USE_DYNAMIC_PARTITIONS, as a
follow-up to the change in [1].

With the CL in [1], it skips building super.img and super_empty.img both
when turning off PRODUCT_BUILD_SUPER_PARTITION. However, the latter
should be mandatory whenever dynamic partitions is enabled. Because
fastboot relies on this file to properly flash dynamic partitions. Plus,
the cost for building super_empty.img is much lower than the one for
super.img.

As part of the change, it'll write group info into target_files when
building with PRODUCT_BUILD_SUPER_PARTITION == false. It's the work for
target_files merging script to determine the values to be picked up. The
current logic in merge_target_files.py always uses the one from vendor
target_files. This CL adds a testcase to ensure the behavior.

[1] https://android-review.googlesource.com/c/platform/build/+/928756

Bug: 135752763
Test: `m dist` with a target that sets PRODUCT_BUILD_SUPER_PARTITION to
      false. Check the built artifacts contain super_empty.img. Verify
      that the build can be flashed properly.
Change-Id: I277f087eab45663a6c3b33333d16e9e576c1c25c
2019-06-28 14:23:53 -07:00
Tao Bao
63cf1326da Merge "releasetools: Prefer the avbtool specified in target_files." 2019-06-28 01:18:21 +00:00
Tao Bao
e4f07795e4 Merge "releasetools: Make additional modules Python 3 compatible." 2019-06-27 23:52:50 +00:00
Tao Bao
f6e8d46e2f Merge "releasetools: Clean up check_target_files_signatures.py." 2019-06-27 21:36:14 +00:00
Tao Bao
2a917796b5 Merge "releasetools: Add sanity test for sign_apex." 2019-06-27 17:35:29 +00:00
Tao Bao
a67e12d66f releasetools: Clean up check_target_files_signatures.py.
And make it Python 3 compatibile.

Bug: 131631303
Test: python check_target_files_signatures.py target-files.zip
Test: python3 check_target_files_signatures.py target-files.zip
Change-Id: I38e868c3124387f5543ad68c92c75917e40b7d8f
2019-06-27 10:24:10 -07:00
Tao Bao
a370545a2c releasetools: Make additional modules Python 3 compatible.
Bug: 131631303
Test: `python -m unittest test_sign_target_files_apks`
Test: `python3 -m unittest test_sign_target_files_apks`
Test: `python -m unittest test_add_img_to_target_files`
Test: `python3 -m unittest test_add_img_to_target_files`
Test: `python -m unittest test_ota_from_target_files`
Test: `python3 -m unittest test_ota_from_target_files`
Test: `python -m unittest test_validate_target_files`
Test: `python3 -m unittest test_validate_target_files`
Test: Run `python3 ota_from_target_files.py` to generate an OTA.
Test: Run `python3 sign_target_files_apks.py` to sign a target_files.
Change-Id: I56b45bbcbf7aa83e690785a9640c0212e45d12d8
2019-06-27 09:05:48 -07:00
Kiyoung Kim
fc195fee44 Merge "Create common.LoadDictionaryFromFile" 2019-06-27 00:27:49 +00:00
Tao Bao
1ac886e181 releasetools: Prefer the avbtool specified in target_files.
This allows a consistent logic in using the avbtool which could be
board-specific.

Test: `atest releasetools_test`
Test: Run sign_target_files_apks.py on a target_files.zip.
Change-Id: I8cd93b8e71146985734f85c31f4662f5e2e9534c
2019-06-26 17:18:48 -07:00
Tao Bao
c9c1b864ba releasetools: Add sanity test for sign_apex.
This ensures a matching interface between sign_apex and apex_utils.

The test apex `testdata/foo.apex` is generated by running
`system/apex/apexer/runtests.sh`.

Test: python -m unittest test_sign_apex
Test: atest releasetools_test
Change-Id: I7c14b1df2a3038ad206aa3e5aac084c47baaa00b
2019-06-26 17:17:09 -07:00
Tao Bao
59cf0c59de releasetools: Clean up additional modules for Python 3 compatibility.
It also addresses a few linter warnings (mostly regarding indentation).

Bug: 131631303
Test: TreeHugger
Test: `python -m unittest test_ota_from_target_files`
Test: `python3 -m unittest test_ota_from_target_files`
Test: `python build/make/tools/releasetools/check_ota_package_signature.py
           build/make/target/product/security/testkey.x509.pem
           test-keys-signed-ota.zip`
Test: `python3 build/make/tools/releasetools/check_ota_package_signature.py
           build/make/target/product/security/testkey.x509.pem
           test-keys-signed-ota.zip`
Change-Id: I11a745dfec052081ab0282bb028dc27debf71f57
2019-06-26 00:15:53 -07:00
Kiyoung Kim
ebe7c9c92f Create common.LoadDictionaryFromFile
There are some places defining same file open function and use
common.LoadDictionaryFromLines. This commit creates
LoadDictionaryFromFile to reduce some code redundancy.

Test: m -j & atest passed
Change-Id: I6a3fa48693095937f8c79ce6f3c110b6862a1967
2019-06-26 13:09:52 +09:00
Tao Bao
58abe77060 Merge "releasetools: Make apex_utils Python 3 compatible." 2019-06-25 22:34:39 +00:00
Elliott Hughes
2fdfc4e439 Merge "Don't use tar's -p with -rf, where it makes no sense." 2019-06-25 21:28:22 +00:00
Chih-hung Hsieh
7b3a8fb7ec Merge "Fix pylint warnings and now prefer python3" 2019-06-25 18:32:26 +00:00
Tao Bao
86b529a23e releasetools: Make apex_utils Python 3 compatible.
In order to get a Python 2 and 3 compatible re-raise behavior, this CL
removes the stack traceback for the lines within apex_util module (i.e.
sys.exc_info()[2]). It's not a big loss in practice, since we only have
one line within the try-except block (`common.RunAndCheckOutput()`)
that's no longer reported in the traceback.

Using `six` module could better solve this, but only after building
releasetools as python_binary_host modules where we can properly handle
the module dependency.

Bug: 131631303
Test: TreeHugger
Test: `python -m unittest test_apex_utils`
Test: `python3 -m unittest test_apex_utils`
Change-Id: I0c5a72ec9fad5ff9d8c9c94d29e813e433ec2921
2019-06-25 11:10:55 -07:00
Elliott Hughes
b82ef911f9 Don't use tar's -p with -rf, where it makes no sense.
-p only applies to tar invocations that cause extraction, but -rf is
just appending to a tar file.

toybox tar doesn't have -p, and it doesn't seem worth implementing if
this is our only "user".

Test: treehugger
Change-Id: I025c496b04cb57cb31ba81fd516fd40b158bc06b
2019-06-25 09:07:41 -07:00
Tao Bao
9e893c3cfd releasetools: Make verity_utils Python 3 compatible.
Bug: 131631303
Test: TreeHugger
Test: `python -m unittest test_verity_utils`
Test: `python3 -m unittest test_verity_utils`
Change-Id: Idc7776be2cf78fbdb0b3ba87231d05013da8d3ac
2019-06-24 21:07:19 -07:00
Tao Bao
da30cfae96 releasetools: Make common Python 3 compatible.
Bug: 131631303
Test: TreeHugger
Test: `python -m unittest test_common`
Test: `python3 -m unittest test_common`
Change-Id: I409fe30a5d71975c1d7b66e5e749843de530f1f9
2019-06-24 21:02:12 -07:00
Chih-Hung Hsieh
9018ea49d8 Fix pylint warnings and now prefer python3
* Read/write warning messages as utf-8 strings.
* No more embedded raw utf-8 code in file.

Test: ./warn.py --csvpath warnings.csv build.log > warnings.html
Change-Id: Ie51700721a32bede1d3b250f4a42fd8facd6af75
2019-06-24 15:24:39 -07:00
Tao Bao
338c1b7e90 releasetools: Remove some legacy paths for prop rewrites.
sign_target_files_apks.py only needs to take care of the current
release. The legacy paths of ODM/build.prop, VENDOR/odm/build.prop, and
BOOT/RAMDISK/default.prop no longer exist in the target_files.zip from
master.

The other two cases of ROOT/default.prop and
RECOVERY/RAMDISK/default.prop are still kept in the code, as they will
still exist (as symlink or conditionally).

Test: Run sign_target_files_apks.py against
      aosp_taimen-target_files.zip. Check the rewritten prop files.
Test: `python -m unittest test_sign_target_files_apks`
Change-Id: I5e70bc2ccc0f3dcf0eace0718c59a3b0f89a9ff4
2019-06-21 10:26:15 -07:00
Tao Bao
b813120af1 releasetools: Make blockimgdiff Python 3 compatible.
Bug: 131631303
Test: `python -m unittest test_blockimgdiff`
Test: `python3 -m unittest test_blockimgdiff`
Change-Id: I8cf072ca4af6a525bc675cba0be998ff7be7f4f1
2019-06-20 14:30:30 -07:00
Tao Bao
1f1aafa30d Merge "releasetools: Make rangelib Python 3 compatibile." 2019-06-20 14:51:21 +00:00
Tao Bao
d660c8d8f3 releasetools: Make rangelib Python 3 compatibile.
Bug: 131631303
Test: `python -m unittest test_rangelib`
Test: `python3 -m unittest test_rangelib`
Change-Id: Ia8e26623d5967f2eea003252ee56b861350d626b
2019-06-19 10:30:34 -07:00
Tao Bao
c1a1ec30df releasetools: Make common.ZipWriteStr Python 3 compatible.
Python 2 and 3 behave differently when calling ZipFile.writestr() with
zinfo.external_attr being 0. Python 3 uses `0o600 << 16` as the value
for such a case (since
18ee29d0b8),
which seems to make more sense. Otherwise the entry will end up with
0o000 as the permission bits. This CL updates common.ZipWriteStr to
follow the logic in Python 3, in order to get consistent behavior
between using the two versions.

Bug: 131631303
Test: `python -m unittest test_common.CommonZipTest`
Test: `python3 -m unittest test_common.CommonZipTest`
Change-Id: If8429855d922ef1ad76591f703215a0ce5089f0f
2019-06-18 23:53:53 -07:00
Tao Bao
aadc9b9159 Merge "releasetools: Update partitions in deterministic order." 2019-06-18 22:20:26 +00:00
Tao Bao
f1113e97ae releasetools: Update partitions in deterministic order.
Previously it was using regular dict.

Test: python -m unittest test_common.DynamicPartitionsDifferenceTest
Change-Id: If108a4512aeaf9d3c8775c030cad6e44342b9d3d
2019-06-18 12:14:32 -07:00
Tom Cherry
de18e892d3 Update fs_config documentation
While searching for some fs_config related symbols, I ran across this
being out of date, so update it.

The new documentation defers to the help section of the underlying
script more to hopefully avoid this in the future.

Test: n/a
Change-Id: I94893cbb29b8d7e81963a12e3f8316ac3f41b7ae
2019-06-17 13:31:28 -07:00
Treehugger Robot
87ebb3013f Merge "Allows skipping building the super images for partial builds." 2019-06-14 21:42:33 +00:00
Daniel Norman
0bf940cace Allows skipping building the super images for partial builds.
Previously, setting PRODUCT_BUILD_SUPER_PARTITION to false for a partial
build (with PRODUCT_USE_DYNAMIC_PARTITIONS == true) would fail to
include necessary keys in misc_info.txt that are required when merging
two partial builds to create a dynamic-partition-enabled mixed build.

This change ensures these necessary keys are included even when
PRODUCT_BUILD_SUPER_PARTITION is false. Setting
PRODUCT_BUILD_SUPER_PARTITION to false causes partial builds to skip
building super.img and super_empty.img, instead relying on these images
to come from the final merged build.

Bug: 134764140
Test: Building & booting a dynamic-partition-enabled mixed build, and
inspecting partial builds' logs / out folder to ensure that
super.img/super_empty.img were not created.

Change-Id: I99431a9a342e9b0617510e250597f3024ef39322
2019-06-14 11:42:45 -07:00
Tao Bao
cd951b2bdb releasetools: No-op change to use common.AVB_VBMETA_PARTITIONS.
common.AVB_VBMETA_PARTITIONS was recently added (commit
08c190fc89) for the same purpose.

Test: TreeHugger
Change-Id: I65572d54c22a753fdef80677377fcc9b684ee16f
2019-06-10 15:29:19 -07:00
Chris Gross
eab4f0e2e9 Add a logging statement after soong ZIP runs in the
merge_target_files.py step.

Bug: 134681035
Test: Built a merged build and ensured that the new timestamp was
visible in the log.

Change-Id: Ia6bbda48c7f57afdb6482253eaf0b3b0ea067468
2019-06-07 13:15:52 -07:00
Daniel Norman
6728fe850e Merge "Renames system to framework and other to vendor." 2019-06-06 21:14:14 +00:00
Daniel Norman
d5d70ea555 Renames system to framework and other to vendor.
Also fixes small nit from previous change to write_sorted_data().

Bug: 132788610
Test: python -m unittest test_merge_target_files
Test: Creating and booting a merged build.
Change-Id: I3dc43a4fe55b86b436dec08feb5d70096d38de36
2019-06-05 16:47:15 -07:00
Tao Bao
4978fa99d1 Rebuild recovery-from-boot patch when calling add_img_to_target_files.
When using Verified Boot 2.0, releasetools specifies a salt value based
on build fingerprint, so that to give idempotent images.

However, the change that removed static `ro.build.fingerprint` [1] broke
the behavior, as common.LoadInfoDict still relies on fingerprints.
Without a fixed salt, the first call to make_recovery_patch.py and the
second one (which writes IMAGES/{boot,recovery}.img) will see different
images, which leads to install-recovery.sh failure.

Note that currently there's a dependency that requires getting bootable
images through two separate calls. make_recovery_patch.py has to happen
first to get (placeholder) files in the system image. We then generate
canned fs_config files, and finally use add_img_to_target_files.py to
write the images.

This CL adds a quick workaround to force rebuilding the
recovery-from-boot patch while calling add_img_to_target_files.py.

[1] https://android-review.googlesource.com/c/platform/build/+/892933

Bug: 134123803
Bug: 134525174
Test: TreeHugger
Test: Build a non-A/B target that uses AVB. Run validate_target_files.py
      on the generated target_files.zip.
Change-Id: I5859e30be63bfd54398cf41fd2d907f15285f560
2019-06-04 22:44:45 -07:00
Tao Bao
08c190fc89 releasetools: Allow verifying chained vbmeta partitions.
Chained vbmeta partitions (vbmeta_system, vbmeta_vendor) were added to
support dynamic partitions. validate_target_files.py misses the logic in
handling such partitions.

Bug: 132882632
Test: Run validate_target_files.py on a target_files.zip that uses
      chained vbmeta_system partition.
Change-Id: Id06c575d13d5e9cc1b621f485ceb75d3e354c39f
Merged-In: Id06c575d13d5e9cc1b621f485ceb75d3e354c39f
(cherry picked from commit 814b14b3f7)
2019-06-04 12:49:41 -07:00
Treehugger Robot
206ef1f4fb Merge "Adds validation check that certain partitions come from a single build." 2019-06-03 14:24:14 +00:00
Daniel Norman
edf124780f Adds validation check that certain partitions come from a single build.
This is to prevent a user from accidentally including files from the
wrong build. For example, adding any SYSTEM/ line to other_item_list
while keeping SYSTEM/* in system_item_list would cause the other build
to introduce an extra or changed file in the system image.

Bug: 132730710
Test: python -m unittest test_merge_target_files
Change-Id: Ic1178cdc9b991114f293ff3f2b4e6054e06647c6
2019-06-01 04:39:46 +00:00
Felix
8453f02c65 fs_config: Fix cases without vendor/oem partition
If the device has neither an OEM nor a vendor partiton,
$PRIVATE_PARTITION_LIST will be empty, causing the fsconfig tool to fail
because the "--all-partitions" argument will be empty.

Quote the comma-substituted "$(PRIVATE_PARTITION_LIST)" - which may be
empty - to appease argparse, which will then populate "_all_partitions"
with an empty "str" object.

Checking _all_partitions against None is superfluous since either
argparse will catch the empty argument and fail early, or the argument
will be a string, in which case it will not be None.

Signed-off-by: Felix <google@ix5.org>
Change-Id: I236e30445b303b4945467b5dc4387d54b5d984f9
2019-05-29 22:24:05 +02:00
Daniel Norman
c9fc1120c1 Merge "Adds image-specific selinux_fc props to allow different file_contexts." 2019-05-23 23:42:13 +00:00
Daniel Norman
72c626f017 Adds image-specific selinux_fc props to allow different file_contexts.
This enables mixed builds to use the file_contexts.bin from the system
build when regenerating images that come from system target files, and
similarly for file_contexts.bin from the other build when regenerating
images from other target files.

In monolithic (non-mixed) builds all image-specific selinux_fc props
point to the same file_contexts.

Bug: 132108151
Test: Built and booted mixed build devices.
Change-Id: Id51ed6d96ea6337879f1ab21d47c93c67bc25312
2019-05-23 11:21:02 -07:00
Bowgo Tsai
71a4d5cdd5 Moving /odm/build.prop to /odm/etc/buid.prop
In device root directory, we have the following symlinks:
  - /odm/app -> /vendor/odm/app
  - /odm/bin -> /vendor/odm/bin
  - /odm/etc -> /vendor/odm/etc
  ...

This allows the Generic System Image (GSI) to be used on both devices:
  1) Has a physical odm partition, where those symlink will be hidden
     when /odm is used as the mount point
  2) Has no physical odm partition and fallback to /vendor/odm/.

We can't just have the symlink /odm -> /vendor/odm, because the former
devices won't have /vendor/odm directory, which leads to mount failure
when the mount point /odm is resolved to /vendor/odm.

The existing /vendor/odm/build.prop won't be loaded in the latter
devices, because there is no symlink:
    - /odm/build.prop -> /vendor/odm/build.prop.

Note that init blocks reading through direct symlinks (O_NOFOLLOW) so
the above symlink won't work either. This CL moves the odm build.prop
to /odm/etc/build.prop for init to load it (symlinks in earlier
components of the path will still be followed by O_NOFOLLOW).

Bug: 132128501
Test: boot a device and checks /odm/etc/build.prop is loaded
Test: make dist with an odm.img, checks $OUT/odm/etc/build.prop is loaded
Change-Id: I6f88763db755c9ec6068bfdd9cee81c19d72e9d7
Merged-In: I6f88763db755c9ec6068bfdd9cee81c19d72e9d7
(cherry picked from commit 6c62884000)
2019-05-22 14:04:39 +08:00
Chris Gross
fabf50a577 Add merging of apexkeys and apkcerts metadata
Bug: 131437873
Test: Built system-only and vendor builds for merge. Compared
resulting apkcertx and apexkeys text files to that of a monolithic
build,
Test: Created colliding entries in both apexkeys and apkcerts text
files and ensure the script exited with an appropriate error message.
Test: Created unit tests to cover both non-colliding and colliding
entries
Change-Id: I6e42ce682ffa9059344e8cd63ba3a720c1f93452
2019-05-20 18:35:22 +00:00
Tao Bao
bc7e3f98f4 Merge "Add sign_apex.py that signs a given APEX file." 2019-05-13 22:47:24 +00:00
Tao Bao
e7354ba447 Add sign_apex.py that signs a given APEX file.
This CL moves SignApex() from sign_target_files_apks into apex_utils,
and adds sign_apex that allows signing a standalone APEX file directly.

Test: Run the following command and check the output file.
$ build/make/tools/releasetools/sign_apex.py \
     -v \
     --container_key \
         build/make/target/product/security/testkey.x509.pem \
     --payload_key external/avb/test/data/testkey_rsa4096.pem \
     --payload_extra_args \
         "--signing_helper_with_files ./signing-helper.sh" \
     foo.apex \
     signed-foo.apex
Test: Run sign_target_files_apks.py on crosshatch target_files.zip.
Change-Id: I4b2422fd5cb1c60a3aa94511475e2a0e5b1666ca
2019-05-13 12:41:26 -07:00
Tao Bao
1dac1d4164 releasetools: Unzip all files when generating image archive.
Commit 7df64c3e starts to call common.LoadInfoDict() when generating
image archive, which reads additional files under BOOT/, RECOVERY/ and
ROOT/. Unzip everything from the target_files.zip.

Bug: 132456827
Test: Run img_from_target_files.py on previously failing
      target_files.zip.
Change-Id: I22ee57c4f765bee9494478bf115b1581877401f4
2019-05-10 15:57:20 -07:00
Xin Li
8a39705283 Merge "DO NOT MERGE - Merge Pie Bonito/Sargo into master." 2019-05-09 22:05:51 +00:00
Daniel Norman
714bd12861 Fixes typo when calling process_dynamic_partitions_info_txt.
Test: Running merge_target_files.py
Change-Id: Ieddfbfe524824844fc12cc10347f667332149f7c
2019-05-08 16:20:02 -07:00
Tao Bao
df24a30b5d Merge "releasetools: Update the comments regarding selinux_fc."
am: 45f74b104b

Change-Id: I570d584f8eadcfacfc4a91470137e2c4f080d9df
2019-05-08 15:14:35 -07:00