Commit graph

240 commits

Author SHA1 Message Date
Tao Bao
63d786cf22 updater: Remove some obsoleted functions for file-based OTA.
This CL removes the updater support for delete(), symlink(), rename(),
set_metadata() and set_metadata_recursive(). Such functions have been
removed from the generation script in commit
f388104eaacd05cfa075d6478369e1d0df5ddbf3 (platform/build).

Note: This CL also removes delete_recursive() which seems to have never
been supported in generation script.

Bug: 35853185
Test: recovery_component_test passes.
Change-Id: I51e1ec946fa73761118fa1eaa082423df6d588e9
2017-03-13 10:02:08 -07:00
Sen Jiang
f9962dbfe2 Merge "Use bspatch from external/bsdiff." 2017-02-16 21:14:10 +00:00
Tao Bao
3da880156b Replace _exit(-1) with _exit(EXIT_FAILURE).
-1 is not a valid exit status.

Also replace a few exit(1) with exit(EXIT_FAILURE).

Test: mmma bootable/recovery
Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
2017-02-03 14:11:11 -08:00
Sen Jiang
25c56979dd Use bspatch from external/bsdiff.
Now ApplyBSDiffPatch() will stream the output to sink as we go instead
of sinking everything at the end.

Test: recovery_host_test
Bug: 26982501

Change-Id: I05b6ed40d45e4b1b19ae72784cf705b731b976e3
2017-02-02 14:41:05 -08:00
Alex Deymo
56ff8061b1 Merge "Remove '_static' suffix from libext2* references." 2017-01-25 23:48:43 +00:00
Alex Deymo
7c5dbd6751 Remove '_static' suffix from libext2* references.
Bug: 34220783
Test: make checkbuild
Change-Id: Iceea20e440a4bb6a3b254486a65a86401a2241ef
2017-01-23 15:18:29 -08:00
Tao Bao
f013642477 Print with newline for ui_print.
Currently the ui_print command between the recovery and updater doesn't
append newline. Updater has to send an extra "ui_print" command without
any argument to get the line break. This looks unnecessary. And not all
the callers (including the ones in bootable/recovery) are following this
protocol when sending the ui_print command.

This CL simplifies the protocol to always print with a newline for
ui_print command. When updating from an old recovery with the new
updater, all the ui_print'd strings would appear in one line as a side
effect. But a) it would only affect the text-mode UI, which won't be
shown to users; b) log files won't be affected.

Bug: 32305035
Test: Apply an update with the new updater on top of an old and new
      recovery image respectively.
Change-Id: I305a0ffc6f180daf60919cf99d24d1495d68749b
2017-01-21 20:43:45 -08:00
Alex Deymo
8031c2d2bb Merge changes from topic 'host_suffix_cleanup'
* changes:
  Remove "_static" suffix from libsparse
  Remove "_static" suffix from libext4_utils.
2017-01-12 21:23:10 +00:00
Alex Deymo
67f3aa8804 Remove "_static" suffix from libsparse
Bug: 34220783

Change-Id: I358f931f0b29f5bd526e1475180e477e2e90b936
2017-01-11 14:38:30 -08:00
Alex Deymo
31653660ad Remove "_static" suffix from libext4_utils.
Bug: 34220783
Change-Id: I34ccc3b11da0d1b48805967ad75b9ddade569930
2017-01-11 14:02:13 -08:00
Tianjie Xu
4728242070 Do not inject I/O fault on a retry
We could inject I/O faults during an OTA update for test purpose. But we
should skip the injection if the update is an retry. Otherwise the
update test will simply keeps failing.

Bug: 34159970
Test: Apply the same package on angler and the update succeeds on the 2nd try.
Change-Id: Id274e5475e3bc8d25d50a8cf61a77d2e32c569d6
2017-01-09 14:51:15 -08:00
Tao Bao
91f74c82cd Merge "updater: Clean up CreateStash()." 2017-01-05 21:14:43 +00:00
Tao Bao
c844c06faf updater: Refactor parse_range().
Returning the parsed RangeSet directly (as opposed to using some pointer
parameter) to make the code cleaner.

