Commit graph

5256 commits

Author SHA1 Message Date
Tianjie Xu
5edd2821de Merge "Protect SparseImage._GetRangeData() with lock" 2018-01-30 23:34:50 +00:00
Treehugger Robot
709ee786cd Merge "Warn.py: Update errorprone categories" 2018-01-30 02:05:19 +00:00
Tianjie Xu
df1166e92f Protect SparseImage._GetRangeData() with lock
The generator function is not thread safe and is prone to race
conditions. This CL uses a lock to protect this generator and loose the
locks elsewhere, e.g. 'WriteRangeDataToFd()'.

Bug: 71908713
Test: Generate an incremental package several times for angler 4208095 to 4442250.
Change-Id: I9e6f0a182a1ba7904a597f403f2b12fe05016513
2018-01-29 11:52:10 -08:00
Tianjie Xu
8a7ed9f771 Double check the sha1 for ranges during package generation
Check that the Sha1 for src&tgt ranges are correct before computing
patches. This adds ~6 seconds overhead for ~2400 commands.

Bug: 71908713
Test: Generate an incremental package from angler 4208095 to 4442250.
Change-Id: I8cf8ce132fb09a22f7d6689274ddb4a27770be76
2018-01-28 01:54:52 +00:00
Andreas Gampe
cf528ca79d Warn.py: Update errorprone categories
From current tip-of-tree.

Bug: 72451126
Test: build/make/tools/warn.py errorprone.log
Change-Id: I1d632fb8801b74af695b4f7f464a99792e46637a
2018-01-25 12:25:20 -08:00
Jaekyun Seok
b7735d8105 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
2018-01-25 09:33:58 +09:00
Treehugger Robot
082837365d Merge "Add BOARD_EXT4_SHARE_DUP_BLOCKS to share duplicated blocks on ext4" 2018-01-24 04:10:42 +00:00
Tianjie Xu
07a4299182 Merge "Don't check the stderr output from bsdiff/imgdiff" 2018-01-23 06:10:46 +00:00
Tianjie Xu
a2a9f9990f Don't check the stderr output from bsdiff/imgdiff
bsdiff/imgdiff returns non-zero values correctly in case of failures.
So we don't need to check the stderr anymore. This avoids some false
reports of the diff program.

Bug: 72335938
Bug: 71505046
Test: Check the exit value of bsdiff/imgdiff in code search,
      generate a package for angler.

Change-Id: I18f0c3882a40a5288d6aee715713a05270e0db2b
2018-01-23 01:29:56 +00:00
Jin Qian
fde9f7906b Add BOARD_EXT4_SHARE_DUP_BLOCKS to share duplicated blocks on ext4
This option applies to system.img and vendor.img.

Bug: 64109868
Change-Id: Ib4c7384049dca08e57441ef71cc81c2fba4462dd
2018-01-22 17:21:11 -08:00
Treehugger Robot
8413824f4b Merge "releasetools: Add PayloadSigner class." 2018-01-22 18:54:57 +00:00
Ng Zhi An
9446c1df98 Fix order of args passed to mksquashfsimage.sh
Bug: 72234456
Test: make systemimage
Change-Id: I1b4b07f0a488eade2f297fea12d02b6e8ccba7d8
2018-01-19 15:55:39 -08:00
Treehugger Robot
3221f0f387 Merge "releasetools: Dump mkfs/fsck/simg2img outputs on error." 2018-01-19 22:35:47 +00:00
Tao Bao
fabe08352c releasetools: Add PayloadSigner class.
Create a wrapper class that handles the payload signing, which unifies
the paths with and without external signer. Also add tests for the newly
added class.

The test keys under testdata/ are created with the script in
development/tools/make_key. testdata/testkey_with_passwd.pk8 uses
password "foo".

Test: python -m unittest test_ota_from_target_files
Test: Get identical A/B OTA packages w/ and w/o the CL.
Change-Id: Ic770aec726498a3babb88ec509985e7f1210fb18
2018-01-19 13:25:04 -08:00
Tao Bao
cd53a89599 releasetools: Dump mkfs/fsck/simg2img outputs on error.
The output (stdout and stderr combined) would be helpful in understanding
the cause of the failure.

