Commit graph

6232 commits

Author SHA1 Message Date
Baligh Uddin
39b8f9fc7d DO NOT MERGE - Add a guard against deleting AVB_PUBKey.
The avb_pubkey may not be present, if the apex was initially
unsigned or generated from a bundle.  In this case, running
sign_apex to generate a signed apex binary would result in an error.
This fix checks for presense of avbpubkey before attempting the
deletion

BUG: 139994107
Change-Id: I3cb2e88a11ad8797e38ba5fb98c96a4ec4135fc8
2019-08-25 22:20:36 -07:00
Tao Bao
b369c7226a releasetools: Ignore nonexistent APEX overrides.
This allows sharing the same signing config on different target_files
zips. Nonexistent APEX will be ignored with a warning.

Bug: 137249701
Test: Run sign_target_files_apks with APEX overrides.
Change-Id: I2bad0f5c00753ed36ec5ae3431c7dc2ff1fc3e9c
2019-07-11 11:54:39 -07:00
Tao Bao
97a6690a23 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
Merged-In: I5859e30be63bfd54398cf41fd2d907f15285f560
(cherry picked from commit 4978fa99d1)
2019-06-05 22:04:47 -07:00
Bowgo Tsai
33ff602070 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 16:14:53 +08:00
Tao Bao
f52dbb81fe Add sign_apex.py that signs a given APEX file.
Bug: 132687993, 131687150
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-19 11:33:31 -07:00
Tao Bao
a3c3b9bc64 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:52:01 -07:00
Tao Bao
d403e7bc8e releasetools: Support replacing the signing keys for chained vbmeta.
Bug: 131710801
Test: Run sign_target_files_apks.py on a target that uses vbmeta_system.
Change-Id: I3bc526af3ec9f2680ca17ee5535607cff3ae9523
Merged-In: I3bc526af3ec9f2680ca17ee5535607cff3ae9523
(cherry picked from commit d6085d6834)
2019-05-06 20:11:17 -07:00
Magnus Strandh
6396797612 Ensure that 'release-keys' are set on properties
Some properties had 'test-keys' still set
after signing the target files zip for release.

These properties are now added to the RewriteProps
method.

Bug: 131810966
Test: manual
Test: `atest releasetools_test`
Change-Id: Ifb352ed28f5100f1e9f686d77e935723f7f6d3ae
Merged-In: Ifb352ed28f5100f1e9f686d77e935723f7f6d3ae
(cherry picked from commit 234f4b418f)
2019-05-03 11:41:07 -07:00
Yifan Hong
7df64c3e77 Add BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE flag.
When set, product-img-tag.zip contains super.img instead of individual
user images from target files. For virtual devices, super.img is needed
to boot the device, but individual user images aren't needed.

Test: on A/B DAP, with flag set:
     - m updatepackage and look at img.zip
     - img_from_target_files
     both have super.img and not system / vendor / system_other
Test: on non-A/B DAP, with the flag set:
     - m updatepackage and look at img.zip
     - img_from_target_files
     both have super.img and not system / vendor
Test: on A/B retrofit, with the flag set:
     - m updatepackage and look at img.zip
     - img_from_target_files
     both have super_*.img and system_other.img, but not system / vendor
Bug: 113175337

Change-Id: I94e33091d0c837cae40776176b4dcfdd338aba90
(cherry picked from commit 0e97dbb8ca)
Merged-In: I94e33091d0c837cae40776176b4dcfdd338aba90
2019-04-30 11:36:16 -07:00
Yifan Hong
46f7e88c27 Merge changes from topic "productmanifest" into qt-dev
* changes:
  ota_from_target_files: include metadata when odm / product is changed.
  Add product manifest.
2019-04-26 22:39:01 +00:00
Tao Bao
548db7d797 releasetools: Accept PRESIGNED keys in apexkeys.txt.
For an PRESIGNED APEX, it has the following format, which should be
considered as a valid input.

name="foo.apex" public_key="PRESIGNED" private_key="PRESIGNED" container_certificate="PRESIGNED" container_private_key="PRESIGNED"

Bug: 131153746
Test: Run sign_target_files_apks.py on a target_files.zip with PRESIGNED
      APEXes.
Test: python -m unittest sign_target_files_apks
Change-Id: I51076b0c6eddfb75637d37659a08009f0a88e931
(cherry picked from commit f454c3a0b4)
2019-04-25 00:20:00 -07:00
Yifan Hong
2dcc1dcf9c ota_from_target_files: include metadata when odm / product is changed.
When odm is changed, device manifest/matrices should be included.
When product is changed, framework manifest/matrices should be included.

Bug: 130714844
Bug: 126770403
Test: build with odm and product VINTF metadata

