Commit graph

75 commits

Author SHA1 Message Date
Inseob Kim
135c1f144f Move fsverity metadata generation to Makefile
build_image.py has been handling fsverity metadata generation in the
packing step, but it can cause issues because the metadata files are
missing in the $OUT directory, and they only exist in result system.img.
This change moves the generation logic into Makefile, and makes the
metadata tracked by ninja graph.

Bug: 206326351
Test: PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA := true and build
Change-Id: I1f910d8ac6e2cc3c54f35916871733c632f18e44
2022-01-07 09:16:42 +09:00
Inseob Kim
2d03493341 Add fsverity_metadata_generator helper binary
Making this a host tool will help users generate their own fsverity
metadata easily.

Bug: 205987437
Test: m fsverity_metadata_generator and run it
Change-Id: Iafd228815a74d298d87ca1466c6909c0d24c5874
2021-12-15 09:41:29 +09:00
Inseob Kim
f69346e0a8 Add fsverity digest manifest
fsverity digest manifest stores a map from files to fsverity digests.
The manifest is installed as a serialized protobuf file, to a signed apk
system/etc/security/fsverity/BuildManifest.apk.

Bug: 193113311
Test: build with PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA := true
Change-Id: I55fc10400206b8ce0d5f198faea08fe3930b362c
2021-11-11 11:19:44 +00:00
Inseob Kim
9cda397948 Implement fsverity metadata generator
Using fsverity tool, fsverity metadata for specific artifacts in system
mage can be generated. Users can do that by setting a makefile variable
PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA to true.

If set to true, the following artifacts will be signed.

