Commit graph

135 commits

Author SHA1 Message Date
Tao Bao
87742421b2 am 2e30a5e8: am 708c4623: Merge "Add post-install verification for BBOTAs"
* commit '2e30a5e853a584b11db65c0703aff93c7f7870f8':
  Add post-install verification for BBOTAs
2015-06-02 18:28:30 +00:00
Tao Bao
68658c0f4f Add post-install verification for BBOTAs
Similar to the assertations in file-based OTA, we perform verification
for block-based OTAs (BBOTAs) after updating a partition, for both of
the incremental and full OTAs. It increases the update time (~20s on
Nexus 6), but will capture unnoticed errors right away.

Bug: 21500869
Change-Id: I89ac8fe623b855721b7affd07cf9426a23433ab0
2015-06-01 15:00:30 -07:00
Brian Carlstrom
663127d0ca Use zipalign -p to page align .so files
Bug: 21400810
Change-Id: Ie3adf26dd3a51acfdb0faa23dc8ca1b206fb3727
(cherry picked from commit 903186f938)
2015-05-26 15:16:36 -07:00
Brian Carlstrom
903186f938 Use zipalign -p to page align .so files
Bug: 21400810
Change-Id: Ie9a0ec0a55511383596016e830b474c76754277a
2015-05-22 15:51:19 -07:00
Tao Bao
58c1b96165 Fix the permission setting in common.ZipWriteStr()
When passing a ZipInfo instance to common.ZipWriteStr(), the
external_attr attribute should not be overwritten unless specified.
We didn't have the issue previously because we were calling
ZipFile.writestr() directly until [1] merged.

[1] commit 2ed665a033.

Bug: http://b/21309935
Change-Id: I8c0190362c60d7d78965ecfe5e484f8398ddc5f2
(cherry picked from commit 9773465409)
2015-05-20 13:29:03 -07:00
Tao Bao
9773465409 Fix the permission setting in common.ZipWriteStr()
When passing a ZipInfo instance to common.ZipWriteStr(), the
external_attr attribute should not be overwritten unless specified.
We didn't have the issue previously because we were calling
ZipFile.writestr() directly until [1] merged.

[1] commit 2ed665a033.

Bug: http://b/21309935
Change-Id: I374ccd40c174ff9259844f38bdbf187dfe82552d
2015-05-20 12:18:55 -07:00
Tao Bao
5ece99d64e Add support for clobbered blocks
In ext4 filesystems, some blocks might be changed even being mounted
R/O, such as the superblock (block 0). We need to exclude such blocks
from integrity verification. Plus such blocks should always be
written to the target by copying instead of patching.

Bug: http://b/20939131
Change-Id: I657025b7b1ad50d4365e7b18dc39308facfe864e
(cherry picked from commit ff7778166b)
2015-05-13 12:26:04 -07:00
Tao Bao
2f7ae925a3 Merge "Add support for clobbered blocks" 2015-05-13 19:03:08 +00:00
Tao Bao
ff7778166b Add support for clobbered blocks
In ext4 filesystems, some blocks might be changed even being mounted
R/O, such as the superblock (block 0). We need to exclude such blocks
from integrity verification. Plus such blocks should always be
written to the target by copying instead of patching.

Bug: http://b/20939131
Change-Id: I991169ec307dfb231b2fe8908a0668595ecb2060
2015-05-13 11:19:39 -07:00
Baligh Uddin
852a5b531c Add bootsigner path as an option
Change-Id: I3d804b7937aafea8274b06edab097a6dca8f04cd
(cherry picked from commit e204868f1f)
2015-05-13 10:07:47 -07:00
Tao Bao
f3282b4a7f Wrap zipfile.write(), writestr() and close()
In order to work around the zip 2GiB limit, we need to wrap the related
functions in zipfile. Calls to those functions should always be replaced
with calls to the wrappers instead.

Bug: 18015246
Change-Id: I499574cee51ec4804bc10cbefe0b17940afed918
(cherry picked from commit 2ed665a033)
2015-05-08 15:53:27 -07:00
Tao Bao
2ed665a033 Wrap zipfile.write(), writestr() and close()
In order to work around the zip 2GiB limit, we need to wrap the related
functions in zipfile. Calls to those functions should always be replaced
with calls to the wrappers instead.

