Commit Graph

641 Commits

Author SHA1 Message Date
LuK1337
961fa5a5c0 Don't remove ANDROID_SECURE_STORAGE_CMD from env vars
We also use it in avbtool.

Change-Id: I4737c1815a031d307f6915a73b5f5b1a37b6baaa
Signed-off-by: RITEFANG <1721985272@qq.com>
2025-02-05 20:41:13 +08:00
LuK1337
6f02eeb749 Log when we fail to get key password from secure cmd
Change-Id: I4455f43e43b772e785ece48721dcd770f0bc8711
Signed-off-by: RITEFANG <1721985272@qq.com>
2025-02-05 20:41:13 +08:00
Aaron Kling
8592dd6443 releasetools: Fallback to calculated fp if partition fp is missing
This happens when the fingerprint property is blacklisted for the
purposes of unified device builds.

Change-Id: I9f8a5041248c3f73fce7a16da73cb8f68c06c8e2
2025-02-05 20:38:40 +08:00
David Ng
1e916f1bdc build: Add support for device tree in boot.img
Add support for optional device tree image (dt.img)
to boot and recovery images.  Some devices use kernel device
tree and this adds the device tree image as a section within
the boot/recovery images.

Change-Id: I91431ef2f4b86485895678916e39a8572be878eb

Build: add DT image variable to Makefile

DT image variable is currently present in
generate_extra_images.mk.This file is moved to
build/tasks to support persist image generation
during parallel make. As build/tasks is called
at the end of Makefile, DT image variable is not
available for other images generation like boot and
recovery. Adding this variable in Makefile ensures
the variable is defined before usage

Change-Id: I21f675d8ce648dc1cf1f4f3aede33278300e08c9
CRs-fixed: 548299

Fix case where boot/recovery.img were being built with wrong params.

The boot and recovery images  now get built using the same params during ota package
generation as during a normal build.

Change-Id: I93d46e11a4245288f0e87c87a2e4bf45ac5aff69

Fix the extra dt.img compilation issue.

Add support for optional device tree image (dt.img)
for device that doesnt have TARGET_BOOTIMAGE_USE_EXT2

Change-Id: I6e07b3ca6d049a8ebdad7ea304b4f39e7c846151

releasetools: Store and use the dt image file through target files

Target files packages may be used for signing images separate from the
build process. Store the device tree image file in the target files
package so it can be used during the signing process.

Change-Id: Ie8507121fa9c4ba57ecffeab05bd859ae5f5b788
2025-02-05 20:38:40 +08:00
Luca Stefani
80f63ee9d1 Add build support for XZ ramdisks
Co-authored-by: Arne Coucheron <arco68@gmail.com>
Change-Id: I61530b6da06e0038970551aa4d12bce02007ae3c
2025-02-05 20:37:48 +08:00
Tom Powell
c32bd60f93 releasetools: support reading release keys out of some sort of command
key passphrases may live in some sort of secure storage, support running
an arbitrary command to retrieve them.

Change-Id: I49862cf60f1b73a2356e0c492e1038beef28a95f
(cherry picked from commit 9caf8603575aecf51761feaeac6db619be76cfd3)
2025-02-05 20:35:57 +08:00
Peter Cai
2a279867ea releasetools: do not remove dynamic partitions in system-only builds
* Before this commit, the generated `dynamic_partitions_op_list` in
  FullOTA packages always tries to remove all partitions and recreate
  them upon flashing. This makes it impossible to have a system-only
  "FullOTA" because vendor partition(s) are always removed.

* This commit detects if a build is vendor-less and disables every
  dynamic partition operation except `resize`, in order to keep the
  original content around after the flash. The change should not affect
  non-dynamic-partition or builds with vendor image included.

Change-Id: I0cded7f3b2958f35103d73d19b7fb5f292f6c17f
Signed-off-by: Jesse Chan <jc@lineageos.org>
2025-02-05 20:35:57 +08:00
Brint E. Kriebel
3d048e0f77 releasetools: Use the first entry of a mount point when reading fstab
There may be multiple entries in fstab for a mount point. Use the first
value found so the entries are prioritized in order.

