Commit Graph

1581 Commits

Author SHA1 Message Date
Mark Salyzyn c777eaa779 build_image: hard code set inode size to 256
inode-size will jump around based on filesystem size, however
readonly Android system partitions have a specific pattern of
xattr associated with sepolicy and 256 is the most efficient at
absorbing the content.

Test: manual
Bug: 122328872
Change-Id: I06dd6a503067ab6477293b386d56a89dd86b0e83
2019-01-10 14:49:12 -08:00
Tao Bao 519d18286e Don't build retrofit OTA package if vendor.img is unavailable.
We used to build retrofit full OTA package as long as
PRODUCT_RETROFIT_DYNAMIC_PARTITIONS is true. This doesn't work with AOSP
targets that have the flag set but without any available vendor image.

This CL detects such a condition and uses a separate flag to guard the
retrofit OTA building as well as the split super images generation.

Bug: 120852744
Test: `m -j dist` on blueline (w/ vendor images) and aosp_blueline (w/o
      vendor images).
Change-Id: I65726f24f8fc546be6802941a6a06590a3804c16
2019-01-07 12:22:48 -08:00
Treehugger Robot dacde2259f Merge "Increase slack for inode estimation algorithm" 2019-01-05 01:22:43 +00:00
Hridya Valsaraju e8e7958c13 Increase slack for inode estimation algorithm
This is required to prevent build failure on some targets.

Test: mmm
Bug: 119115481

Change-Id: Idf7c21b163a4e10e2ef435c2b2a7795a42feb200
2019-01-04 09:18:07 -08:00
Yifan Hong cc46eae994 Put system_other in super.img
... for launch A/B devices.
Test: build super image and lpdump
Bug: 113182233

Change-Id: I79ad9da2f6852b39b23e862ff00f320b6565db2f
2019-01-02 12:05:10 -08:00
xunchang 3df4d5eb6d blockimgdiff: add a function to select and convert 'diff' to new
Package size will be unintended large if we stash more blocks than the
stash limit specified by the cache size. To reduce the maximum size of
simultaneous stashed blocks, we will inevitably convert some 'diff'
commands to 'new' commands.

To mitigate the impact, we add a new function to smartly select the
transfers to convert based on their patch size and compressed size.
This cl converts the transfers that have a larger patch size than the
compressed target sizes. And there's a slightly improvement in the
final package size: from 194M -> 185M.

Bug: 120561199
Test: build a non-A/B incremental package, run simulator
Change-Id: Id73ff736ba4e6901d245ad5549d42310d0740284
2018-12-19 20:21:25 -08:00
Treehugger Robot 7cac3adf1a Merge "Relax inode usage estimation slack for DAP right sizing" 2018-12-18 02:13:10 +00:00
Hridya Valsaraju bd17fab260 Relax inode usage estimation slack for DAP right sizing
The current increase of 4 % is insufficient for some
targets.

Test: mmm
Bug: 119115481
Change-Id: Idcba8025b913da9b70794bfc7464d15b4d99ad34
(cherry picked from commit 3e02e34090)
2018-12-14 14:13:24 -08:00
Tianjie Xu 8ab919dcce Merge "blockimgdiff: Factor out the diff_worker" 2018-12-13 18:45:30 +00:00
xunchang 2153183acf blockimgdiff: Factor out the diff_worker
We will call it at an earlier time to compute the patch size; and
choose the transfers to convert to 'new'.

Bug: 120561199
Test: Generate an incremental update on shiner
Change-Id: I29a0c8e75c9e5b66a266c1387186692a86fcbe43
2018-12-12 17:02:39 -08:00
Chen, ZhiminX 752439b321 Add recovery_acpio option to make recovery image
Test: can generate recovery image with recovery_acpio
Fixes: 111871613

Change-Id: I9174a4741f571a00bcadc548cd9e1316b4175132
2018-12-11 15:23:28 +08:00
Yifan Hong e98427ac3f Don't build super image if source images are missing
For some internal branches, vendor.img isn't built, so there
is no need to build super image / super split images there.

Test: remove vendor.img and VENDOR/ from target_files_intermediates, then
      run add_img_to_target_files
Fixes: 120634805