Not changing other occurrences in build_image.py yet, since it's less
obvious if a failed call should be considered fatal (thus whether to
dump such outputs). For example, GetVeritySize() simply returns 0 on
failed calls. They deserve further clean-ups in later CLs (with unit
tests).

Bug: 71864688
Test: Inject errors into mke2fs/e2fsck/simg2img. `m snod` prints outputs.
Test: `m snod` remains quiet on successful runs.
Change-Id: I172403f6cd05bce93767265dbcb110271a68e2a8
2018-01-19 11:15:42 -08:00
Tao Bao
a2ff4c9b06 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
2018-01-18 23:37:29 -08:00
Tao Bao
bea20ac722 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
2018-01-18 23:37:23 -08:00
Treehugger Robot
13f228ebde Merge "releasetools: Remove the reloading of target info dict." 2018-01-18 22:48:15 +00:00
Andreas Gampe
7f494c121f Warn: Change GuardedBy regular expressions
This was modified in commits 20a8664 "Change canonical name for
GuardedByChecker to GuardedBy" and 1f6dc3dc "Merge GuardedByValidator
into GuardedByChecker."

Test: m
Test: manual
Change-Id: I07305e59694a955e52bd69c1cbe53346808b78aa
2018-01-17 21:28:21 -08:00
Tao Bao
d32e78fd3c releasetools: Add a note for the ZipInfo._decodeExtra() workaround.
Test: N/A
Change-Id: I9e84fc27230182f17c2fda0df57a2c149281dcda
2018-01-17 10:10:00 -08:00
Tao Bao
df3a48b43e releasetools: Consolidate the codes that generate metadata dict.
Now they (A/B, non-A/B full and non-A/B incremental) share the same
code. Also add tests for the newly added function.

Test: python -m unittest test_ota_from_target_files
Test: Build A/B and non-A/B packages respectively.
Change-Id: I5499dd9c683ac1a18d8a24f21ff8845fe69f343e
2018-01-16 15:34:27 -08:00
Tianjie Xu
a7229a08b7 Merge "Iterate through the sorted file map when finding transfers" 2018-01-13 00:01:03 +00:00
Tianjie Xu
20a86cdd8d Iterate through the sorted file map when finding transfers
This helps to generate a deterministic package.

Bug: 71770360
Test: Generate a incremental package and transfers are added by file name.
Change-Id: I7562a200b97a1babbb09a77801324cc9408cc01f
2018-01-12 12:21:00 -08:00
Tao Bao
2db1385db5 releasetools: Remove the reloading of target info dict.
In non-A/B OTA path, we've been loading the info dict for the target
build twice (once to have a peek at the OTA type, with a reload after
unzipping the target-files zip). Remove the reloading.

This CL moves the loading of the source info dict up a bit to avoid
having two copies in the A/B and non-A/B paths. It also moves up the
sanity checks of the loaded info dicts before unzipping the target-files
zips.

Test: Generate full and incremental packages for bullhead and marlin.
Change-Id: Iccb953feb0b6ecf62e6f73d6e9ceea00077d098d
2018-01-11 21:59:30 -08:00
Treehugger Robot
896fa043bc Merge "releasetools: Remove the fallback-to-full logic." 2018-01-11 22:24:36 +00:00
Treehugger Robot
155a140c82 Merge "releasetools: Remove two dead functions in ota_from_target_files.py." 2018-01-11 22:23:18 +00:00
Tianjie Xu
c56071b21b Merge "Sort the split transfers to generate a determinate package" 2018-01-11 04:15:28 +00:00
Tao Bao
175df38e6c releasetools: Remove two dead functions in ota_from_target_files.py.
GetBuildProp() and GetVendorBuildProp() have been factored into
BuildInfo class. These two functions were meant to be deleted in commit
481bab8d48.

Test: python -m unittest test_ota_from_target_files
Test: No users of these two functions.
Change-Id: Id590a46d597939973ef2339cdfea4f5163548d4d
2018-01-10 19:57:57 -08:00
Tao Bao
32b80dca9f releasetools: Remove the fallback-to-full logic.
The fallback-to-full logic doesn't look beneficial, but may hide away
real bugs, especially when it's on by default.