Change-Id: Ibd2631413d3e00507d3a0ec84fb91755f1c7993c
Ticket: OPO-326
2025-02-05 20:35:57 +08:00
M1cha
9b91836d1f releasetools: ota_from_target_files: add FullOTA_PostValidate
Change-Id: I152412049f90fd546d4516cc064238c3192be553
2025-02-05 20:35:57 +08:00
dianlujitao
6a1b8b765e Move recovery-from-boot.p from /system to /vendor
The file was missed when moving recovery resources, but the assertion
path was changed, as a result non-Treble devices failed to build.

Fixes: Ia4045bd67ffb3d899efa8d20dab4c4299b87ee5f
Change-Id: Ib7822a9bd5b1a2ab7e762e9fb35dbb22291a3a76
2025-02-05 20:35:57 +08:00
Steve Kondik
6d06aad39d Allow override of device asserts, including multi-device support.
Set in board file with TARGET_OTA_ASSERT_DEVICE.
(cherry-picked from commit 0f452f21fc9323b9d1fe746161761cf40aaa5030)

Change-Id: I3d06bdc0e3e26bde0c0e646accd050364f9713b9

ota_from_target_files: Remove device dependent arguments

These device-specific arguments are defined at build time and are
necessary to generate the zip correctly. Don't use command line
arguments to specify them, but write all the needed information
in misc_info.txt when the target-files zip is generated.
ota_from_target_files will then read misc_info.txt and set
everything automatically.

Change-Id: Ibdbca575b76eb07b53fccfcea52a351c7e333f91
Signed-off-by: André Pinela <sheffzor@gmail.com>
2025-02-05 20:35:57 +08:00
Kelvin Zhang
cc758d9609 Create parent directories before writing to output target files
Sometimes the output path's parent directory doesn't exist yet,
causing a failure in open() syscall.

Test: sign_target_files_apks solios-target_files-12328286.zip
solis_signed.zip
Bug: 364967828

Change-Id: I85f91ca5d1321c1ba763cac058eb28acc7f48e70
2024-09-06 14:49:12 -07:00
Treehugger Robot
939326d3be Merge "Re-generate 4K boot OTAs using signed boot.img during signing process" into main 2024-08-22 17:09:06 +00:00
Kelvin Zhang
b707ea0206 Re-generate 4K boot OTAs using signed boot.img during signing process
Currently, dev option OTAs are generated using dev-key signed boot.img
On release-key devices, OTA will install successfully, but user would be
using dev-key signed boot image after reverting to 4K mode, and
subsequent OTAs would fail. This CL re-generates 4K boot OTA using
release-key signed boot.img , which allows normal OTAs after toggling
dev options.

Test: th
Bug: 354019928
Change-Id: I40811d6ed7a37f50edea77d245bf559b66da5a71
2024-08-21 10:36:57 -07:00
JaeMan Park
b3795b7933 Fix build error while creating CHD image
While building CHD image, it failed with the error

KeyError: 'system_dlkm_base_fs_file'

Fix the build error by deleting proper props in the python code.

Bug: 359578756
Test: Building CHD image using build_cf_hybrid_device.py should not failed
Change-Id: Iae84ff080b8f6bf3b8d22b26865ea3e74815ac37
2024-08-14 14:11:15 +09:00
Jooyung Han
67911682c2 target-files: Support erofs_compress_hints
erofs_compress_hints files should be copied into target-files and then
sign_target_files_apks should use them from the target-files.

Bug: 357721652
Test: m target-files-package (with aosp/3204257)
Test: sign_target_files_apks <target_file> signed-target-files.zip
Change-Id: Id55000004ecb72ea8fec19bfbe144c9b4d3f06cb
2024-08-09 08:27:19 +09:00
ELIYAZ MOMIN
10e47e3723 Revert^2 "Fix signing failure for split APKs"
This reverts commit d06e5a83ba.

Reason for revert: <It's not a culprit any more.>

