Commit graph

81 commits

Author SHA1 Message Date
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
Abhishek Nigam
b148ac22f8 Revert "Fix non-AB ota generation failure"
This reverts commit 782b752889.

bug: 308932171
tested: locally generated and applied ota on nonab device
Change-Id: I67b26be01d6240b2cb332e13bc7c7959de128755
2023-11-08 22:29:18 +00:00
Kelvin Zhang
782b752889 Fix non-AB ota generation failure
Test: ota generation on pinot target
Bug: 308615740
Change-Id: I8b540516c0ba9e3acb23eebad8569a6dbf2ef9f3
2023-10-31 19:42:39 -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
c693d95f86 Fix some wording to comply with respectful-code
https: //source.android.com/setup/contribute/respectful-code
Test: Run unit tests
Bug: 161896447
Change-Id: I9a3676b6f7bb6be43756fdf18b1d8b9ec41fb4cf
2020-07-23 10:04:12 -04:00
P.Adarsh Reddy
1ed2d66259 Fix up _CheckSecondTokenNotSlotSuffixed function.
Incremental OTA generation was failing since the
function _CheckSecondTokenNotSlotSuffixed was in
broken state, this change fixes the same.

Bug: 160215626
Test: Incremental OTA now gets generated and applied
      successfully a non-ab device.

Change-Id: Ifb3886396fe65dcdaeba16c568419b9fa084193d
Merged-In: Ifb3886396fe65dcdaeba16c568419b9fa084193d
2020-07-01 01:37:56 +00:00
Yifan Hong
bdb3201353 Use add_slot_suffix function in edify script
Whenever a device is retrieved from fstab, wrap it with
add_slot_suffix() if it has slotselect option.

Test: change fstab (changes boot image, which is a static partition),
      change system partition (a dynamic partition),
      generate incremental OTA with --force_non_ab and apply it on
      cuttlefish
Bug: 153581609
Change-Id: Id3f8e4425b65176baf1b0ff1ee07ab3d820a3a7f
(cherry picked from commit ae6e0d5d28)
Merged-In: Id3f8e4425b65176baf1b0ff1ee07ab3d820a3a7f
2020-05-19 15:23:27 -07:00
Tao Bao
5121655643 releasetools: Track edify function API changes.
In particular, it replaces the generated calls to edify function of
`apply_patch()` and `apply_patch_check()` with `patch_partition()` and
`patch_partition_check()` instead.

It adds two functions to EdifyGenerator: PatchPartition() and
PatchPartitionCheck() for Python releasetools callers. It also tries to
handle the callers of obsolete EdifyGenerator.PatchCheck() and
EdifyGenerator.ApplyPatch(), if their inputs are in known format.
Otherwise it raises an exception to avoid generating an OTA that updater
doesn't understand.

It requires the matching updater changes in the same topic.

Bug: 110106408
Test: Generate an incremental package with the new script and updater.
      Apply the package on device.
Test: Revert the change in ota_from_target_files.py, so that it calls
      the obsolete EdifyGenerator functions. Check that it generates the
      same incremental package.
Change-Id: Ifc55cb40d3a45116fd4d408536d037eca249effa
2018-08-29 11:53:19 -07:00
Tao Bao
76def243ec releasetools: Make scripts pylint clean.
Clean up the following scripts.
  blockimgdiff.py
  common.py
  edify_generator.py
  img_from_target_files.py
  ota_from_target_files.py

Seems we don't have a way to force pylint-ing the scripts using
per-directory pylintrc files (and we don't have pylint tool in AOSP
repo), per
https://android.googlesource.com/platform/tools/repohooks/#todo_limitations.

Test: `m dist`
Test: pylint --rcfile=pylintrc <script.py>
Change-Id: Ia6fd1ddc86f4d84c68e500f225d4a89d0fea8ec7
2018-07-19 10:39:05 -07:00
Tao Bao
a24f711bf3 releasetools: Remove three obsolete functions from EdifyGenerator.
Namely MakeTemporary, Verify and FileCheck. They were once used for
file-based OTA that has been deprecated.