Test: Apply an incremental with the new updater.
Change-Id: I8c99e701f189eb6a3eacc0d647e5a3a85fbeb3eb
2017-01-03 17:51:30 -08:00
Tao Bao
5141221211 updater: Clean up CreateStash().
Change the stash size computation from int to size_t.

Test: Apply an incremental BBOTA with the new updater.
Change-Id: Ib45b71b826fec6aa0ffafc67c17735825634eae0
2016-12-28 16:22:16 -08:00
Tao Bao
0d3f84f237 updater: Update the header name for bootloader.h.
We should include "bootloader_message/bootloader_message.h" now.

Test: m updater
Change-Id: I65b22a8a0bcc5976ff1ba827bd30b46ee9d59c53
2016-12-28 15:09:20 -08:00
Tao Bao
5354f60f2b updater: Fix the operator order.
Shift operator ("<<") has a higher precedence level than ternary
operator ("?").

Test: BBOTA update log says "performing update" as opposed to
      "performing 0".

Change-Id: I0cf60cbfc11415e94f1f9f6effe75f14d13a1874
2016-12-14 11:34:49 -08:00
Tao Bao
039f2da3e4 updater: Switch to libbase logging.
Test: Build an updater into a package and apply it on device.
Change-Id: I289b5768e9b1e44ef78e0479c64dbaa36fb1a685
2016-11-30 23:44:41 -08:00
Tao Bao
358c2ec1dc Remove ota_close(int) and ota_fclose(FILE*).
We should always use unique_fd or unique_file to hold the FD or FILE*
pointer when opening via ota_(f)open functions.

This CL avoids accidentally closing raw FDs or FILE* pointers that are
managed by unique_fd/unique_file.

Test: recovery_component_test passes.
Change-Id: If58eb8b5c5da507563f85efd5d56276472a1c957
2016-11-28 12:09:39 -08:00
Tao Bao
bedf5fc11c updater: Refactor set_stage() and get_stage() functions.
Add read_bootloader_message_from() and write_bootloader_message_to() to
allow specifying the BCB device (/misc).

Also add testcases for set_stage() and get_stage().

