summaryrefslogtreecommitdiffstats
path: root/applypatch/main.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-07-24 23:10:46 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-24 23:10:46 +0200
commit6a06034d031464b220bc78bda2654f80d6ef1ad1 (patch)
tree9afd779a06fddad908541f1ee53c727c800c4b5a /applypatch/main.cpp
parentam c69095d8: am afb8f320: Merge "uncrypt: Support file level encryption." (diff)
parentam dd738c11: Merge "applypatch: Support flash mode." (diff)
downloadandroid_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar.gz
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar.bz2
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar.lz
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar.xz
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.tar.zst
android_bootable_recovery-6a06034d031464b220bc78bda2654f80d6ef1ad1.zip
Diffstat (limited to 'applypatch/main.cpp')
-rw-r--r--applypatch/main.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/applypatch/main.cpp b/applypatch/main.cpp
index 63ff5c2c0..966d8b91f 100644
--- a/applypatch/main.cpp
+++ b/applypatch/main.cpp
@@ -47,8 +47,8 @@ static int SpaceMode(int argc, char** argv) {
// "<sha1>:<filename>" into the new parallel arrays *sha1s and
// *patches (loading file contents into the patches). Returns true on
// success.
-static bool ParsePatchArgs(int argc, char** argv,
- char*** sha1s, Value*** patches, int* num_patches) {
+static bool ParsePatchArgs(int argc, char** argv, char*** sha1s,
+ Value*** patches, int* num_patches) {
*num_patches = argc;
*sha1s = reinterpret_cast<char**>(malloc(*num_patches * sizeof(char*)));
*patches = reinterpret_cast<Value**>(malloc(*num_patches * sizeof(Value*)));
@@ -98,7 +98,12 @@ static bool ParsePatchArgs(int argc, char** argv,
return false;
}
-int PatchMode(int argc, char** argv) {
+static int FlashMode(const char* src_filename, const char* tgt_filename,
+ const char* tgt_sha1, size_t tgt_size) {
+ return applypatch_flash(src_filename, tgt_filename, tgt_sha1, tgt_size);
+}
+
+static int PatchMode(int argc, char** argv) {
Value* bonus = NULL;
if (argc >= 3 && strcmp(argv[1], "-b") == 0) {
FileContents fc;
@@ -114,7 +119,7 @@ int PatchMode(int argc, char** argv) {
argv += 2;
}
- if (argc < 6) {
+ if (argc < 4) {
return 2;
}
@@ -125,6 +130,16 @@ int PatchMode(int argc, char** argv) {
return 1;
}
+ // If no <src-sha1>:<patch> is provided, it is in flash mode.
+ if (argc == 5) {
+ if (bonus != NULL) {
+ printf("bonus file not supported in flash mode\n");
+ return 1;
+ }
+ return FlashMode(argv[1], argv[2], argv[3], target_size);
+ }
+
+
char** sha1s;
Value** patches;
int num_patches;
@@ -162,6 +177,10 @@ int PatchMode(int argc, char** argv) {
// - if the sha1 hash of <tgt-file> is <tgt-sha1>, does nothing and exits
// successfully.
//
+// - otherwise, if no <src-sha1>:<patch> is provided, flashes <tgt-file> with
+// <src-file>. <tgt-file> must be a partition name, while <src-file> must
+// be a regular image file. <src-file> will not be deleted on success.
+//
// - otherwise, if the sha1 hash of <src-file> is <src-sha1>, applies the
// bsdiff <patch> to <src-file> to produce a new file (the type of patch
// is automatically detected from the file header). If that new