Change-Id: I2834a27ce232538f203733c204dd257279c789fc
2018-12-07 11:01:21 -08:00
Tao Bao 2a20f344fc releasetools: Keep the original RangeSet for 'uses_shared_blocks' case.
Setting 'uses_shared_blocks' indicates that the block list for a given
file is incomplete, as some of the blocks are "owned" by others. As a
result, such a file will be skipped from imgdiff'ing.

This CL makes a copy of the original block list before removing the
shared blocks. It uses the original RangeSet as the value of
extra['uses_shared_blocks']. validate_target_files.py will try to read
the file as in the original RangeSet, unless the original list is also
incomplete or has non-monotonic ranges.

Test: Run validate_target_files on a target that uses
      `BOARD_EXT4_SHARE_DUP_BLOCKS := true`.
Change-Id: I259e871ecc249ba0c14b5796bef413185a1b8242
2018-12-06 10:28:49 -08:00
Yifan Hong 5df29604b9 Merge changes from topic "super_target_files"
* changes:
  add_img_to_target_files uses build_super_image
  Build super_empty with build_super_image.py
  Build super.img from images in target_files
2018-12-04 23:20:21 +00:00
Yifan Hong 055e6cf5c8 add_img_to_target_files uses build_super_image
Use the new script to build super_empty and super split images. No more
transformation to lpmake_args.

Test: build target_files_package for retrofit device
Change-Id: Id5f6bd607654ca869bcdf58d86b7ae300e3927eb
2018-12-03 11:33:44 -08:00
Yifan Hong 2b891ac024 Build super.img from images in target_files
For non-retrofit (launch) devices, super.img is used for factory, so
source images should be from target_files.

In this change, build-superimage-target procedure is converted to a
more flexible script so that it can be built.

Bug: 119322123
Test: build target files for device launch with dynamic partitions
Change-Id: I6ee0cc3e145357dfc74be248f81f5f8f4e51fc5c
2018-12-03 11:33:44 -08:00
David Anderson 6f693f04c2 releasetools: Specify a minimum size for right-sized images.
On aosp_blueline, system_other gets right-sized to 61,440 bytes. This
messes up the AVB footer calculation, and is too small to store an ext4
image.

Bug: 116608795
Test: build aosp_blueline w/ dynamic partitions
Change-Id: If0138a9d858765ff82cb957532504a066fd113ff
2018-11-29 13:27:47 -08:00
Tao Bao 03fecb669c releasetools: Remove the mismatch map files when generating retrofit OTAs.
The map files contain the filename-block mapping for the original
images.

Bug: 120109184
Test: Generate an incremental OTA that was previously failing.
Change-Id: I1285d0b24a435477b958e6c2e4f474acf8f7578b
2018-11-28 10:59:23 -08:00
Treehugger Robot 08d07f5aa9 Merge "Infer prebuilt image size" 2018-11-28 00:36:50 +00:00
Yifan Hong 70fc029ab8 Infer prebuilt image size
Test: call script twice; the second time uses prebuilts
Fixes: 119769527

Change-Id: Icd98a4dbfed91538cbc07aab957c7b042c05b330
2018-11-27 11:21:21 -08:00
Tao Bao f21a8f5376 Merge "Use common.RunAndCheckOutput() in add_img_to_target_files.py." 2018-11-26 18:41:36 +00:00
Yifan Hong 50611038e9 dynamic_partition_use -> use_dynamic_partitions.
Test: build OTA package
Change-Id: Ia43d23f49fc024ecc767da1c2186c4b446c034de
2018-11-21 13:00:57 -08:00
Tao Bao 2764aee664 Use common.RunAndCheckOutput() in add_img_to_target_files.py.
Test: `m dist` with aosp_marlin-userdebug
Test: python -m unittest test_add_img_to_target_files.py
Change-Id: Icff60a44e5c189c2443fbaba3fc6a2b106b409ea
2018-11-21 11:04:32 -08:00
Yifan Hong 50e7954ac9 Generate retrofit OTA.
Test: m otapackage -j, manual apply on top of P
Bug: 118506262