Test: recovery_component_test passes.
Test: Build a recovery image and apply a two-step OTA package.
Change-Id: If5ab06a1aaaea168d2a9e5dd63c07c0a3190e4ae
2016-11-18 12:04:48 -08:00
Tao Bao
1036d36542 updater: Add testcase for package_extract_dir().
Test: recovery_component_test passes.
Change-Id: I3af4707bc42c7331ca961be8b967a53de82ea25b
2016-11-17 23:02:13 -08:00
Tao Bao
d0f3088aa9 updater: Add "write_value()" function.
write_value(value, filename) writes 'value' to 'filename'. It can be
used to tune device settings when applying an OTA package. For example,
write_value("960000", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq").

Bug: 32463933
Test: recovery_component_test passes.
Test: Apply an OTA package that contains a call to write_value(), and
      check the result.

Change-Id: Ib009ecb8a45a94353f10c59e2383fe1f49796e35
2016-11-16 15:51:53 -08:00
Tao Bao
ef0eb3b01b updater: Fix the wrong return value for package_extract_file().
'bool success = ExtractEntryToFile()' gives opposite result. Fix the
issue and add testcases.

Change the one-argument version of package_extract_file() to explicitly
abort for non-existent zip entry. Note that this is NOT changing the
behavior. Prior to this CL, it aborts from Evaluate() function, by
giving a general cause code. Now it returns kPackageExtractFileFailure.

BUg: 32903624
Test: recovery_component_test works.

Change-Id: I7a273e9c0d9aaaf8c472b2c778f7b8d90362c24f
2016-11-15 13:17:52 -08:00
Tao Bao
8992902aab updater: Add more testcase for symlink().
Clean up SymlinkFn() a bit. Also clean up the temp files created when
running the tests; otherwise non-empty TemporaryDir won't be removed.

Test: recovery_component_test passes.
Change-Id: Id3844abebd168c40125c4dcec54e6ef680a83c3a
2016-11-08 21:29:16 -08:00
Tianjie Xu
d75003d24c Make make_parent() to take const argument
Switch to use const std::string; and add corresponding tests.

Bug: 32649858
Test: Component tests pass
Change-Id: I640f3ec81f1481fa91aa310f8d4d96dac9649cb9
2016-11-08 10:11:03 -08:00
Tao Bao
a659d79b92 updater: Add a testcase for RenameFn().
Test: recovery_component_test passes.

Change-Id: Iba5a0fdf6c79e2bed6b30b8fc19a306c1ab29d8a
2016-11-03 23:35:42 -07:00
Tao Bao
0831d0b592 updater: Fix a bug in DeleteFn().
Also add a testcase for delete() function.

Test: recovery_component_test passes.
Change-Id: I064d1ad4693c3ed339d0a69eabadd08a61a2ea86
2016-11-03 23:28:36 -07:00
Tao Bao
51d516e913 updater: Fix an off-by-1 bug in file_getprop().
Also add a testcase for file_getprop().

Test: recovery_component_test passes.

Change-Id: I8eb2f9a5702b43997ac9f4b29665eea087b1c146
2016-11-03 14:58:54 -07:00
Tianjie Xu
5fe280ac96 Cleanup ReadArgs & ReadValueArgs usage
ReadArgs will switch to using std::string and std::unique_ptr. Also
cleanup the callers.

Test: mma & component test passed.
Change-Id: I4724406ae6c0c134a27bbd1cdd24ad5d343b2a3b
2016-11-01 15:03:06 -07:00
Tao Bao
fada91ccf2 applypatch: Switch the parameter of Value** to std::vector.
Test: Unit tests and install-recovery.sh pass on angler and dragon.

Change-Id: I328e6554edca667cf850f5584ebf1ac211e3d4d1
2016-10-28 16:46:12 -07:00
Tianjie Xu
8cf5c8f60f Replace minzip with libziparchive
Clean up the duplicated codes that handle the zip files in
bootable/recovery; and rename the library of the remaining
utility functions to libotautil.

Test: Update package installed successfully on angler.
Bug: 19472796

Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
2016-10-17 17:41:51 -07:00
Tianjie Xu
aced5d9e4e Change StringValue to use std::string
Changing the field of 'Value' in edify to std::string from char*.
Meanwhile cleaning up the users of 'Value' and switching them to
cpp style.

Test: compontent tests passed.
Bug: 31713288

Change-Id: Iec5a7d601b1e4ca40935bf1c70d325dafecec235
2016-10-15 01:18:23 +00:00
Tao Bao
39119ad8ec edify: Some clean-ups to libedify.
- Remove dead declarations in expr.h: SetError(), GetError(),
  ClearError().
- Remove the declaration of Build() out of expr.h.
- Use std::unordered_map to implement RegisterFunction() and
  FindFunction(); kill FinishRegistration().
- Add a testcase for calling unknown functions.

Test: mmma bootable/recovery; recovery_component_test passes.
Change-Id: I9af6825ae677f92b22d716a4a5682f58522af03b
2016-10-12 23:29:59 -07:00
Tao Bao
361342cbd2 updater: Kill the duplicate PrintSha1() in install.cpp.
Also add a testcase for sha1_check().

Test: mmma bootable/recovery; recovery_component_test passes.

Change-Id: I4d06d551a771aec84e460148544f68b247a7e721
2016-10-10 20:36:17 -07:00
Tao Bao
0c7839ac14 Refactor libupdater into a seperate module.
So that we can write native tests for updater functions. This CL adds a
testcase for getprop() function.

Test: mmma bootable/recovery; Run recovery_component_test on device.

Change-Id: Iff4c1ff63c5c71aded2f9686fed6b71cc298c228
2016-10-10 16:49:50 -07:00
Tao Bao
de40ba59c8 Update the header path for ext4_utils.
Test: `mmma bootable/recovery`
Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e
2016-10-09 14:02:10 -07:00
Tao Bao
59dcb9cbea edify: Move State.script and State.errmsg to std::string.
This way we kill a few strdup() and free() calls.

Test: 1. recovery_component_test still passes;
2. Applying an update with the new updater works;
3. The error code in a script with abort("E310: xyz") is recorded into
last_install correctly.

Change-Id: Ibda4da5937346e058a0d7cc81764d6f02920010a
2016-10-04 14:24:32 -07:00
Tianjie Xu
7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Elliott Hughes
cb22040c63 Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-26 09:51:37 -07:00
Tianjie Xu
61590bbf0d Merge "Switch recovery to libbase logging" 2016-09-01 23:04:37 +00:00
Tianjie Xu
7b0ad9c638 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 18:33:25 +00:00
Tianjie Xu
71e182bc38 Check an edge case when read(2) returns 0
We might end up in an infinite loop if read(2) reached EOF unexpectedly.
The problematic code in uncrypt mentioned in the bug has been fixed
by switching to libbase ReadFully(). So I grepped through the recovery
code and fixed some other occurences of the issue.

Bug: 31073201
Change-Id: Ib867029158ba23363b8f85d61c25058a635c5a6b
2016-08-31 19:11:41 -07:00
Josh Gao
dc97404346 Merge "Fix references to libcrypto_utils_static."
am: b97da5e0f0

Change-Id: Ia935df84e5ea36dfc6605b41872c36db69a114a0
2016-08-08 18:33:51 +00:00
Josh Gao
073164f24b Fix references to libcrypto_utils_static.
Bug: http://b/30708454
Change-Id: I7a5048beff1d8b783a9683dcb4a79606a77f20ee
2016-08-05 18:08:03 -07:00
Elliott Hughes
691db7ba77 Merge \"Fix install.h\'s use of attribute printf.\"
am: a82ee456bb

Change-Id: Ibcfabbb0e044d503f889f1afea271cf73ad93f45
2016-06-30 18:18:40 +00:00
Elliott Hughes
83ce755518 Fix install.h's use of attribute printf.
And move off the bionic __nonnull macro, which I'm removing.

Change-Id: I40b4424f4fd7bd8076e0eee3ec35de36c3ded8de
2016-06-30 09:28:42 -07:00
Tianjie Xu
93110c767f Check the results from applypatch
am: 31f8cc84cf

Change-Id: I2ea241fb3e688f5f8b0558d638dd3ed502223f97
2016-06-16 18:08:59 +00:00
Tianjie Xu
31f8cc84cf Check the results from applypatch
Check the results from applypatch in PerformCommandDiff; and abort the
update on failure.

Bug:29339536
Change-Id: I5087d79ba532b54250f4c17560524255c8a4fabc
2016-06-15 23:26:59 +00:00
Elliott Hughes
274d17dc0f resolve merge conflicts of 179c0d8 to stage-aosp-master
Change-Id: Iba5aec266444cabf83f600f2bdb45a3c027e5995
2016-06-15 15:22:17 -07:00
Elliott Hughes
179c0d80bc Merge "Remove obsolete MTD support." 2016-06-15 21:55:15 +00:00
Tao Bao
1e67422f37 Merge \\"updater: Fix the broken ReadFileFn.\\" am: 4ddd5edf31
am: 89dfe730d4

Change-Id: Ia465c92d341da4681d3490151a20e1e117271e52
2016-06-11 18:53:14 +00:00