Test: Generate an incremental non-A/B OTA successfully.
Test: Inject bugs into script; observe that incremental OTA
      generation errors out instead of silently falling back.
Test: No internal users of the flag from code search.
Change-Id: Ifc627d898552c0bd72463e8c107e36610421608e
2018-01-10 14:03:16 -08:00
Tao Bao
b54f6157a4 Merge "releasetools: Add a BuildInfo class." 2018-01-10 20:37:41 +00:00
Tianjie Xu
d3bf67e1d3 Sort the split transfers to generate a determinate package
We split large apks and generated patches for them in parallel,
resulting in nondeterminate packages between different runs. This CL
sort the split transfers by target name first; and then add them
sequentially to the final transfer list.

Also fix a side effect where we may generate a wrong sha1 for split
ranges due to synchronization error.

Bug: 71770360
Bug: 71759418

Test: Generate the package several times, compare the log and the transfer list.
Change-Id: I2a49e22594d59ffaa98b11edc776be4e3c4c561f
2018-01-10 12:23:57 -08:00
Tao Bao
481bab8d48 releasetools: Add a BuildInfo class.
Prior to this CL, we have similar codes in different paths
(WriteFullOTAPackage / WriteBlockIncrementalOTAPackage /
WriteABOTAPackageWithBrilloScript). This CL factors out the common codes
that deal with OEM-specific properties into BuildInfo class, and adds
tests for the new class.

Test: python -m unittest test_ota_from_target_files
Test: Create an incremental package that uses and doesn't use OEM
      properties respectively.
Test: Create a full package that uses and doesn't use OEM properties
      respectively.
Change-Id: Ida914cace12803d55396fa503bafcac2db2a520e
2018-01-09 15:08:23 -08:00
Elliott Hughes
1a701d93f9 adbs was broken for a year and no-one noticed.
Time to remove it.

Bug: https://b/15270043
Test: N/A
Change-Id: Idb56fc99c213732eca75f81ddd9d7a8a19374b42
2018-01-08 13:55:00 -08:00
Treehugger Robot
e3692095a1 Merge "releasetools: Add tests for common.ReadApkCerts()." 2018-01-05 23:30:53 +00:00
Tao Bao
818ddf5e7e releasetools: Add tests for common.ReadApkCerts().
Test: python -m unittest test_common
Test: Run sign_target_files_apks.py on a target with compressed APKs.
Change-Id: I107a8b8f2f0f82e2d1947f14c8a8b3778f633b11
2018-01-05 11:53:55 -08:00
Colin Cross
96029a1276 Merge changes I9fda7fe3,I0a34b2b4,Ie64a283d
* changes:
  Clear resource_export_package outside conditionals
  Fix adbs after move from build/tools to build/make/tools
  Use proguard.jacoco.flags for EMMA_INSTRUMENT_STATIC
2018-01-05 06:22:35 +00:00
Colin Cross
d31ff8ff32 Fix adbs after move from build/tools to build/make/tools
adbs broke when build/tools was moved to build/make/tools in
aosp/286781.

Bug: 15270043
Test: build/tools/adbs
Change-Id: I0a34b2b446f996bcc53a7dde6381402f8eed9bd0
2018-01-03 14:21:35 -08:00
Tao Bao
c72727ac3f releasetools: Clean up build_image.py.
Mostly cosmetic changes, such as moving print statement to print
function. The only functional change is to wrap the file opening in
Append() with try statement, which would dump the error message as
needed.

Test: `m dist`
Test: python -m unittest test_build_image
Change-Id: I4e6c593517cf737bfcbe51bc533b22a247b10e44
2018-01-03 11:52:28 -08:00
Tao Bao
d8a953d7ab releasetools: Move assertions into CheckHeadroom().
Assert the input arguments inside CheckHeadroom() function, and add
matching tests. Also use common.MakeTemp{File,Dir} in tests.