Bug: 18015246
Change-Id: Ice494371ca6654e88ded2ae0eb680f51082effcb
2015-05-08 13:51:12 -07:00
Mohamad Ayyash
95e74c1424 common.py: Add support for squashfs
Change-Id: Ia40f8c6307d0213d43207aee91c4c8a5b5ad6f1e
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
2015-05-01 15:58:42 -07:00
Mohamad Ayyash
a990534e73 common.py: Add support for squashfs
Change-Id: Ia40f8c6307d0213d43207aee91c4c8a5b5ad6f1e
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
2015-05-01 15:39:43 -07:00
Sami Tolvanen
3edeb4e97b am 045d817c: am 497b74d5: am d21d1d27: am 00e1f003: Merge "Check partition hash before resorting to block_image_verify"
* commit '045d817cce8cb1feb0186b537306cabf1a5069cd':
  Check partition hash before resorting to block_image_verify
2015-04-25 10:01:53 +00:00
Sami Tolvanen
e09d096ed6 Check partition hash before resorting to block_image_verify
It's not necessary to call block_image_verify for the most common
case where we attempt an update for the first time and the target
partition has expected contents. It is sufficient to confirm that
the target partition is intact.

Computing a hash is much faster than simulating the update, which
means this change should make the update speed for v3 much closer
to v2 for the common case. If the update was interrupted, this is
going to make resuming somewhat slower, of course. Hopefully this
should be rather rare.

Bug: 20309033
Change-Id: I04792f3681bf2cd5d9a4e1c41eb883c7f26c6f58
2015-04-24 10:56:59 +00:00
Sami Tolvanen
8b3f08bc7b Separate boot and recovery image signing from dm-verity
Allow dm-verity to be enabled without boot and recovery images being
signed. This makes it possible to enable only dm-verity to detect
corruption without confusing bootloaders that do not understand signed
images.

Bug: 19985143
Change-Id: Ie52c6ff595faa7a5c1f1bc1b37f6899c4d0c7001
2015-04-08 12:30:16 +01:00
Tao Bao
521a8dbd18 am 93d46584: am ae26f5b0: am 53602955: Merge "Add support to sign bootable images with vboot_signer"
* commit '93d46584170a9aae1728cdb9010eef41e25b4d4a':
  Add support to sign bootable images with vboot_signer
2015-04-01 17:33:36 +00:00
Tao Bao
d95e9fd267 Add support to sign bootable images with vboot_signer
Add vboot properties to the dictionary file, which will be packed into
the target_files zip. Add support in packaging and OTA scripts to
sign the generated bootable images (boot.img and recovery.img) when
vboot is enabled.

Change-Id: I08758ced03d173219415bca762bbdb66c464a9f5
(cherry picked from commit 5d5a3bd9e8d8b14b71d1b2105417a2958d13d3d2)
2015-04-01 09:23:08 -07:00
Dan Albert
3d4466f3d6 am 146366bf: am b6339d74: am f1a8c8c5: Merge "Fix up a few callers of GetTypeAndDevice."
* commit '146366bfb28e6f7c7b785188325fab40c4db000a':
  Fix up a few callers of GetTypeAndDevice.
2015-03-28 02:38:22 +00:00
Dan Albert
ebb19aa01a Fix up a few callers of GetTypeAndDevice.
Change-Id: I8f2d8d28b60715f917e9aceb8f851ad652034aa7
2015-03-27 19:11:53 -07:00
Dan Albert
cd9ecc0258 resolved conflicts for merge of eecf00db to master
Change-Id: I7f268122c10152aff8ef59622edbba88db427fca
2015-03-27 16:37:23 -07:00
Baligh Uddin
6c0618976c Merge "Add bootsigner path as an option" 2015-03-26 23:03:13 +00: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
Dan Albert
8e0178d41b Allow system images larger than 2GiB.
Python 2.7's zipfile implementation wrongly thinks that zip64 is
required for files larger than 2GiB. We can work around this by
adjusting their limit. Note that `zipfile.writestr()` will not work
for strings larger than 2GiB. The Python interpreter sometimes rejects
strings that large (though it isn't clear to me exactly what
circumstances cause this). `zipfile.write()` must be used directly to
work around this.

This mess can be avoided if we port to python3.

The bug (b/19364241) in original commit has been fixed.

Bug: 18015246
Bug: 19364241
Bug: 19839468

(cherry picked from commit cd082d4bfe)

Change-Id: I7b5cc310e0a9ba894533b53cb998afd5ce96d8c6
2015-03-19 13:59:01 -07:00
Tao Bao
dd2a5892e5 Restrict the verification in block-based incremental OTAs
BlockImageDiff has three versions. Only the incremental OTAs generated
with the latest version (3) can be re-applied to the system that's
already on the target build. Otherwise, operations like move will make
unconditional changes and damage the system. During the verification
phase, abort the OTA update if BlockImageDiff is less than 3 and it
doesn't match the checksum of the source build.