- system/framework/*.jar
- system/framework/oat/<arch>/*.{oat,vdex,art}
- system/etc/boot-image.prof
- system/etc/dirty-image-objects

One fsverity metadata container file per one input file will be
generated in system.img, with a suffix ".fsv_meta". e.g. a container
file for "system/framework/foo.jar" will be
"system/framework/foo.jar.fsv_meta".

Bug: 193113311
Test: build with PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA := true
Change-Id: Ib70d591a72d23286b5debcb05fbad799dfd79b94
2021-11-11 17:30:19 +09:00
Cole Faust
c76931fe8b Use python 3 for release tools
The release tools have already been updated in prior cls to
support python 3. To test this, I added code to print the script
name to a temp file at the beginning of every script, and then
ran various builds, ensuring that the scripts were run afterwards.

The builds run:
m brillo_update_payload checkvintf minigzip lz4 toybox unpack_bootimg deapexer (needed for releasetools_test)
m (as both sdk_phone_x86_64 and beagle_x15)
m target-files-package (as both sdk_phone_x86_64 and beagle_x15)
m releasetools_test && out/host/linux-x86/nativetest64/releasetools_test/releasetools_test (25 errors with and without python3)
m check_target_files_signatures apksigner target-files-package && out/host/linux-x86/bin/check_target_files_signatures out/target/product/emulator_x86_64/obj/PACKAGING/target_files_intermediates/sdk_phone_x86_64-target_files-eng.colefaust.zip
m dist
As aosp_cf_x86_64_phone: m dist && sign_target_files_apks  out/dist/aosp_cf_x86_64_phone-target_files-eng.$USER.zip /tmp/signed_target_files.zip && validate_target_files /tmp/signed_target_files.zip

This hit all the scripts except for make_recovery_patch,
merge_builds, and ota_package_parser.

I couldn't find anything that uses merge_builds, so it must
only be run manually.

make_recovery_patch and ota_package_parser are only run if
TARGET_OTA_ALLOW_NON_AB is true (among other things), which
is not the case for any product in aosp.

Test: Described in commit message + presubmits
Change-Id: I1a29eafa7ff1a69973b27055e311de77f7ee628b
2021-11-05 13:47:28 -07:00
Jaegeuk Kim
1f50a36c62 Missing required packages for f2fs when building ota package
Bug: 171942852
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ib2ecc0cf88d71f358bd04e6c4ac129607fe4054c
2021-06-08 19:12:15 -07:00
Kelvin Zhang
766eea72ef Handle caremap for partial OTAs
When generating a partial OTA, filter care_map.pb to include only the
partial partitions, then generate OTA.

Test: Generate a partial OTA, make sure care map is included.

Change-Id: I0eaa12772eb1d06a57451e64f70689d3183f0115
2021-06-04 16:17:32 -04:00
Kelvin Zhang
51c8f9f34c Merge "Expose ota_metadata_proto for consumption" 2021-05-19 12:59:43 +00:00
Elliott Hughes
16a5cac394 check_target_files_signatures actually needs aapt2, not aapt.
Test: treehugger
Change-Id: Ia0ff6d16a64f96fd9e2b9d33711cc9b94734c4ff
2021-05-14 15:27:23 -07:00
Kelvin Zhang
a3a74b69ac Expose ota_metadata_proto for consumption
Recovery needs to parse OTA metadata and perform various safety checks

Test: th
Change-Id: Ibbfa55a8ec8a15d37adb57299ed6ee89b06ba368
2021-05-14 17:18:43 -04:00
Kelvin Zhang
2b6a9c3133 Add ota_metadata_proto_java
Test: th
Change-Id: Iac9b679299db6a23cdf85d7c46f20d0538ba6015
2021-05-05 09:08:12 -04:00
jiajia tang
f3f842b676 Fix error if ramdisk is minigzip compression
This change intends to fix if ramdisk is not "lz4" compression.
Legacy is "minigzip" compression.

If not lz4, the following error will happen when exec build_super_image.py:
  Unable to get boot image build props: Failed to run command '['lz4', '-d', '/tmp/boot_omdZZ8.img/ramdisk', '/tmp/boot_omdZZ8.img/uncompressed_ramdisk']' (exit code 44):
  Error 44 : Unrecognized header : file cannot be decoded

Change-Id: I71248387bbeecbf184e0c24e6346c235d728518e
Signed-off-by: jiajia tang <tangjiajia@xiaomi.com>
2021-04-01 10:41:00 +08:00
Jiyong Park
b92b8f48fc verity_utils.py is a standalone binary
verity_utils.py gets an entry point and becomes a host binary. This is
to support signing images from the "bootimg" module type. Previously
this was done by directly invoking "avbtool" from the soong module, but
that required people to know the partition_size priori. The partition
size may not be known before actually building the partition image
especially when the partition is not for a physical partition but for a
partition in a composite image.

verity_utils.py, when the partition_size is not given, is capable of
calculating the mininum required partition size based on the size of the
unsigned input image file.

Bug: 180676957
Test: m microdroid_boot-5.10
Change-Id: I7bef292fb141c90899b7bdc0748895f95f964829
2021-03-17 16:28:16 +09:00
Daniel Norman
48603ff158 Creates a combined split-sepolicy file in merge_target_files.py.
This follows the same steps as OpenSplitPolicy() in
system/core/init/selinux.cpp on the device.

Bug: 178864050
Test: merge_target_files for R+S and S+S devices
Test: test_merge_target_files
Change-Id: Ia41a436bfda8e2cb65706122f0ff3805b99d16e1
2021-02-23 11:41:29 -08:00
Bob Badour
0390580262 [LSC] Add LOCAL_LICENSE_KINDS to build/make
Added SPDX-license-identifier-Apache-2.0 to:
  target/product/sysconfig/Android.bp
  tools/apicheck/Android.bp
  tools/product_config/Android.bp
  tools/releasetools/Android.bp
  tools/signapk/Android.bp
  tools/signtos/Android.bp
  tools/zipalign/Android.bp
  tools/ziptime/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-CC-BY SPDX-license-identifier-GPL
    SPDX-license-identifier-GPL-2.0 SPDX-license-identifier-LGPL
    SPDX-license-identifier-MIT legacy_not_a_contribution
    legacy_restricted
to:
  Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-CC-BY SPDX-license-identifier-GPL
    SPDX-license-identifier-MIT
to:
  tools/Android.bp
  tools/droiddoc/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-LGPL SPDX-license-identifier-MIT
to:
  core/base_rules.mk
  core/dex_preopt_libart.mk
  core/package_internal.mk

Added SPDX-license-identifier-Apache-2.0 legacy_not_a_contribution
to:
  target/board/Android.mk

Added legacy_restricted
to:
  core/tasks/tools/package-modules.mk
  target/product/gsi/Android.bp
  target/product/gsi/Android.mk
  target/product/security/Android.bp
  target/product/security/Android.mk
  tools/acp/Android.bp
  tools/atree/Android.bp
  tools/fs_config/Android.bp
  tools/fs_config/Android.mk
  tools/fs_get_stats/Android.bp
  tools/libhost/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id67a4eb1312940f999643b2ae57f45f34f120724
2021-02-14 10:37:20 -08:00
Julien Desprez
0c09471cc3 Clean TEST_MAPPING config based on go/a-unit-tests
unit_tests:true do not need TEST_MAPPING files

Test: presubmit
Bug: 178646865
Change-Id: Id36e98ce661dc2052e333b2644202361127939a5
2021-02-04 09:12:05 -08:00
Kelvin Zhang
e9d4ddb1e0 Merge "Add releasetools_test to TEST_MAPPING" 2021-02-02 19:25:21 +00:00
Kelvin Zhang
553efcaae2 Add releasetools_test to TEST_MAPPING
Test: treehugger
Change-Id: I3a0f9e9e5dd8d49c22f466aa0605768fee3f4821
2021-02-02 14:24:54 -05:00
Mohammad Samiul Islam
f4909b4d71 Add deapexer to releasetools_common
Bug: 178726093
Test: m updatepackage
Change-Id: I74650f339ab5399c2474d7cde1d290b55dab721c
2021-02-01 21:03:58 +00:00
Kelvin Zhang
5f0fcee4dd Emit apex_info to target_files META/apex_info.pb
Test: mm -j
Bug: 172911822

Change-Id: I5a70b75dbe1cd546c66beaa8e4e3a63c3987461e
2021-01-25 09:15:30 -05:00
Mohammad Samiul Islam
9fd5886e23 Create a function that can generate ApexInfo using target-files
If an OTA contains compressed APEX inside it, then the device will need
to allocate space on /data partition for their decompression. In order
to calculate how much space the OTA process needs to allocate, the
process needs more information about the APEX contained inside the OTA.

In this CL, we are adding functionality to the OTA generation script
that allows us to gather information about the APEX stored inside the
target-file zip. However, we did not integrate the new functionality
with the ota_from_target_files.py scrip yet. That will be done on follow
up CL.

Bug: 172911822
Test: atest releasetools_py3_test
Change-Id: I2ac42018f628c2c21527b3e086be1f4e7e7247ad
2021-01-22 20:13:32 -05:00
Yifan Hong
14a8712c4d Add missing dependencies to releasetools_common and binary defaults.
When GetBootImageBuildProp is moved to common, its dependencies
(toybox, lz4 and unpack_bootimg) aren't moved accordingly.
Copy the dependencies over.

Test: pass
Change-Id: Iaa8f41ae0109e8eb1c058ecd7dd854bb7de9391a
2021-01-12 14:04:19 -08:00
Julien Desprez
6d9e78fd5d Swich TEST_MAPPING config to unit_tests:true
All unit_tests:true are run in presubmit which avoids
the explicit definition of TEST_MAPPING.

Test: presubmit runs all those tests
Bug: 175408655
Change-Id: Ibfad3fe2dd8d2fa1ebc6f6bcbd8ab34c2a0069dc
2020-12-21 13:56:05 -08:00
Daniel Norman
21c34f78e8 Runs host_init_verifier on merged target files packages.
This verifies the init rc files in the merged result.

Bug: 163089173
Test: test_common.py
Test: Run merge_target_files.py to merge two target-files packages where
      one has init_rc errors. Observe script failure.
Test: Run merge_target_files.py on two good target-files packages,
      observe no failure.
Change-Id: I86c8e5a2bc07c2c1896ac40afd32bc1d055447ee
2020-11-24 17:26:27 +00:00
Treehugger Robot
50c0f97fe7 Merge "Finds APK shared UID violations when merging target files." 2020-11-04 21:44:40 +00:00
Daniel Norman
b8d52a2fdc Finds APK shared UID violations when merging target files.
This involved moving the find-shareduid-violation.py script to
releasetools to simplify the cross-tool usage. This new location aligns
this script with other similar python host tools.

In a future change this violation file will be used to check for
shared UID violations across the input build partition boundary.

Bug: 171431774
Test: test_merge_target_files
Test: Use merge_target_files.py to merge two partial builds,
      observe shared UID violations file contents in the result.
Test: m dist out/dist/shareduid_violation_modules.json
      (Checking that existing behavior in core/tasks is presereved)
Change-Id: I7deecbe019379c71bfdbedce56edac55e7b27b41
2020-10-29 09:33:26 -07:00
Gao Xiang
961041ac80 Allow flashing erofs system imgs
Bug: 158339527
Test: build & boot
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Change-Id: Ie74db8ebcd7214ffbec49d42b305b2f3ac2e8c9d
2020-10-28 01:24:39 +08:00
Yifan Hong
125d0b63b9 Add function to extract timestamp from boot image
Also add toybox to otatools list.

Bug: 169169031
Test: build OTA
Change-Id: Ib14dbf46a8385ccf2a9c5a9c6f4e7fa9399cf0ba
2020-10-15 19:32:39 +00:00
Luca Stefani
e0fc4caea9 Sync modules required by releasetools
Test: m otapackage
Change-Id: Id9e43909f3600224af5649b2615dffd7d59723eb
2020-09-12 06:10:13 +00:00
Tianjie
a2076137a1 Define the protobuf for OTA metadata
Background in http://go/android-partial-updates. For partial update
(e.g. system-only) or devices with mixed build, the current
fingerprint & device name no longer suffice as the precondition to
install the package.

Therefore, we need to additionally include the per-partition build
props into the ota metadata. We also define a protobuf for the metadata
so it can be extended later. The metadata of the legacy format is also
kept for backward compatibility.

Bug: 151088567
Test: unittest pass, generate an OTA and check the result
Change-Id: I716f7da54a393cd340280dbddc3c92b3460f8ef8
2020-08-26 16:17:35 -07:00
Yifan Hong
770234520d build_image relies on mkuserimg_mke2fs.
Add missing dependency.

Test: TH
Bug: 162921175
Change-Id: Ide1fe0b823e5e7a06c6c0252a5bef7bfaf6f7c28
2020-08-25 16:15:30 -07:00
Yo Chiang
76279b102f Merge "Revert^2 "releasetools: Disable host module on darwin"" 2020-08-11 04:56:55 +00:00
Yo Chiang
096c515976 Revert^2 "releasetools: Disable host module on darwin"
0ac3666667

Exempt-From-Owner-Approval: Original change was approved

Change-Id: I4030dbc072a90f9b8704926c0956787c75bc5583
2020-08-11 04:56:31 +00:00
Kelvin Zhang
cff4d7606d Move non-AB OTA generation code to a separate file
Test: Generate a non-AB OTA, apply it
Change-Id: I2f1afbe70d17356fcbf4d59901d201a76a3d6c4f
2020-08-10 16:22:22 -04:00
Insaf Latypov
0ac3666667 Revert "releasetools: Disable host module on darwin"
Revert "conscrypt: Disable host module on darwin"

Revert submission 1385032-mac-required-fix

Reason for revert: breaks the build on aosp-master
Reverted Changes:
I13335299c:releasetools: Disable host module on darwin
I728a4677a:conscrypt: Disable host module on darwin
I8f3435ff1🎨 Remove dependencies on platform unavailable m...
Ibb9248ef4🎨 Disable host module on darwin
I7db68a629:libcore: Disable host module on darwin

Bug: 163030797
Change-Id: I3b3991b91652c426d8f22d60c59c44d640059619
2020-08-06 15:48:12 +00:00
Yo Chiang
d65e8127f1 releasetools: Disable host module on darwin
Disable releasetools components that depend on disabled
modules on darwin host.

Bug: 162102724
Bug: 7456955
Test: TH build mac host target
Change-Id: I13335299ca0872cfa956ed756650a966f269080e
2020-08-04 07:12:57 +00:00
J. Avila
98cd4cc7a3 Add LZ4 support to the release tools
The core android build platform has changed to add support for LZ4
compression for ramdisks, but the release tools were not. Fix this.

Bug: 156129966
Change-Id: I39680b91930d2d3cbd0cd565beb78e1ee699397e
2020-06-10 21:51:19 +00:00
Yo Chiang
a0359ca828 releasetools: Fix non-existent required dependency
HOST module img_from_target_files has non-existent required: zip2zip
HOST module releasetools_py3_test has non-existent required: otatools
HOST module releasetools_test has non-existent required: otatools

Bug: 7456955
Test: TH presubmit
Test: atest releasetools_test # Test result doesn't change
Change-Id: I4fa4fb9c120fda5d4cb309b1e3a2660c3387eb7f
2020-05-25 17:14:51 +08:00
Kiyoung Kim
39197f846b Merge "Build required modules from default" 2020-04-02 06:14:43 +00:00
Kiyoung Kim
0a8d26210e Build required modules from default
Some required modules from host tool (such as imgdiff) are bound to
required from releasetools_common, but unfortunately required modules
from python_library_host does not work (b/140144201). To make this work
we should mark dependency from each host tool.

Bug: 152258157
Test: Build succeeded without system image
Change-Id: Iedfda9b48d78687d8f622b818eeb93896d4f119d
2020-04-01 14:21:01 +00:00
Luca Stefani
3e4b44868b releasetools: Add signapk as required modules
* common.py requires the signapk jar

Test: m otapackage ( before it was broken )
Change-Id: Ic0cff0a21258cb1e7d1ced5553a940dcf5cd6d04
2020-03-27 13:05:21 +00:00
Yifan Hong
3a7c2ef7cc Reland "Move partition size checks to python script"
This reverts commit 0141e45b96.

Reason for revert: Fixed in follow-up CL
Test: forrest
Bug: 143734706

Change-Id: I007acf228d4fb4d6a16ae9089e3f04cf33a567bb
2019-11-01 11:41:26 -07:00
Raff Tsai
0141e45b96 Revert "Move partition size checks to python script"
This reverts commit a4906cd306.

Reason for revert: b/143734706

Change-Id: I905bd9c0bfcbd123c8f9e78986bfcb5600a9eca9
2019-11-01 05:36:20 +00:00
Yifan Hong
a4906cd306 Move partition size checks to python script
Easier to read and modify its logic.

Test: builds
Test: test_check_partition_sizes
Test: atest releasetools_test
Test: atest releasetools_py3_test
Change-Id: I73204664b64a0bcee7375fa6fca46758d5a2bb72
2019-10-31 11:22:20 -07:00
Yifan Hong
708cbdbd41 Merge "releasetools: add dep to checkvintf"
am: fd4a3de77d

Change-Id: Ie5ffcd9b96de64129555980d77d851f7672f2083
2019-09-04 17:53:30 -07:00
Yifan Hong
09298552e2 releasetools: add dep to checkvintf
'required' only works on python_binary_host.
Test: modify checkvintf source code, build ota_from_target_files

Change-Id: Ieac68b39b1ccabae679a1679f184cb3aeaaeefb6
2019-09-04 12:37:46 -07:00
Tao Bao
bce0264348 Merge "releasetools: img_from_target_files uses zip2zip."
am: f833a75283

Change-Id: I1731934e5585185167db9638c7b6652871fbf913
2019-08-30 12:29:42 -07:00
Yifan Hong
ee276acce8 Merge changes from topic "vintf_ota_delete"
am: bcba1cfdaf

Change-Id: If11df7c409b9d1087defc119bf3a132f5b7016c5
2019-08-28 17:21:36 -07:00
Yifan Hong
a592de9c61 Check VINTF compatibility at OTA generation time.
am: 9276cf0226

Change-Id: Iee0efa785ccbf2aaadb1be7b3dc106f805242adb
2019-08-28 17:21:27 -07:00
Yifan Hong
96961bf94f releasetools: add tests for check_target_files_vintf
am: ccb86fe7d4

Change-Id: I3ecddd78ccce7f97bd02abea133ad84187b312ac
2019-08-28 17:21:07 -07:00