Test: `m dist`
Test: python -m unittest test_build_image
Change-Id: Ib45f24651af9591a9cfdd72aac3558f6c9a80f44
2018-01-03 11:52:16 -08:00
Tao Bao
e838d1446c releasetools: Clean up ReplaceVerityKeyId and add tests.
Test: python -m unittest test_sign_target_files_apks
Test: Run sign_target_files_apks.py on marlin target_files.zip.
Change-Id: Ic3c3f4f14c73f8f8e48a8341e024e0861e665989
2018-01-02 12:29:31 -08:00
Tao Bao
1c830bfbaa 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
2018-01-02 12:22:01 -08:00
Treehugger Robot
7d100ce03b Merge "releasetools: Clean up sign_target_files_apks.py." 2018-01-02 19:56:03 +00:00
Tao Bao
0c28d2d02d releasetools: Clean up sign_target_files_apks.py.
Mostly cosmetic changes, such as replacing print statement with print
function. Also change 'import cStringIO' to optionally look for the one
in io module, to allow Python 2/3 compatibility.

Test: pylint --rcfile=pylintrc sign_target_files_apks.py
Test: Run sign_target_files_apks.py on marlin target_files.zip.
Change-Id: I4dc98b01da6f89e624114bbca5522f659901c1f2
2018-01-02 09:57:29 -08:00
Tao Bao
186ec99eb9 releasetools: Fix a bug in blockimgdiff.HeapItem.
HeapItem defines __bool__(), which contains a logical error that should
return the opposite value.

Note that the bug only manifests while using Python 3, which calls
__bool__(). With Python 2, `if x:` or bool(x) actually calls
x.__nonzero__() or x.__len__(). If a class defines neither __len__() nor
__nonzero__(), as the case in HeapItem, it always returns True.

Test: python -m unittest test_blockimgdiff
Test: python3 -m unittest test_blockimgdiff
Test: Generate an incremental non-A/B OTA package successfully.
Change-Id: Ibe8430e0b495a7d2f430cfffb716d2536ffb53d2
2018-01-02 09:54:32 -08:00
Dan Shi
9a50168c85 Test config should use manifest package attribute
Bug: 70981774,69929803
Test: m -j SetupWizardActivityTests
Change-Id: I6d50744504eac71d6ecae5db9b14e6d30eb923fe
2017-12-22 13:34:50 -08:00
Tao Bao
be8ea6ec11 Merge "releasetools: Remove the dead code for blockimgdiff_version <= 2." 2017-12-21 22:20:32 +00:00
Dan Shi
3c28ff7bff Merge "Auto generate test config files" 2017-12-21 21:53:12 +00:00
Tao Bao
0582cb639f releasetools: Remove the dead code for blockimgdiff_version <= 2.
The code is on infeasible path since we already have assertions in
common.BlockDifference().

Also remove the dead code that checks for OPTIONS.info_dict, as we
already set that in ota_from_target_files.main(), for both of A/B and
non-A/B.

Test: Generate incremental OTAs w/ and w/o the CL, and get identical
      packages.
Change-Id: Ifb8fc101e78f5ce58c60c8e49028b66ce0d20246
2017-12-21 11:53:27 -08:00
Tao Bao
2f5358d38b releasetools: Fix the bug that skips loading OEM dict.
The CL in [1] unintentionally breaks the OEM dict loading logic in the
incremental BBOTA path. We should always require and load the OEM
property dict if _either_ of the source and target builds uses OEM
properties. Otherwise with the current "and" operator, it skips loading
the OEM property dict and thus fails to generate an OTA package that has
OEM property changes (e.g. updating from build with fingerprint to
another one using thumbprint).

The CL in [1] actually makes the right change in the file-based OTA
path, but introduces the bug in the block-based OTA path.

This CL also cleans up the line that reads recovery_mount_options.

[1] commit 7f804ba71f ("releasetools:
allow for multiple OEM property values.").

Test: Genearte an OTA that has OEM property changes successfully.
Change-Id: Idce4ad59825d432618535ce09ab22bd7ddc524f2
2017-12-20 23:06:02 -08:00
Dan Shi
efb892d858 Auto generate test config files
This change allows one to run atest <module name>. The TradeFed test
config file will be automatically created in testcases directory based
on the settings.

Bug: 69929803, 69932044
Test: m -j NotificationStressTests libminijail_test
add following lines in notificationtests/Android.mk,
before "include $(BUILD_PACKAGE)"
LOCAL_COMPATIBILITY_SUITE := general-test

Change-Id: Ib5e9cd152d957b5d5beb6ed23a899a021a7e06d6
2017-12-20 15:05:17 -08:00