diff options
author | Doug Zongker <dougz@android.com> | 2011-04-12 09:28:10 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2011-04-12 09:28:10 -0700 |
commit | 469243e53689b6f312d20813444dc00d83528758 (patch) | |
tree | e59d3978874c4637efdd7fb86201b1c360f4e56d /install.c | |
parent | 3ed8e187212b06767e0ca5860cdbd79c11c9390e (diff) | |
download | bootable_recovery-469243e53689b6f312d20813444dc00d83528758.zip bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.gz bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.bz2 |
save a last_install file with the result of the last package install attempt
When installing a package, create /cache/recovery/last_install, which
contains the filename of the package and a 1 or 0 for success or
failure.
Also, don't mount ext4 and vfat filesystems as read-only (on devices
where /cache is ext4, we need it to be read-write).
Change-Id: I0cf2a1921bbd65e06343aa74e2006577fac77c2c
Diffstat (limited to 'install.c')
-rw-r--r-- | install.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -36,6 +36,8 @@ #define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary" #define PUBLIC_KEYS_FILE "/res/keys" +static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install"; + // If the package contains an update binary, extract it and run it. static int try_update_binary(const char *path, ZipArchive *zip) { @@ -233,8 +235,8 @@ exit: return NULL; } -int -install_package(const char *path) +static int +really_install_package(const char *path) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("Finding update package...\n"); @@ -285,3 +287,23 @@ install_package(const char *path) ui_print("Installing update...\n"); return try_update_binary(path, &zip); } + +int +install_package(const char* path) +{ + FILE* install_log = fopen_path(LAST_INSTALL_FILE, "w"); + if (install_log) { + fputs(path, install_log); + fputc('\n', install_log); + } else { + LOGE("failed to open last_install: %s\n", strerror(errno)); + } + int result = really_install_package(path); + if (install_log) { + fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); + fputc('\n', install_log); + fclose(install_log); + chmod(LAST_INSTALL_FILE, 0644); + } + return result; +} |