summaryrefslogtreecommitdiffstats
path: root/applypatch/applypatch.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2012-10-19 21:24:26 +0200
committerDoug Zongker <dougz@android.com>2012-10-19 21:24:26 +0200
commitbf80f49edcec6b22ad7b1219e6ed6eda1e930c8c (patch)
tree1f47c641d762aeac482cae331b04f9d4391720fa /applypatch/applypatch.c
parentam cd74108c: resolved conflicts for merge of 78afed1c to jb-mr1-dev-plus-aosp (diff)
downloadandroid_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.gz
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.bz2
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.lz
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.xz
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.zst
android_bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.zip
Diffstat (limited to 'applypatch/applypatch.c')
-rw-r--r--applypatch/applypatch.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c
index 7b8a010e3..69f8633ab 100644
--- a/applypatch/applypatch.c
+++ b/applypatch/applypatch.c
@@ -585,6 +585,14 @@ int CacheSizeCheck(size_t bytes) {
}
}
+static void print_short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) {
+ int i;
+ const char* hex = "0123456789abcdef";
+ for (i = 0; i < 4; ++i) {
+ putchar(hex[(sha1[i]>>4) & 0xf]);
+ putchar(hex[sha1[i] & 0xf]);
+ }
+}
// This function applies binary patches to files in a way that is safe
// (the original file is not touched until we have the desired
@@ -620,7 +628,7 @@ int applypatch(const char* source_filename,
char** const patch_sha1_str,
Value** patch_data,
Value* bonus_data) {
- printf("\napplying patch to %s\n", source_filename);
+ printf("patch %s: ", source_filename);
if (target_filename[0] == '-' &&
target_filename[1] == '\0') {
@@ -646,8 +654,9 @@ int applypatch(const char* source_filename,
if (memcmp(source_file.sha1, target_sha1, SHA_DIGEST_SIZE) == 0) {
// The early-exit case: the patch was already applied, this file
// has the desired hash, nothing for us to do.
- printf("\"%s\" is already target; no patch needed\n",
- target_filename);
+ printf("already ");
+ print_short_sha1(target_sha1);
+ putchar('\n');
free(source_file.data);
return 0;
}
@@ -769,8 +778,10 @@ static int GenerateTarget(FileContents* source_file,
enough_space =
(free_space > (256 << 10)) && // 256k (two-block) minimum
(free_space > (target_size * 3 / 2)); // 50% margin of error
- printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n",
- (long)target_size, (long)free_space, retry, enough_space);
+ if (!enough_space) {
+ printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n",
+ (long)target_size, (long)free_space, retry, enough_space);
+ }
}
if (!enough_space) {
@@ -805,7 +816,7 @@ static int GenerateTarget(FileContents* source_file,
unlink(source_filename);
size_t free_space = FreeSpaceForFile(target_fs);
- printf("(now %ld bytes free for target)\n", (long)free_space);
+ printf("(now %ld bytes free for target) ", (long)free_space);
}
}
@@ -901,6 +912,10 @@ static int GenerateTarget(FileContents* source_file,
if (memcmp(current_target_sha1, target_sha1, SHA_DIGEST_SIZE) != 0) {
printf("patch did not produce expected sha1\n");
return 1;
+ } else {
+ printf("now ");
+ print_short_sha1(target_sha1);
+ putchar('\n');
}
if (output < 0) {