From a23075fb0e23978e5b8f3a7c92280ee1b2274e6d Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 6 Aug 2012 16:19:09 -0700 Subject: fix the symlink() command to create directories if needed Full OTAs currently fail if the build contains a directory containing only symlinks, because nothing creates that directory. Change the symlink() command to create any ancestor directories that don't exist. They're created as owner root perms 0700 because we assume that in practice subsequent set_perm_recursive() calls will fix up their ownership and permissions. Change-Id: I4681cbc85863d9778e36b924f0532b2b3ef14310 --- updater/install.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'updater') diff --git a/updater/install.c b/updater/install.c index f981017bf..ba27e9f33 100644 --- a/updater/install.c +++ b/updater/install.c @@ -456,6 +456,26 @@ 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) fprintf(stderr, "symlink(): created [%s]\n", name); + *p = '/'; + if (result == 0 || errno == EEXIST) { + // successfully created or already existed; we're done + return 0; + } else { + fprintf(stderr, "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. @@ -483,6 +503,11 @@ Value* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) { ++bad; } } + if (make_parents(srcs[i])) { + fprintf(stderr, "%s: failed to symlink %s to %s: making parents failed\n", + name, srcs[i], target); + ++bad; + } if (symlink(target, srcs[i]) < 0) { fprintf(stderr, "%s: failed to symlink %s to %s: %s\n", name, srcs[i], target, strerror(errno)); @@ -504,7 +529,8 @@ Value* SetPermFn(const char* name, State* state, int argc, Expr* argv[]) { int min_args = 4 + (recursive ? 1 : 0); if (argc < min_args) { - return ErrorAbort(state, "%s() expects %d+ args, got %d", name, argc); + return ErrorAbort(state, "%s() expects %d+ args, got %d", + name, min_args, argc); } char** args = ReadVarArgs(state, argc, argv); @@ -626,7 +652,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) { buffer = malloc(st.st_size+1); if (buffer == NULL) { - ErrorAbort(state, "%s: failed to alloc %d bytes", name, st.st_size+1); + ErrorAbort(state, "%s: failed to alloc %lld bytes", name, st.st_size+1); goto done; } @@ -638,7 +664,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) { } if (fread(buffer, 1, st.st_size, f) != st.st_size) { - ErrorAbort(state, "%s: failed to read %d bytes from %s", + ErrorAbort(state, "%s: failed to read %lld bytes from %s", name, st.st_size+1, filename); fclose(f); goto done; -- cgit v1.2.3 From a3ccba6d314cb29b02d1dbda9a71427b11da936d Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 20 Aug 2012 15:28:02 -0700 Subject: add bonus data feature to imgdiff/imgpatch/applypatch The bonus data option lets you give an additional blob of uncompressed data to be used when constructing a patch for chunk #1 of an image. The same blob must be available at patch time, and can be passed to the command-line applypatch tool (this feature is not accessible from edify scripts). This will be used to reduce the size of recovery-from-boot patches by storing parts of the recovery ramdisk (the UI images) on the system partition. Change-Id: Iac1959cdf7f5e4582f8d434e83456e483b64c02c --- updater/install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'updater') diff --git a/updater/install.c b/updater/install.c index ba27e9f33..41f053d01 100644 --- a/updater/install.c +++ b/updater/install.c @@ -901,7 +901,7 @@ Value* ApplyPatchFn(const char* name, State* state, int argc, Expr* argv[]) { int result = applypatch(source_filename, target_filename, target_sha1, target_size, - patchcount, patch_sha_str, patches); + patchcount, patch_sha_str, patches, NULL); for (i = 0; i < patchcount; ++i) { FreeValue(patches[i]); -- cgit v1.2.3 From 7eb7567aa3faebfb22bd052f3505d485ee23d585 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 16 Oct 2012 10:47:27 -0700 Subject: Remove HAVE_SELINUX guards Change-Id: Ia96201f20f7838d7d9e8926208977d3f8318ced4 --- updater/Android.mk | 7 +------ updater/install.c | 4 ---- updater/updater.c | 2 -- updater/updater.h | 4 ---- 4 files changed, 1 insertion(+), 16 deletions(-) (limited to 'updater') diff --git a/updater/Android.mk b/updater/Android.mk index 8876120b0..4271371e9 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -27,17 +27,12 @@ LOCAL_STATIC_LIBRARIES += \ libz endif -ifeq ($(HAVE_SELINUX), true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX -endif # HAVE_SELINUX - LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz LOCAL_STATIC_LIBRARIES += libminelf LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc +LOCAL_STATIC_LIBRARIES += libselinux LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. # Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function diff --git a/updater/install.c b/updater/install.c index f981017bf..9ace12541 100644 --- a/updater/install.c +++ b/updater/install.c @@ -78,23 +78,19 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { goto done; } -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehandle) { selabel_lookup(sehandle, &secontext, mount_point, 0755); setfscreatecon(secontext); } -#endif mkdir(mount_point, 0755); -#ifdef HAVE_SELINUX if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (strcmp(partition_type, "MTD") == 0) { mtd_scan_partitions(); diff --git a/updater/updater.c b/updater/updater.c index 5f1580870..58ac27f9e 100644 --- a/updater/updater.c +++ b/updater/updater.c @@ -105,7 +105,6 @@ int main(int argc, char** argv) { return 6; } -#ifdef HAVE_SELINUX struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; @@ -116,7 +115,6 @@ int main(int argc, char** argv) { fprintf(stderr, "Warning: No file_contexts\n"); fprintf(cmd_pipe, "ui_print Warning: No file_contexts\n"); } -#endif // Evaluate the parsed script. diff --git a/updater/updater.h b/updater/updater.h index a00872ca4..d2e901141 100644 --- a/updater/updater.h +++ b/updater/updater.h @@ -20,12 +20,8 @@ #include #include "minzip/Zip.h" -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif typedef struct { FILE* cmd_pipe; -- cgit v1.2.3 From 4e21482d979f6f81b34f92e664adf137555d4504 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 9 Apr 2013 21:41:29 -0700 Subject: Add liblog Bug: 8580410 Change-Id: Ie60dade81c06589cb0daee431611ded34adef8e6 --- updater/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'updater') diff --git a/updater/Android.mk b/updater/Android.mk index 4271371e9..67e98ecd4 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -31,7 +31,7 @@ LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDA LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz LOCAL_STATIC_LIBRARIES += libminelf -LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc +LOCAL_STATIC_LIBRARIES += libcutils liblog libstdc++ libc LOCAL_STATIC_LIBRARIES += libselinux LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. -- cgit v1.2.3