Change-Id: I405c418e6da88774b174fcb3508eb54039fbdf8e
2024-08-01 15:43:31 +00:00
Pechetty Sravani (xWF)
d06e5a83ba Revert "Fix signing failure for split APKs"
This reverts commit 6871779d9b.

Reason for revert: Potential culprit for b/356752725- verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I4c29b27f0318901130036dbe8ab9edef37f08875
2024-08-01 05:54:13 +00:00
Kelvin Zhang
6871779d9b Fix signing failure for split APKs
Test: th
Bug: 353837347
Change-Id: Ifed9746c1e1d053a97860de3bab4380d6e207412
2024-07-31 10:36:47 -07:00
Jooyung Han
972804b81e Fix a bug in the releasetools common.py script.
The script was not breaking out of the loop when a handler was found, which could lead to multiple handlers being called for the same option.

This fixes the issue that a single option can be handled in two handlers.

Bug: 345402175
Test: sign_target_files_apks -k ..
Change-Id: I9f4ef801df99a4a0f2ba5be994b3f37fbedc22c0
2024-06-21 22:42:48 +00:00
Jakub Czapiga
31f6e08fc9 Drop legacy vboot support.
Bug: 291329969
Bug: 347885843
Bug: 347899892
Test: m
Test: CIs
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5071b95a067c9392b7bfa4d95957307ff0ccdcc3)
Merged-In: I5f30f63553cc2670650897e259ba51baf8ced05d
Change-Id: I5f30f63553cc2670650897e259ba51baf8ced05d
2024-06-18 15:40:14 +00:00
Ashok Mutyala
8a3e361ea4 Add fs_config support for vendor_boot
Test:
1) add META/vendor_boot_filesystem_config.txt to    merge_config_other_item_list
2)Building vendor_boot image from target_files

Change-Id: Ia983d1119e30c46a6730566c567f13e25a65b0ff
2024-05-24 14:09:28 +00:00
Daniel Zheng
2fc519a568 Merge "ota_from_target_files: read correct api level" into main 2024-04-16 19:32:37 +00:00
Daniel Zheng
dc411eda4c ota_from_target_files: read correct api level
ro.product.first_api_level looks like the value we actually want to read
to since it inherits from $PRODUCT_SHIPPING_API_LEVEL. Other variables
we attempted to look at were giving other values (e.g 202504 for pixel
watch)

Bug: 331202590
Test: th
Change-Id: Ied3da247cba45611132db6c9e3cdefb447891f96
2024-04-16 12:32:05 -07:00
Kelvin Zhang
1d9b3daad2 Make output of MakeVbmeta consistent
The order of items in `partitions` map is non-deterministic. To make
sure that builds are hermetic, sort the map before use.

Test: th
Bug: 332550989
Change-Id: I76c7037ef9f03904899339813819fcf985a7c893
2024-04-15 09:45:03 -07:00
Kelvin Zhang
4dc089971b Make build_image output consistent for partitions w/o build.prop
Bug: 331405669
Change-Id: I01a673e7c842a5042d85f079e29c680c4d7b589c
2024-04-02 09:05:08 -07:00
Treehugger Robot
decb8f4d1b Merge "Add apk_name information in error message" into main 2024-03-25 22:30:31 +00:00
Spandan Das
198dcf91ca Add apk_name information in error message
Logging the apk_name will improve debugging process if
`GetMinSdkVersion` returns an exception.

Test: None
Change-Id: I3ddf602d92701dcaaa4821fe42a76a870a721a11
2024-03-25 21:24:33 +00:00
Daniel Zheng
4a80c5403d fallback to v2 on s build
In the case that a vendor is on s build (which doesn't have snapuserd),
and is takinga  v3 -> v3 upgrade, we want to fallback to v2 vabc ota.

Test: th
Change-Id: Iba259b139b9b423ac77d82e14a113cf35fbfea64
2024-03-22 12:02:54 -07:00
Daniel Zheng
474afa8f06 fallback on older cow version
If a device's source or target cow version is specified at 2 (or
undefined) we should fallback on using the v2 writer.