Change-Id: I49c8083e0e7185ae7b96047d68f1f624b1113dfc
Merged-In: I49c8083e0e7185ae7b96047d68f1f624b1113dfc
2019-04-24 16:28:49 -07:00
Bowgo Tsai
08aca59c53 Avoid signing debuggable boot-debug.img
The boot-debug.img should NOT be release signed and can only be used
if the device is unlocked. Adding a check to prevent the tool from
signing this debuggable boot.img.

See the following for more details about boot-debug.img:

  https://android-review.googlesource.com/c/platform/build/+/947857

Bug: 126493225
Test: put a file /force_debuggable into boot.img, checks the following
      command fails:
        ./build/tools/releasetools/sign_target_files_apks \
        out/dist/*-target_files-*.zip signed-target_files.zip
Change-Id: Ia5232949cb9582d2b4eaa171d9e9f3fe7317d418
Merged-In: Ia5232949cb9582d2b4eaa171d9e9f3fe7317d418
(cherry picked from commit 78369ebbc1)
2019-04-23 21:00:08 +08:00
Dan Willemsen
e531685ba5 TARGET_FS_CONFIG_GEN is a list, not a single path
Bug: 130787336
Test: m oemaids_header_gen oemaids_headers passwd group
Test: Set TARGET_FS_CONFIG_GEN to a list of paths
Change-Id: I5186b378fea8865f46cfd891420ba576f36e2565
Merged-In: I5186b378fea8865f46cfd891420ba576f36e2565
(cherry picked from commit 7f25f2aed9)
2019-04-18 14:26:48 -07:00
Yifan Hong
210ede323f FileImage: make thread-safe
FileImage needs to be thread-safe because multiple
threads gets data from it when an incremental OTA
package is created.

Test: apply incremental OTA on cuttlefish
Bug: 113175337
Change-Id: I31637fce0fbd66f3fa6c5c478da09bae65a52229
Merged-In: I31637fce0fbd66f3fa6c5c478da09bae65a52229
2019-04-12 15:59:03 -07:00
Yifan Hong
50db54519e Allow generating OTA package from non-sparse images.
Test: build OTA package in cuttlefish

Bug: 120041578
Bug: 113175337
Change-Id: I246c38e08376c837b7f126aa19cb8c1d73ed1e26
Merged-In: I246c38e08376c837b7f126aa19cb8c1d73ed1e26
2019-04-12 10:48:29 -07:00
Yifan Hong
508850e298 Fix DataImage.ReadRangeSet()
It returns a list of one generator object, not a list
of strings.

Test: test_blockimgdiff
Bug: 113175337

Change-Id: I8962c539c2ce3fae90d428b38c4b0e52c5a2cdad
Merged-In: I8962c539c2ce3fae90d428b38c4b0e52c5a2cdad
2019-04-12 10:48:21 -07:00
Tao Bao
222bba6253 releasetools: Remove the name restriction in common.GetSparseImage.
The function used to be serving system and vendor partitions only (as
they were the only partitions using sparse image at the point). The code
itself doesn't rely on anything specific to system/vendor.

Test: python -m unittest test_common
Bug: 113175337

Change-Id: Ia4ecdeedb262f3d9db082128eaf9bab299983333
Merged-In: Ia4ecdeedb262f3d9db082128eaf9bab299983333
2019-04-12 10:47:53 -07:00
TreeHugger Robot
f9dca5e1d8 Merge "Convert oemaids_headers / passwd / group to Soong" into qt-dev 2019-04-12 16:06:59 +00:00
Tianjie Xu
cd797a289f Merge "Pass the correct signature size to payload generator" into qt-dev 2019-04-12 01:21:45 +00:00
Dan Willemsen
b9d45c7d47 Convert oemaids_headers / passwd / group to Soong
Bug: 118089258
Test: m oemaids_header_gen oemaids_headers passwd group
Change-Id: Ie3b92a499b44391e0692da5d9ad067089a62aabb
Merged-In: Ie3b92a499b44391e0692da5d9ad067089a62aabb
(cherry picked from commit d32e6d1314)
2019-04-11 16:41:22 -07:00
TreeHugger Robot
c028b0e155 Merge "docker: update sha256sum for repo version 1.25" into qt-dev 2019-04-11 21:52:23 +00:00
xunchang
3c5de18f5d Pass the correct signature size to payload generator
The signature size will be 512 bytes when signing the payload
with 4096 bits key. This cl determines the key size with
"openssl rsa -modulus"

The new key in testdata is generated by
"openssl genrsa -out testkey 4096"

Bug: 129163830
Test: generate and verify an OTA package
Change-Id: I6662b0a0c553dc0fd84711312a1256b887e332fd
(cherry picked from commit 376cc7c452)
2019-04-11 21:04:28 +00:00
Pavel Salomatov
a77dea9865 docker: update sha256sum for repo version 1.25
Fixes: 130366091
Change-Id: Iaec4b2429c61aa2d804e56a88cf66ae543a29805
Merged-In: Iaec4b2429c61aa2d804e56a88cf66ae543a29805
(cherry picked from commit 4a7f6daa85)
2019-04-11 13:38:05 -07:00
Yifan Hong
0d8e89b5f8 Reland "Only assert-max-image-size for static partitions."
assert-max-image-size doesn't make sense for
dynamic partitions, as build_image.py always find the
right size for the output image. Hence:

- build_image.py no longer need to write generated_*_info.txt
  (which contains the size of the image).
- assert-max-image-size on the static BOARD_*IMAGE_PARTITION_SIZE. If
  a partition is dynamic, that variable isn't set, and
  assert-max-image-size becomes a no-op. If the partition is static,
  assert-max-image-size checks the static partition size as it used
  to be.
- Fix read-size-of-partitions to use the size of the partition by
  reading the image directly (instead of using generated_*_info.txt).

For devices without AVB, with DAP enabled, and does not have
RESERVED_SIZE for partitions, because of right sizing, the original
code always warns about approaching size limits. Since such checks
doesn't make sense for dynamic partitions, remove them.

Test: builds on device with dynamic partitions
Test: builds on cuttlefish with DAP enabled (without AVB), no
      more size limit warnings:
WARNING: out/target/product/vsoc_x86/vendor.img approaching size limit (X now; limit X)

This reverts commit 6e099095d1.

Reason for revert: reland the CL

Bug: 122377935
Test: build blueline_mainline

Change-Id: Iee594b64e687decff186c0fa60f82b88608febe9
Merged-In: Iee594b64e687decff186c0fa60f82b88608febe9
2019-04-11 10:12:27 -07:00
Yifan Hong
cf9f9bedb8 sparse_img.py --get_partition_size return size of partition
Also, move code from build_super_image.py to sparse_img.py.

Test: sparse_img.py on sparse and non-sparse images
Bug: 122377935
Change-Id: Ie91fdfdbb54298ea27eb20d1b5363aeb1470356e
Merged-In: Ie91fdfdbb54298ea27eb20d1b5363aeb1470356e
2019-04-11 10:12:27 -07:00
Yifan Hong
c3664703f8 Build non-sparse super image if necessary.
If TARGET_USERIMAGES_SPARSE_EXT_DISABLED is set, don't provide
--sparse to lpmake, so that a non-sparse super image is built.

Test: build with the flag set.
Bug: 120041578
Change-Id: I5a26e4c793b0e2ddc89e9c38c8828ac21044e78a
Merged-In: I5a26e4c793b0e2ddc89e9c38c8828ac21044e78a
2019-04-04 16:36:25 -07:00
Tao Bao
4117d7df6f Merge "releasetools: Update the embedded AVB pubkey in an APEX." am: 289fa3cea3 am: a24aecb821
am: 013c86f4fc

Change-Id: I137507e29b5f734e3657664ee900e11da672db95
2019-04-02 11:06:39 -07:00
Tao Bao
a24aecb821 Merge "releasetools: Update the embedded AVB pubkey in an APEX."
am: 289fa3cea3

Change-Id: Iaf4497f41f38fff7bf646f923f61b7a8199e5cfc
2019-04-02 10:22:53 -07:00
Tao Bao
289fa3cea3 Merge "releasetools: Update the embedded AVB pubkey in an APEX." 2019-04-02 16:56:45 +00:00
Bill Peckham
f4f3007461 Merge "Add support merging system and other for the non-A/B configuration." am: 5f4186b000 am: a635376ce1
am: ec4b69a7d6

Change-Id: I3785bd7da43f028e61110bd3780930f5098c1c5a
2019-04-02 06:35:21 -07:00
Bill Peckham
a635376ce1 Merge "Add support merging system and other for the non-A/B configuration."
am: 5f4186b000

Change-Id: I347d05f8a60c5f63ba591aed8d16b078bfdfb840
2019-04-02 06:24:25 -07:00
Tao Bao
9c0f443264 releasetools: Update the embedded AVB pubkey in an APEX.
APEX keys are now embedded in the APEX [1].

[1] https://android-review.googlesource.com/c/platform/system/apex/+/936942

Fixes: 128297564
Test: Run sign_target_files_apks.py on a target_files.zip built with the
      CL above.
Change-Id: I219cc3e6ce6f652537fcc37322c8902f295c1447
2019-04-01 21:30:07 -07:00
Bill Peckham
364c1ccaa5 Add support merging system and other for the non-A/B configuration.
For non-A/B, you must supply the --system-item-list, --other-item-list, and
--system-misc-info-keys parameters approrpriate for merging two partial target
files. Additionally, you must supply the --rebuild-recovery option to correctly
generate the filesystem config and file contexts. With all of these parameters,
the script will generate a merged target files containing the correct recovery
files.

Also fix the --keep-tmp option to be consistent with the other options.

Bug: 122813742
Test: verify that merged target image boots and can perform OTA.
Change-Id: I5a942ac0cd9924fec419a686794a2340304594c8
2019-04-01 14:55:33 -07:00
Daniel Norman
b2852ae287 Merge "Adds some tests for merge_target_files." am: 482e67f4ee am: d8414c71b8
am: 1abb3e3371

Change-Id: Ifd603539b53807c347ccb93e2306d4d989693bd5
2019-03-28 21:39:10 -07:00
Daniel Norman
d8414c71b8 Merge "Adds some tests for merge_target_files."
am: 482e67f4ee

Change-Id: I246a1e6f2afceb42a5aca56b46291fbd37860ac5
2019-03-28 21:30:49 -07:00
Daniel Norman
6d82fa3961 Adds some tests for merge_target_files.
Test: python -m unittest test_merge_target_files
Bug: 129262038
Change-Id: Ibcb3b384b81ceaa1924a6cd402a8880bd3cfbba6
2019-03-28 14:43:30 -07:00
Tao Bao
f1a39e9170 Merge "releasetools: Remove the sanity check on APEX payload key names." am: c292edc22c am: ea673330bd
am: bce744ef67

Change-Id: I26cf08f34a974eaef13e55af3b590892df713d06
2019-03-27 09:05:58 -07:00
Tao Bao
ea673330bd Merge "releasetools: Remove the sanity check on APEX payload key names."
am: c292edc22c

Change-Id: I3ff4de4afde65971f9967db73a6373107517c8fa
2019-03-27 08:51:33 -07:00
Tao Bao
c292edc22c Merge "releasetools: Remove the sanity check on APEX payload key names." 2019-03-27 15:44:29 +00:00
Tao Bao
d602409b5d Merge "releasetools: Re-enable verifying AVB-signed images." am: 5ed75d74e3 am: 26b2664dce
am: 06ee461ac2

Change-Id: I9a9e2a6bca07247f43311c7bf95d67f137093c58
2019-03-26 20:50:41 -07:00
Tao Bao
26b2664dce Merge "releasetools: Re-enable verifying AVB-signed images."
am: 5ed75d74e3

Change-Id: I45ff35f4b64967f5dd0c539b5abf535ab648408a
2019-03-26 20:36:22 -07:00
Tao Bao
5ed75d74e3 Merge "releasetools: Re-enable verifying AVB-signed images." 2019-03-27 03:20:13 +00:00
Tao Bao
6d9e3da5f9 releasetools: Remove the sanity check on APEX payload key names.
Unlike container keys/certs, we'll always carry full names for APEX
payload signing keys.

Test: Run sign_target_files_apks.py on a target_files.zip with
      mismatching payload signing keys (e.g. shim apexes).
Test: `python -m unittest test_sign_target_files_apks`
Change-Id: Ifa329478f43b4f5ae665821564dbc14af7841330
2019-03-26 13:05:46 -07:00
Tao Bao
a81d429928 releasetools: Re-enable verifying AVB-signed images.
This reverts commit 9788b4ed31. All the
blocking issues have been addressed.

Fixes: 120517892
Test: Run validate_target_files.py on crosshatch signed
      target_files.zip.
Change-Id: I95de241e159998e002dedddafea65953b1a1b263
2019-03-26 12:13:37 -07:00
Daniel Norman
de01f0fdfe Merge "Merges dynamic partition misc_info.txt keys from both system and other." am: c21a8448d1 am: 081eedce39
am: d857025380

Change-Id: I9d788369617dbca5df4bbaf24fbcc9b505d0e18e
2019-03-25 16:35:11 -07:00
Daniel Norman
081eedce39 Merge "Merges dynamic partition misc_info.txt keys from both system and other."
am: c21a8448d1

Change-Id: I91afb67ab90b8a6f0c54138b299481403e4b1c2d
2019-03-25 16:26:53 -07:00
Daniel Norman
c21a8448d1 Merge "Merges dynamic partition misc_info.txt keys from both system and other." 2019-03-25 23:15:09 +00:00
Anton Hansson
db064f1f1a Merge "Put DEVICE/PRODUCT overlays in different partitions" am: 94fa0e75cb am: fd946975d0
am: 691c979b62

Change-Id: I1e9c9b79b931229ed3142d1921d784a6bad7baed
2019-03-25 02:46:53 -07:00
Anton Hansson
fd946975d0 Merge "Put DEVICE/PRODUCT overlays in different partitions"
am: 94fa0e75cb

Change-Id: I490160177bd0084721212d832dff8c0d721e2e14
2019-03-25 02:32:55 -07:00