Test: Check that there's no active user, including device-specific
      releasetools script.
Change-Id: Ic73054d73271ad91e860b34b2ba156361c58bc1a
2018-07-06 14:21:26 -07: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
Tao Bao
d2d01e519e Fix the broken script in AssertFingerprintOrThumbprint.
Bug: 62252466
Test: Re-generate an incremental OTA that goes from the fingerprint to
      thumbprint, and check the updater-script.
Change-Id: I6e2cbf68cbd22fbcf0d200fc3fdc8a33da510a53
2017-06-05 12:27:52 -07:00
Tianjie Xu
6a324ba588 Remove the obsolete UnpackPackageDir() in edify generator
package_extract_dir is used in file based OTA only and should be killed.

Bug: 37959785
Test: code search shows no usage of this function in aosp.
Change-Id: Id3719b969c24b7ecef0c7f0e4a3af09a72be54d4
2017-05-23 17:15:14 -07:00
Tao Bao
f388104eaa releasetools: Remove dead functions in EdifyGenerator.
Remove the following functions that are needed for file-based OTAs only:
 - SetPermissions()
 - SetPermissionsRecursive()
 - MakeSymlinks()
 - DeleteFiles()
 - DeleteFilesIfNotMatching()
 - RenameFiles()
 - SkipNextActionIfTargetExists()

Bug: 35853185
Test: Verified there's no reference to these functions.
Change-Id: Iff24a9d705476211effaef28eed2a147fa5fcbce
2017-03-08 16:37:07 -08:00
Alain Vongsouvanh
7f804ba71f releasetools: allow for multiple OEM property values.
This CL changes the --oem_settings flag to allow a comma seperated list of
property files. All property values will be used when asserting properties such
as ro.product.name.

For example, if two property files are provided with ro.product.name values of
"sprout" and "sprout_a", the resulting otapackage will check that the device's
ro.product.name property matches at least one of them.

Bug: 34191373
Test: manual

Change-Id: I954673511be8f0929982235cc9cbfbd85a9ee1f4
2017-02-21 16:09:34 +00:00
Elliott Hughes
ece6ff869c Merge \"Remove obsolete MTD support from the releasetools scripts.\"
am: 63fc2b6766

Change-Id: I26ed21479ab52d535bcc99b13e55a1476a02f76c
2016-06-17 04:59:26 +00:00
Elliott Hughes
305b088729 Remove obsolete MTD support from the releasetools scripts.
Bug: http://b/29250988
Change-Id: I653dc306485c6b35411840b53211d42eb6d19e34
2016-06-16 20:48:47 -07:00
Tianjie Xu
97be5b9b6e Merge "Report error codes in the OTA update script" into nyc-dev
am: 654e4fb023

* commit '654e4fb02368b05cbfba3246b4c634512fa84464':
  Report error codes in the OTA update script

Change-Id: I333bd45886d5915858b762e086d8a263f81b26e2
2016-05-25 21:11:12 +00:00
Tianjie Xu
209db46be1 Report error codes in the OTA update script
Modify the abort() function in the OTA update generation script to
report an error code. The recoveryimage will parse the code and write it
into last_install for further data analysis.

Bug: 28934032
Change-Id: I2d62f81fd352c3102fb84f054972ac0ecb965a21
2016-05-25 12:22:31 -07:00
Tao Bao
3e30d97dde Revert "Revert "releasetools: Support OTAs that have OEM properties changes.""
This CL fixes the bug in [1] (copy-paste error) and reenables it.

We need to handle a special case that an OTA goes from a source build
without OEM properties to a target build with those properties (or vice
versa). Add support in OTA scripts to deal the case properly, by a)
using two oem_props variables to handle source and target builds
respectively; b) adjusting the fingerprint/thumbprint assertions to
allow a mix of both.

[1] commit c086370440