Change-Id: Iedc389a1058007a604de0482f2348a9ef0d5892a
2018-11-20 11:17:39 -08:00
Yifan Hong c767f7cbfc Add split super images to target_files.
Test: build target files package
Bug: 118506262
Change-Id: Iee6143987c9bfa6f2d287e20c06ea5ef25e82985
2018-11-20 11:17:39 -08:00
Tao Bao 9788b4ed31 releasetools: Temporarily disable verifying AVB-signed images.
Bug: 119624011
Test: Run validate_target_files.py on aosp_blueline-target_files.zip.
Change-Id: I0c3a93dd2ec9fe26c62be2ac2cc26780fb9fe1a6
2018-11-15 13:46:56 -08:00
Mark Salyzyn 3cd2460edc build: Split out mkfs in BuildImageMkfs (retry)
NB: second attempt, issue with scope for mkfs_output.

Separate out BuildImageMkfs from BuildImage, which just makes the
filesystem without any verity, avb, or other decisions.  BuildImage
does all the wrapping for such.  This will hopefully ease maintenance
and drop the issues surrounding BuildImage reentrancy.

Change right-size estimation path to use BuildImageMkfs, and thus do
so without verity or avb wrappings.  Add partition_headroom to space
consideration.  This makes the results of the estimation more
accurate and predictable.

Test: build
Bug: 111302946
Change-Id: I2549bd4e403c21290470b2fa1835492ae883f0fd
2018-11-08 15:42:22 -08:00
Mark Salyzyn 533558ec96 Revert "build: Split out mkfs in BuildImageMkfs"
This reverts commit 2b72b7f01e.

out/target/product/generic_x86/installed-files.txt \${DIST_DIR}/installed-files-rescued.txt; exit 1 ) )" 
2018-11-08 19:12:28 - build_image.py - ERROR : Failed to build out/target/product/generic_x86/obj/PACKAGING/systemimage_intermediates/system.img from out/target/product/generic_x86/system 
Traceback (most recent call last): 
File "build/make/tools/releasetools/build_image.py", line 767, in <module> 
main(sys.argv[1:]) 
File "build/make/tools/releasetools/build_image.py", line 755, in main 
BuildImage(in_dir, image_properties, out_file, target_out) 
File "build/make/tools/releasetools/build_image.py", line 449, in BuildImage 
CheckHeadroom(mkfs_output, prop_dict) 
NameError: global name 'mkfs_output' is not defined 


Bug: 111302946
Reason for revert: Build problem

Change-Id: I786f232e07af653a7207509055df5a07a6d8bb9e
2018-11-08 19:26:50 +00:00
Mark Salyzyn 2b72b7f01e build: Split out mkfs in BuildImageMkfs
Separate out BuildImageMkfs from BuildImage, which just makes the
filesystem without any verity, avb, or other decisions.  BuildImage
does all the wrapping for such.  This will hopefully ease maintenance
and drop the issues surrounding BuildImage reentrancy.  Change
right-size estimation path to use BuildImageMkfs, and do so without
verity or avb wrappings.

Test: build
Bug: 111302946
Change-Id: I30e2e2b727f40ecca5164142f34139f5244f6424
2018-11-07 15:51:32 -08:00
Mark Salyzyn 41f781de9e build_image: right size image problems.
Neglected to correct for filesystem size in estimate for verity.

To keep build space optimized and make sure that the existing image
does not confuse the tools, remove the out_file after the test build
image phase.

Test: build
Bug: 111302946
Change-Id: I360775d862d02a721d061bbc43e8b4e2f03bd01e
2018-11-07 14:50:33 -08:00
Tao Bao 68b081fd5a Merge "releasetools: Add tests for VerityImageBuilder." 2018-11-07 20:23:12 +00:00
Anton Hansson 0e60f8a42c Make right-sizing less aggressive
This is a rollback of Id5ae6645b9aa2d036e6fefe2fb17672e8f8ef6f0
and the followup I6a0f3919e8d45d0b3e7cd558a6ad4d3799012f2c

The magic constant introduced appears to be too aggressive.
Note that the new constant in I0f32c75e80b5da4d47671055ac274ccc2b485992
doesn't appear to fix the broken builds.

Bug: 111302946
Test: make
Change-Id: I29207265172d293c6fee98212e3266bde85895df
2018-11-07 14:02:42 +00:00
Mark Salyzyn 2b191894c2 build_image still too aggressive with right sizing (part troix)
Regression introduced by c3d408e3c1