Change-Id: Ic630346eab2a993a84d0aeaacd7167ef62cc24f6
(cherry picked from commit daebaa6ed3)
2015-03-13 17:57:15 -07:00
Michael Runge
910b005f18 Do not use block_verify on target-files where feature is missing.
This will only be used when the block file format is at least
version 3.  For V1/V2 (L, L MR1) block versions, fall back to
the old range_sha1 check.

Bug: 19357591
Change-Id: I7cb178b70d48ec3c98cdb88ed1c94cf7797a01d0
(cherry picked from commit cad78c12fb)
2015-03-13 11:36:14 -07:00
Sami Tolvanen
dd67a295cc Change transfer list format to include block hashes
Add source and target block hashes as parameters to transfer list
commands that copy or patch data to a partition. This allows the
updater to verify the status of each command in the transfer list
and makes resuming block based OTAs possible. Due to the changes,
update the transfer list version to 3.

Needs matching changes from
  I1e752464134aeb2d396946348e6041acabe13942

Bug: 18262110
Change-Id: Ia5c56379f570047f10f0aa7373a1025439495c98
(cherry picked from commit cac671a9d1)
2015-03-11 17:22:06 +00:00
Justin Harrison
2de68bbbf4 Revert "Allow system images larger than 2GiB."
This reverts commit cd082d4bfe.

Change-Id: Ie63e1ba70d907d2849164871bc7ec71c245f7af9
2015-02-13 18:47:51 +00:00
Baligh Uddin
e204868f1f Add bootsigner path as an option
Change-Id: I71e8cb96b7a33cc02897fc24f6f3f61c7608bfe3
2015-02-11 15:43:02 +00:00
Dan Albert
39a68ab310 am f8f91c94: am 3907eaf8: am cd082d4b: Allow system images larger than 2GiB.
* commit 'f8f91c94706a953f91bf75e919b4302db6a9a99f':
  Allow system images larger than 2GiB.
2015-02-09 04:14:08 +00:00
Dan Albert
cd082d4bfe Allow system images larger than 2GiB.
Python 2.7's zipfile implementation wrongly thinks that zip64 is
required for files larger than 2GiB. We can work around this by
adjusting their limit. Note that `zipfile.writestr()` will not work
for strings larger than 2GiB. The Python interpreter sometimes rejects
strings that large (though it isn't clear to me exactly what
circumstances cause this). `zipfile.write()` must be used directly to
work around this.

This mess can be avoided if we port to python3.

Bug: 18015246
Change-Id: I8a476d99c5efdef6ea408373b706e9fbd3a798be
2015-02-06 13:24:06 -08:00
Sami Tolvanen
cac671a9d1 Change transfer list format to include block hashes
Add source and target block hashes as parameters to transfer list
commands that copy or patch data to a partition. This allows the
updater to verify the status of each command in the transfer list
and makes resuming block based OTAs possible. Due to the changes,
update the transfer list version to 3.

Needs matching changes from
  I1e752464134aeb2d396946348e6041acabe13942

Bug: 18262110
Change-Id: Ia5c56379f570047f10f0aa7373a1025439495c98
2015-01-30 11:34:27 +00:00
Jesse Zhao
75bcea0267 verify system and vendor image together before patching.
Change-Id: Ia43657ed6cd8860b0edb78cc2dd6388c761e1f8b
Bug: 17919909
2015-01-07 21:44:09 +00:00
Sami Tolvanen
8d212ea873 DO NOT MERGE: Change verity key formats
Change boot, recovery, and verity metadata signing keys to use the
same PKCS8 / X.509 PEM format as the other signing keys, and update
build scripts to use correct arguments for the updated signing
tools.

Bug: 15984840
Bug: 18120110
Change-Id: I23ed5a004ecdad6cf7696487935ad5031eb8adf8
(cherry picked from commit 72d90eb189)
2014-11-13 23:23:31 +00:00
Doug Zongker
623381880a generate version 2 blockimgdiff files
Generate version 2 of the block_image_update transfer list format.
This improves patch size by a different strategy for dealing with
out-of-order transfers.  If transfer A must be done before transfer B
due to B overwriting A's source but we want to do B before A, we
resolve the conflict by:

  - before B is executed, we save ("stash") the overlapping region (ie
    the blocks B will overwrite that A wants to read)

  - when A is executed, it will read those parts of source data from
    the stash rather than from the image.

This reverses the ordering constraint; with these additions now B
*must* go before A.  The implementation of the stash is left up to the
code that executes the transfer list to apply the patch; it could hold
stashed data in RAM or on a scratch disk such as /cache, if available.