Change-Id: I98118d77d5a0ff694fa1ee33602b5ee5e048599b
2016-03-15 13:28:49 -07:00
Tao Bao
838c68fa1a Revert "releasetools: Support OTAs that have OEM properties changes."
Broke some builds.

This reverts commit c086370440.

Change-Id: If07006db412fea6c04f8698776a2ab418125a469
2016-03-15 19:16:18 +00:00
Tao Bao
c086370440 releasetools: Support OTAs that have OEM properties changes.
We need to handle a special case that an OTA goes from a source build
without OEM properties to a target build with those properties (or vice
versa). Add support in OTA scripts to deal the case properly, by a)
using two oem_props variables to handle source and target builds
respectively; b) adjusting the fingerprint/thumbprint assertions to
allow a mix of both.

Change-Id: Ib517c366730b967a974c89528df9d42887c92ec2
2016-03-07 13:14:49 -08:00
Tao Bao
8cad831b39 resolve merge conflicts of 9baa993c07 to nyc-dev
Change-Id: Ifcfb2da03662ef1b6677c0974605189e2a8e3d20
2016-03-01 15:08:51 -08:00
Tao Bao
df4cb0b2c1 releasetools: Add --oem_no_mount option.
We may have devices with OEM-specific properties but without an OEM
partition (e.g. the properties might be set by init based on hardware
SKUs). For such devices, we supply --oem_no_mount to skip mounting the
OEM partition in the updater-script. The option is only meaningful when
-o (--oem_settings) is specified.

Bug: 27359929
Change-Id: Ic08396e478a82be4188e980e704b33b4f704a8d7
(cherry picked from commit 8608cde944)
2016-02-26 16:10:34 -08:00
Tao Bao
8608cde944 releasetools: Add --oem_no_mount option.
We may have devices with OEM-specific properties but without an OEM
partition (e.g. the properties might be set by init based on hardware
SKUs). For such devices, we supply --oem_no_mount to skip mounting the
OEM partition in the updater-script. The option is only meaningful when
-o (--oem_settings) is specified.

Bug: 27359929
Change-Id: Ic08396e478a82be4188e980e704b33b4f704a8d7
2016-02-26 16:07:16 -08:00
Tao Bao
b4cfca530c releasetools: Add two new entries to metadata.
Add "ota-required-cache" into the metadata file in an OTA package,
which shows the minimum free space on /cache to apply the update.

Add "ota-type" into the metadata file, which shows the OTA type for
this package (i.e. one of FILE, BLOCK and AB).

Also add the cache free space check into updater-script when generating
block-based incremental OTAs (we only had such lines for file-based
incrementals before).

Bug: 26731903
Change-Id: Id6ff0fc4cdfb1443636b0b3800b0f8bddb5bb1d0
(cherry picked from commit d8d14bec0d)
2016-02-10 09:37:40 -08:00
Tao Bao
d8d14bec0d releasetools: Add two new entries to metadata.
Add "ota-required-cache" into the metadata file in an OTA package,
which shows the minimum free space on /cache to apply the update.

Add "ota-type" into the metadata file, which shows the OTA type for
this package (i.e. one of FILE, BLOCK and AB).

Also add the cache free space check into updater-script when generating
block-based incremental OTAs (we only had such lines for file-based
incrementals before).

Bug: 26731903
Change-Id: Id6ff0fc4cdfb1443636b0b3800b0f8bddb5bb1d0
2016-02-08 11:00:27 -08:00
Tao Bao
c386890d0e releasetools: Abort the update on apply_patch failures.
We used to silently ignore the return value from apply_patch() even if
it had failed. It gives us more trouble to investigate the failure when
the affected file/partition gets touched in subsequent OTAs. This CL
adds the checking of the return value and aborts the update accordingly.