Found a case where 1 + 1/60 reduction in size based on free space
failed when right sizing an ext4 image. Reduced the math to 1 + 1/61.

Test: compile
Bug: 111302946
Change-Id: I0f32c75e80b5da4d47671055ac274ccc2b485992
2018-11-06 15:57:03 -08:00
Tao Bao d0b9758203 Merge "releasetools: Create VerityImageBuilder." 2018-11-06 23:37:15 +00:00
Tao Bao 46901fb8ca releasetools: Log the exceptions before rethrowing.
In Append2Simg and Append in verity_utils.py, we catch and rethrow
exceptions as BuildVerityImageError. However, this suppresses the
traceback from the original exception which usually indicates the actual
cause. We can better handle this with the raise statement in Python 3,
which is however unavailable in Python 2.

This CL logs the exception before rethrowing to retain the useful bits.

Test: Inject an error to append2simg. `m -j systemimage` with
      aosp_marlin-userdebug. Check the output.
Change-Id: I0c2f57d6023fa1038256b85fa98d57ad0244a70d
2018-11-06 10:42:35 -08:00
Tao Bao 4a0d5134e1 releasetools: Add tests for VerityImageBuilder.
`testdata/verity_mincrypt` is generated with the following command.
  $ generate_verity_key \
        -convert testdata/verity.x509.pem \
        testdata/verity_mincrypt

Test: python -m unittest test_verity_utils
Change-Id: I3f2f0cd89da0fd5d2420e0e2b09761cc77f893c5
2018-11-06 10:00:51 -08:00
Tao Bao 7549e5e919 releasetools: Create VerityImageBuilder.
Test: `m dist` with aosp_marlin-userdebug (VB 1.0)
Test: `m dist` with aosp_taimen-userdebug (VB 2.0)
Test: `python -m unittest discover .`
Change-Id: I8c016b7621b73f220fb2a4586cc45a21eeee438d
2018-11-06 10:00:28 -08:00
Mark Salyzyn 4a6ce93f27 build_image too aggressive with right sizing
Regression introduced by c3d408e3c1

Found a case where 1 + 1/59 reduction in size based on free space
failed when right sizing an ext4 image. Reduced the math to 1 + 1/60.

Test: compile
Bug: 111302946
Change-Id: I6a0f3919e8d45d0b3e7cd558a6ad4d3799012f2c
2018-11-01 12:45:29 -07:00
Tao Bao 757dfe8792 Merge "Revert "Work around e2fsck issue for building sparse GSIs"" 2018-10-30 15:18:58 +00:00
Tao Bao 27809667b4 Revert "Work around e2fsck issue for building sparse GSIs"
This reverts commit ec7fa1cd09.

The earlier e2fsck issue has been addressed by [1].

[1] https://android-review.googlesource.com/c/platform/external/e2fsprogs/+/725259/

Bug: 112062612
Test: m PRODUCT-aosp_x86_64-eng \
          SANITIZE_HOST=address ASAN_OPTIONS=detect_leaks=0 \
          -j e2fsck systemimage
Change-Id: I7287cb8639ae45abdf753821421bd070b819a30e
2018-10-29 16:02:47 -07:00
Mark Salyzyn f0cef8d8bf build_image setup ext4 dedupe on more images.
Add ext4 dedupe to system_other, product, product_services, odm and
oem images.  Experimental savings without any other configuration
changes was 0%, .75%, 3.4% respectively for the raw image file size
for the first three.

Test: manual
Bug: 111302946
Change-Id: Ia8fb5696151acad59bb144ea93f2c2ddac962bbd
2018-10-29 13:37:10 -07:00
Mark Salyzyn c3d408e3c1 build_image tune right-size image
To more quickly settle on a no free space result, recognize that
there is roughly 1/58.5 overhead managing the free space pool as
determined experimentally.  This algorithm carries with it some
risk of being sensitive to any alterations in ext4.

This also addresses the issue of a much larger apparent free space
available calculated on the sample pass when deploying ext4 dedupe,
and resolves the poorer estimation that happens without accounting
for the overhead.

The alternative of adding a second pass works to a similar, and
likely more comforting algorithm and result.  But doing so adds
a minute to the typical incremental build time, or +50% to the
time it takes to determine ext4 right sized images.

