aboutsummaryrefslogtreecommitdiffstats
path: root/applypatch
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2012-10-19 12:24:26 -0700
committerDoug Zongker <dougz@android.com>2012-10-19 12:24:26 -0700
commitbf80f49edcec6b22ad7b1219e6ed6eda1e930c8c (patch)
tree1f47c641d762aeac482cae331b04f9d4391720fa /applypatch
parenta0d9ddb8f2922088b08219326afeaf532b3af5ac (diff)
downloadbootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.zip
bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.gz
bootable_recovery-bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c.tar.bz2
reduce some recovery logging
Make minzip log only a count of files when extracting, not individual filenames. Make patching only chatter about free space if there's not enough and compact the other messages. Only the last 8k of the recovery log gets uploaded; this makes it more likely that we will get all of it. Change-Id: I529cb4947fe2185df82b9da5fae450a7480dcecd
Diffstat (limited to 'applypatch')
-rw-r--r--applypatch/applypatch.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c
index 7b8a010..69f8633 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) {