Bug: 25893277
Change-Id: Ie5e1c563576e503343e6a5b28ed4d7039f6f919c
2015-12-02 12:26:57 -08:00
Tao Bao
9bc6bb23b5 releasetools: Support generating verify packages.
We can generate a special OTA package that verifies all the partitions
(boot, recovery, system, vendor and etc) on a device. It also calls
device-specific script to verify bootloader and radio images. This
ensures a flashed device contains all the desired images faithfully.

Usage:
ota_from_target_files.py --gen_verify target_files.zip output.zip

Bug: 24679956
Change-Id: Ib3091d98c4b17a6fad305b3edf16d09efbda5c38
2015-11-10 12:49:33 -08:00
Tao Bao
39c322cefc releasetools: Fix the bug in symlink deletion.
For file-based OTAs, symlinks in the source build but not in the target
build will be deleted. However, if a symlink is replaced by a regular
file in the target build, the file will be accidentally deleted when
applying (resuming) the same package again.

Verify the checksum of a symlink that will be unpacked or renamed to.
Delete the file only if it doesn't have the target checksum.

Bug: 23646151
Change-Id: I77bae035e39f2e0be25f7f6d71c5882464e3d50f
(cherry picked from commit 84006eacd0)
2015-09-02 21:21:17 -07:00
Tao Bao
84006eacd0 releasetools: Fix the bug in symlink deletion.
For file-based OTAs, symlinks in the source build but not in the target
build will be deleted. However, if a symlink is replaced by a regular
file in the target build, the file will be accidentally deleted when
applying (resuming) the same package again.

Verify the checksum of a symlink that will be unpacked or renamed to.
Delete the file only if it doesn't have the target checksum.

Bug: 23646151
Change-Id: Ie322abb6022b6fa812c6b36a3127872d9614fc3b
2015-09-02 17:51:16 -07:00
Tao Bao
c94a705f44 Merge "Use fstab in the source build" 2015-06-26 22:57:09 +00:00
Tao Bao
34b47bf42b Use fstab in the source build
When generating incremental OTAs, we should use the fstab in the source
build instead of the target one. Similarly for recovery_mount_options.

Bug: 22011892
Change-Id: Ia02584c71af7d47835b1f62e7daa46f27940a545
(cherry picked from commit bebd3cfbf9)
2015-06-26 15:53:16 -07:00
Tao Bao
bebd3cfbf9 Use fstab in the source build
When generating incremental OTAs, we should use the fstab in the source
build instead of the target one. Similarly for recovery_mount_options.

Bug: 22011892
Change-Id: Idb5c72d1a792e8bb40376a380e3dc06136b13652
2015-06-22 19:27:59 -07:00
Tao Bao
df06e96826 Support SELinux context label when mounting
If there is a SELinux context label in the recovery.fstab, we should
honor that when mounting the partition.

Bug: 19764039
Change-Id: Ic80a3377a5a94c9d10dd464eb1257b157a947510
(cherry picked from commit 548eb76c8f)
2015-06-10 16:20:18 -07:00
Tao Bao
548eb76c8f Support SELinux context label when mounting
If there is a SELinux context label in the recovery.fstab, we should
honor that when mounting the partition.

Bug: 19764039
Change-Id: I4df71a092b418cd340a18b2e3b0936de33d8e3f5
2015-06-10 15:35:34 -07:00
Tao Bao
e7b103751c Fix the wrong error message
apply_patch_space() checks the free space on /cache, not /system.

Change-Id: I70996d5cd5a81fe4871ee738bddb1437e8df6fb9
2015-06-03 09:25:10 -07:00
Dan Albert
8b72aefb5a Make releasetools pylint clean.
This caught a few bugs/syntax errors (a few character classes were not
escaped properly in regex patterns, some indentation was illegal,
etc).

Change-Id: I50637607524e68c4fb9cad7167f58a46b8d26b2c
2015-03-24 11:05:16 -07:00
Tao Bao
3910ebf468 Fix the syntax error in the edify script generator
file_getprop() always expects two arguments.