Test: manual
Bug: 111302946
Change-Id: Id5ae6645b9aa2d036e6fefe2fb17672e8f8ef6f0
2018-10-29 13:37:04 -07:00
Tao Bao f3fc62c8a0 releasetools: Fix the error message.
This avoids showing a message as below:

raise BuildImageError("Failed to get tune2fs usage:\n{}".format(output))
UnboundLocalError: local variable 'output' referenced before assignment

The `output` won't be set under such a case, which unfortunately hides
the real cause. This CL addresses the issue by letting it throw
implicitly, which contains the command and outputs.

Test: `m dist`
Test: `python -m unittest test_build_image`
Change-Id: Icf015bab8869d150516246ed73552f6502127cdf
2018-10-25 12:29:44 -07:00
Mark Salyzyn 780f595fac build_image: improvements to right size for dynamic partitions
If partition_reserved_size is 0 or undefined, and
use_dynamic_partition_size is true, we should approach no space
and no free inodes automatically.

Estimate the space and number of inodes required, then do a first
pass build to see how much space actually used, and use those values
to refine the estimate.

Depends on tune2fs to report the characteristics of the filesystem,
so only support for ext filesystems.  In the future if there has to
be a more generic ability, either a tool per a filesystem has to be
found, or we will need root capabilities to mount the filesystem to
acquire the characteristics live from the host system.

Test: manual + python -m unittest test_build_image
Bug: 111302946
Change-Id: I933a388be43516b6de7b5007b296765bd5556fde
2018-10-23 15:14:00 -07:00
Tao Bao 7ceac730cf Merge "releasetools: Include descriptor of `vbmeta_system.img` in `vbmeta.img`." 2018-10-23 20:03:47 +00:00
Tao Bao 7106420add releasetools: Include descriptor of `vbmeta_system.img` in `vbmeta.img`.
Chained vbmeta images should be included into the top-level vbmeta.img
as chained partitions. It's done in the path of `m`, but not `m dist`.

Bug: 118115607
Test: `m dist` a target that uses chained vbmeta.
    a) Check that the `vbmeta.img` in target-img.zip contains the image
       descriptor of `vbmeta_system.img` (`avbtool info_image`).
    b) `avbtool verify_image --image vbmeta.img \
            --expected_chain_partition \
                vbmeta_system:1:/path/to/vbmeta_system/pubkey`
    c) `avbtool verify_image --image vbmeta_system.img`
Change-Id: I064e583b247c44b9b2f19355838550bb5dbb8f26
2018-10-22 15:27:54 -07:00
Tianjie Xu ffbe6b9785 Install the ota keys under recovery as a zipfile
Recovery can now parse the pem encoded x509 keys from a zipfile. So
instead of dumping the keys into a text file with some intermediate format,
we can simply create a zipfile with the keys.

Bug: 116655889
Test: make bootimage and check the generated zipfile, run sign_target_files_apks
Change-Id: Ib76feecfb26d6be713a07644e80ec96133759004
2018-10-22 14:47:15 -07:00
Tao Bao 898a924904 releasetools: Log to stdout when running tests.
This sets up the root logger while running tests. It also logs to
stdout, as our Python test result parser doesn't like outputs from
stderr.

Test: `python -m unittest discover build/make/tools/releasetools \
          > /dev/null` doesn't print log lines.
Change-Id: Ic99711bd458bc4b67b38226786fed604c2168476
2018-10-18 15:05:49 -07:00
Tao Bao 32fcdab512 releasetools: Switch to Python logging.
Converts the following files to Python logging.

add_img_to_target_files.py
blockimgdiff.py
build_image.py
check_ota_package_signature.py
common.py
img_from_target_files.py
make_recovery_patch.py
ota_from_target_files.py
sparse_img.py
verity_utils.py

This separates logging outputs from normal outputs, and allows easier
switching between different verbosity levels. It also supports adjusting
logging config via environment variable (LOGGING_CONFIG).

Test: `m dist`
Test: `python -m unittest discover build/make/tools/releasetools`
Change-Id: Idfc3f7aff83e03f41f3c9b5067d64fd595d5192d
2018-10-17 07:51:04 -07:00
Treehugger Robot 86fb70dcdc Merge "Rename vbmeta_mainline to vbmeta_system." 2018-10-16 22:02:48 +00:00