summaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2013-09-04 20:35:08 +0200
committerDees_Troy <dees_troy@teamw.in>2013-09-04 21:00:58 +0200
commit1669f89dd288e2ba226233a7fd62ea78ddb473c1 (patch)
treee6d72d724b31b6fa72e6d273a9c6c8661d5c9c2c /updater/install.c
parentInitialize TWPartition::User_Rm_Rf to false in constructor (diff)
parentMerge "Update libpng API usage" (diff)
downloadandroid_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar.gz
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar.bz2
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar.lz
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar.xz
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.tar.zst
android_bootable_recovery-1669f89dd288e2ba226233a7fd62ea78ddb473c1.zip
Diffstat (limited to 'updater/install.c')
-rw-r--r--updater/install.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/updater/install.c b/updater/install.c
index c5aa77c49..305703cd3 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();
@@ -456,6 +452,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 +499,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 +525,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 +648,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 +660,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;
@@ -823,7 +845,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]);