Bug: 19881931
Change-Id: Icf5577ad34188991c03f68c1217642d3adc4201c
2015-03-22 14:20:48 -07:00
Michael Runge
3e286645ba Add support for tuning partitions
Allow a simple mechanism to call tune2fs to modify an existing
partition without reformatting.

Bug: 18430740
Change-Id: I9210355b6bfec74d002d1f40b930330740f379a5
2014-11-21 00:46:03 -08:00
Michael Runge
63f01de818 Add post-install verification phase
Verify the SHA sum of all patched and extracted files after
a file system remount.

Bug: 18145574

Change-Id: I2f053d085543e10e39153a774542d37ee0a238bd
2014-10-29 02:54:51 +00:00
Michael Runge
7cd99bad21 Allow info_dict from target_files to specify mount options
This will allow safer mount options to be added per mount FS
type, to better ensure data is written during an OTA.
Bug: 18079773, 18092222

Change-Id: I1e3e4fd4639c6fd263e550b770cc3c858ef1e03b
2014-10-22 18:38:49 -07:00
Doug Zongker
fc44a515d4 new block OTA system tools
Replace the xdelta/xz-based block OTA generation with a new system
based on the existing bsdiff/imgdiff tools.

Bug: 16984795
Change-Id: Ia9732516ffdfc12be86260b2cc4b1dd2d210e886
2014-08-26 13:10:25 -07:00
Doug Zongker
c8b4e849f1 full support for OTA of vendor partitions
Make vendor partition a first-class member of the OTA system (for
target_files that contain a VENDOR/ subdirectory).

Build vendor images in a way that is compatible with block-based OTA.
Support updating the vendor partition in both full and incremental,
block and file OTAs.  In most cases this is handled by refactoring the
existing code to handle the system partition to handle either, and
then calling it twice.

Currently we don't support incremental OTAs from a target-files
without a VENDOR subdirectory to one with one, or vice versa.  To add
or remove a vendor partition a full OTA will need to be done.

Bug: 15544685
Change-Id: I9cb9a1267060bd9683a9bea19b43a26b5a43800d
2014-06-16 15:39:54 -07:00
Michael Runge
4f12fceead Add missing quotation mark in assertion
Change-Id: I3e76997fe257bfccb7d61dcc1273e014cdb55a41
2014-05-09 14:14:42 -07:00
Doug Zongker
af845256f1 assert recovery finger/thumbprints, not system
Block OTAs don't have the system partition mounted and so can't use
file_getprop on the system partition.  Make assertions look at the
recovery system finger/thumbprints, which should be the same as the
ones on the system partition (even for sprout devices).

Change-Id: Ie5d329d13beab4b428e37f75da9b9e1b8ceb35bc
2014-05-09 08:29:05 -07:00
Michael Runge
6e836116f7 Add support for verifying OEM properties.
A separate OEM file must be specified to provide the expected
values for these properties.  The list of properties comes from
the "oem_fingerprint_properties" list in misc_info.txt

Bug: b/13367676

Change-Id: I1a3eaf108492132cf6f595a5d1c9f7e0c3cb3142
2014-05-01 17:37:57 -07:00
Doug Zongker
5fad2039bb handle don't care regions in the system image
The system partitions has regions that we shouldn't write and can't
depend on the contents of.  Adds a new script to generate a map of
these regions (using the sparse image as input), and include the map
in the package zip so it can be used when writing or patching the
system partition.

Also fixes a bug where the wrong SELinux file contexts are used when
generating incrementals.

Change-Id: Iaca5b967a3b7d1df843c7c21becc19b3f1633dad
2014-03-03 10:57:23 -08:00
Doug Zongker
25568486e5 add option to specify updater binary, for development
Change-Id: I5f239afff70c87fb16ddc4b8abefa7bbcda6040d
2014-03-03 10:21:27 -08:00
Geremy Condra
36bd365625 Add support for block incremental OTAs
Change-Id: Ie72015e34ed8d7595a5c74c8df41cba73275afab
2014-02-20 12:54:17 -08:00