e.g.
1. v3 -> v2 downgrade OTA
2. v2 -> v3

Bug: 322279333
Test: ota_from_target_files
Change-Id: I8c5139eceeb64ee255ddea66017b3e17bbdc44c0
2024-02-28 20:47:20 -08:00
Yi-Yo Chiang
a4d5f4380b Re-land: releasetools: Deprecate GKI build rules
(Re-land of Ie882fccd864920289e48366e99a4ebd67e784d0d)

We no longer build GKIs from the platform tree.
These build commands were neither used nor maintained anymore, so clean
them up to reduce maintenance effort.
Keep the command line options as no-op, so existing scripts that still
specifies the deprecated options don't break.

Bug: 229701033
Test: presubmit
Change-Id: I0f7d05562dbc3eed29e902d6dc9a0f2e4083aaa6
2024-01-25 11:21:00 +08:00
Treehugger Robot
ca96bcb0c8 Merge "Sign OTA packages inside target_files during signing" into main 2023-12-05 21:46:55 +00:00
Yi-Yo Chiang
18650c7be0 releasetools: Remove deprecated BOARD_BUILD_SYSTEM_ROOT_IMAGE
This variable is always false or empty now, so clean up remaining
references to the variable.

Bug: 241346584
Test: Presubmit
Change-Id: I5dd3d356729d0bd2639633580bbb85f8b03582cf
2023-12-01 09:03:08 +00:00
Yi-Yo Chiang
92a517d75e Revert "releasetools: Deprecate GKI build rules"
This reverts commit faaede0f01.

Reason for revert: caused GSI sign failure b/311134118#comment23

Change-Id: Id794a8ab3369c907834a73cc88ea1640dc7492d1
2023-12-01 07:02:17 +00:00
Kelvin Zhang
b84d2aa7d1 Sign OTA packages inside target_files during signing
Test: th
Bug: 293313353
Change-Id: Ifd5dd08153c5970dac8166808173f7dfbbb3411d
2023-11-28 10:08:38 -08:00
Yi-Yo Chiang
faaede0f01 releasetools: Deprecate GKI build rules
We no longer build GKIs from the platform tree.
These build commands were neither used nor maintained anymore, so clean
them up to reduce maintenance effort.

Bug: 229701033
Fix: 229701033
Test: presubmit
Change-Id: Ie882fccd864920289e48366e99a4ebd67e784d0d
2023-11-28 08:54:33 +00:00
Kelvin Zhang
c68c6b9530 Allow ParseOptions to compose multiple option parsers easily
There are certain options which we need to share in multiple binaries,
for example, the signer options. Current options parsing function only
accepts 1 extra option handler, which is inflexible. Extend it to take a
list of extra option handlers.

Currently, to add a new CLI flag, caller must append the flag name to
`extra_long_opts`, then pass an extra option handler which can handle
that option. Define a new dataclass which contains both the CLI flag
name and the code to handle that flag for better composition.

Test: th
Bug: 293313353
Change-Id: I758db66dfd95934f5b2701454d97bfe7d37dc16d
2023-11-14 12:41:56 -08:00
Abhishek Nigam
1dfca46094 Revert "Move more non-AB code to separate files"
This reverts commit 513b86e5c2.

Change-Id: I6aae60642772a052404eb1773966b2e637864bbc
2023-11-08 22:29:18 +00:00
Kelvin Zhang
8c9166ae37 Convert partition size to int before CheckSize
Test: th
Change-Id: Ic312e40fdad99afd65b4fc259395b8952bb038c6
2023-11-01 10:14:13 -07:00
Kelvin Zhang
9f9ac4e8a0 Fix prebuilt boot image hermetic build
Break when we find a working salt, certain devices have boot image
containing both the kernel and ramdisk, resulting in the ramdisk being
used as salt. Since core/Makefile uses kernel as salt, update python
code to match.