The code retains the ability to build a version 1 block image patch;
it's needed for processing older target-files.

Change-Id: Ia9aa0bd45d5dc3ef7c5835e483b1b2ead10135fe
2014-09-25 16:39:14 -07:00
Doug Zongker
b34fcce08c explicitly check the superblock for differences
When generating incrementals for the system and vendor partitions,
check the first block (which contains the superblock) of the partition
to see if it's what we expect.  If this check fails, give an explicit
log message about the partition having been remounted R/W (the most
likely explanation) and the need to flash to get OTAs working again.

Bug: 17393999
Change-Id: Ifd2132b428dbc4907527291712690204a3664ac0
2014-09-11 09:38:01 -07:00
Doug Zongker
8544877399 select default search_path by platform
Bug: 17443175
Change-Id: I2b8b0a3b56e667b749ac167a6d09dc973ecf8419
2014-09-09 15:11:13 -07:00
Baligh Uddin
bdc2e3186f Add java_args as a valid option
Bug: 17393134
Change-Id: If2749d03b5d409a08d415a829dd21f986cac1789
2014-09-06 00:37:54 +00:00
Baligh Uddin
339ee4968a Add jvm args option. I rather not hardcode some large value just for Volantis. This can easily be passed in from sign-build.sh and should be a no-op for any other tools
Bug: 17393134
Change-Id: Ic2325d7c1e1e7292c9339e169efbed526f82263c
2014-09-05 18:29:47 +00:00
Doug Zongker
ab7ca1d286 refactor BlockDifference into common
Move BlockDifference into common and make its script generation code
more complete, so that it can be use by releasetools.py to do diffs on
baseband images.

Bug: 16984795
Change-Id: Iba9afc1c7755458ce47468b5170672612b2cb4b3
2014-08-26 13:12:11 -07:00
Doug Zongker
4d0bfb4f40 remove unused xdelta3/xz utilities
This was part of the original block-based OTA mechanism.

Bug: 16987495
Change-Id: I5bd6599829ee6084a8da1f0b14af87aabf07c130
2014-08-26 13:11:56 -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
6f1d031b39 take bootable images from target_files if present
Now that we're building and saving images in the target_files at build
time, we should use those images instead of rebuilding them.

Bug: 17201052
Change-Id: I459e650f66f1e0bdf01ad54df9e34f36bf2ee899
2014-08-22 10:25:57 -07:00
Geremy Condra
95ebe7a09b Use the specified verity key to sign boot and recovery OTA images.
This ensures that when the verity key is rotated to a release key
both the boot and recovery images will be correctly signed. It does
mean that they will both be signed with the same key for now, but
as that doesn't change the threat model separating them is just a
distant nice-to-have.

Bug: 15725238
Change-Id: I5b75e4346fe0655065643ab553431690cc1a8cb0
2014-08-20 20:17:01 +00:00
Benoit Fradin
a45a8682fa BuildBootImage: Add secondstage image support [DO NOT MERGE]
The AOSP bootimage format allows the use of a second stage image
however the BuildBootableImage function does not allows the "second"
optional argument. This patch adds the support of this argument.

Bug: 17035158

Change-Id: I8ed9d9e56449945c2d42fc908269921c394f68c0
Signed-off-by: Benoit Fradin <benoit.fradin@intel.com>
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Patrick Tjin <pattjin@google.com>
2014-08-14 11:24:54 -07:00
Doug Zongker
f83400896d add 5 minute timeout on binary patch construction
When making bsdiff/imgdiff patches, give up after 5 minutes.  (On
certain large files it can take hours to build a patch, if it ever
even completes.)

Change-Id: I123c06f8194f85f6f4e640f7eb31c7746f76ba4d
2014-08-05 10:39:37 -07:00
Ying Wang
a961a09e59 Fix error: 'NoneType' object is not iterable
Change-Id: I5a54edbed0e5e5481a570b93c07d50f6ca3e18e0
2014-07-29 11:42:37 -07:00
Daniel Rosenberg
f4eabc3961 Added support for building verified vendor partition
Change-Id: I762724800ccab3a365e6d2efdf86cd9c394818eb
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-07-14 22:55:22 +00:00
JP Abgrall
5bfed5a320 core+tools: support specifying F2FS as the fstype for userdata
- Support TARGET_USERIMAGES_USE_F2FS.
- Support BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE.
- Support "userdata_fs_type" in the prop dict.
- Update build_image to recognize f2fs and call the correct command.

Change-Id: If31cc8bd235f93a4c7814fab36e6e2d13d3037ad
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 13:32:14 -07:00