From 0c7839ac14a00f32d740c23ddf6df65f2757ece5 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 10 Oct 2016 15:48:37 -0700 Subject: 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 --- updater/install.cpp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'updater/install.cpp') diff --git a/updater/install.cpp b/updater/install.cpp index 24e35cfb8..86cdd5d32 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "updater/install.h" + #include #include #include @@ -40,24 +42,22 @@ #include #include #include +#include #include #include #include #include -#include "bootloader.h" #include "applypatch/applypatch.h" -#include "cutils/android_reboot.h" -#include "cutils/misc.h" +#include "bootloader.h" #include "edify/expr.h" #include "error_code.h" #include "minzip/DirUtil.h" #include "mounts.h" #include "openssl/sha.h" #include "ota_io.h" -#include "updater.h" -#include "install.h" #include "tune2fs.h" +#include "updater/updater.h" // Send over the buffer to recovery though the command pipe. static void uiPrint(State* state, const std::string& buffer) { @@ -90,6 +90,27 @@ void uiPrintf(State* _Nonnull state, const char* _Nonnull format, ...) { uiPrint(state, error_msg); } +// Create all parent directories of name, if necessary. +static int make_parents(char* name) { + char* p; + for (p = name + (strlen(name)-1); p > name; --p) { + if (*p != '/') continue; + *p = '\0'; + if (make_parents(name) < 0) return -1; + int result = mkdir(name, 0700); + if (result == 0) printf("created [%s]\n", name); + *p = '/'; + if (result == 0 || errno == EEXIST) { + // successfully created or already existed; we're done + return 0; + } else { + printf("failed to mkdir %s: %s\n", name, strerror(errno)); + return -1; + } + } + return 0; +} + // Take a sha-1 digest and return it as a newly-allocated hex string. char* PrintSha1(const uint8_t* digest) { char* buffer = reinterpret_cast(malloc(SHA_DIGEST_LENGTH*2 + 1)); @@ -569,27 +590,6 @@ Value* PackageExtractFileFn(const char* name, State* state, } } -// Create all parent directories of name, if necessary. -static int make_parents(char* name) { - char* p; - for (p = name + (strlen(name)-1); p > name; --p) { - if (*p != '/') continue; - *p = '\0'; - if (make_parents(name) < 0) return -1; - int result = mkdir(name, 0700); - if (result == 0) printf("created [%s]\n", name); - *p = '/'; - if (result == 0 || errno == EEXIST) { - // successfully created or already existed; we're done - return 0; - } else { - printf("failed to mkdir %s: %s\n", name, strerror(errno)); - return -1; - } - } - return 0; -} - // symlink target src1 src2 ... // unlinks any previously existing src1, src2, etc before creating symlinks. Value* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) { -- cgit v1.2.3