Bug: 293313353
Test: th
Change-Id: I68b5a8c2f0747ddf68f775bc2a6c5db46eb7eb64
2023-11-01 10:14:13 -07:00
Kelvin Zhang
513b86e5c2 Move more non-AB code to separate files
non-AB has different lifetime and development cycles from AB. To avoid
accidentally breaking each other when making changes, put non-AB code in
its own files.

Test: local non-AB OTA generation
Bug: 296485685

Merged-In: I0736ecef343834c746464666a454a8bfcd4a20ea

Change-Id: I0736ecef343834c746464666a454a8bfcd4a20ea
2023-10-30 23:43:15 +00:00
Kelvin Zhang
2ab6986dd9 Make non-ab code path compatible with extracted target files
Bug: 296485685
Test: ota_from_target_files -v -i non_ab.zip non_ab.zip ota.zip
Change-Id: I13ed54bfe7d14d2d1e87f45564da465a77bc2d1d
2023-10-27 11:01:27 -07:00
Kelvin Zhang
160762a276 Use deterministic salt for AVB footer of prebuilt boot img
When target specified a prebuilt boot.img, current build system will add
avb hash footer to it with a random salt. Use a deterministic salt
instead for more reproducible builds. To stay consistent with
non-prebuilt boot.img code path, we extract the kernel image from
prebuilt boot.img and uses sha256sum of kernel image as the salt.

Test: th
Bug: 293313353
Change-Id: I988999ddc4f18e0b8677b05a3165c847b6a11b52
2023-10-25 13:28:11 -07:00
Kelvin Zhang
9d74128194 Allow -v option to change log level
Setting logging level to 'NOTSET' would tell logging module to inherit
logging level from handlers. Since the verbosity of handlers is
controlled by -v option, this allows sign_apex.py to give verbose output
if -v is specified.

Test: th
Bug: 307191956
Change-Id: I9c1db107cf4eae80ab570d892b0465b3902298fd
2023-10-24 21:58:28 -07:00
Thiébaud Weksteen
62865caf1b Revert "Add sign_sepolicy_path for a binary to sign sepolicy.apex."
This reverts commit e0a977affd.

Test: atest --host releasetools_test
Bug: 297794885
Change-Id: I951277e4aa3ae1f90474a1f7a036fc8693453c53
2023-10-18 11:41:25 +11:00
Dennis Song
764585118f Merge "Resolve conflict AVB rollback index location" into main 2023-10-04 17:16:11 +00:00
Dennis Song
4aae62ee77 Resolve conflict AVB rollback index location
Add an `--avb-resolve-rollback-index-location-conflict`
option in merge_target_files. When this option is set,
the merge tool will resolve conflicting index locations
by assigning the smallest unused index location.

This is to support merging system and vendor target files
from two different targets. In this case, the two target
files may have conflict rollback index location because
they were built independently.

Test: atest releasetools_test
Test: validate_target_files *-target_files-*.zip
Test: merge_target_files &&
        add_img_to_target_files &&
        img_from_target_files &&
        flash device
Bug: 300604688
Change-Id: Ibd18ef2a9f3784157fe17966f5364c3c81c9bd9f
2023-10-04 06:45:15 +00:00
Kelvin Zhang
de53f7df43 Use deterministic salt for boot image avb footer
avbtool by default generates a random salt everytime, this makes builds
less reproducible. Use sha256 checksum of kernel image as the hex to
make the build reproducible.

Test: th
Bug: 293313353

Change-Id: I959b3dee77654098ab9fde475f11eaee8d40c790
2023-10-03 12:26:08 -07:00
Dennis Song
6e5e44df72 Minor refactor tools/releasetools/common.py
- Sort the import modules in alphabetical order.
- Define module variables for avbtool arguments name.

Test: atest releasetools_test
Bug: 300604688
Change-Id: I7990b94cfc1d7b3e977ceb0a3dc2317689891229
2023-10-03 02:46:51 +00:00
Kelvin Zhang
2f9a9ae64b Prevent VABC from being disabled on release-key builds
VABC is mandated now, and plain VAB will be unsupported later.

Test: th
Change-Id: Iad19433c06b25246d4f7bffe5599035836e36076
2023-09-27 09:35:21 -07:00