summaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
Diffstat (limited to 'updater')
-rw-r--r--updater/Android.mk21
-rw-r--r--updater/install.cpp11
-rw-r--r--updater/updater.cpp36
3 files changed, 59 insertions, 9 deletions
diff --git a/updater/Android.mk b/updater/Android.mk
index d7aa613e9..45f1a47b2 100644
--- a/updater/Android.mk
+++ b/updater/Android.mk
@@ -33,22 +33,30 @@ LOCAL_CLANG := true
LOCAL_SRC_FILES := $(updater_src_files)
-LOCAL_STATIC_LIBRARIES += libfec libfec_rs libext4_utils_static libsquashfs_utils libcrypto_static
+LOCAL_STATIC_LIBRARIES += libfec libfec_rs libsquashfs_utils libcrypto_static
ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
LOCAL_CFLAGS += -DUSE_EXT4
LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_C_INCLUDES += system/extras/ext4_utils
-LOCAL_STATIC_LIBRARIES += \
- libsparse_static \
- libz
+LOCAL_STATIC_LIBRARIES += libext4_utils_static libsparse_static
+ifneq ($(wildcard external/lz4/Android.mk),)
+ LOCAL_STATIC_LIBRARIES += liblz4
+endif
+endif
+
+ifeq ($(WITH_CRYPTO_UTILS), true)
+ LOCAL_STATIC_LIBRARIES += libcrypto_utils_static
endif
LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS)
LOCAL_STATIC_LIBRARIES += libapplypatch libbase libotafault libedify libmtdutils libminzip libz
+LOCAL_STATIC_LIBRARIES += libflashutils libmmcutils libbmlutils
LOCAL_STATIC_LIBRARIES += libbz
LOCAL_STATIC_LIBRARIES += libcutils liblog libc
LOCAL_STATIC_LIBRARIES += libselinux
+
+LOCAL_STATIC_LIBRARIES += libselinux
tune2fs_static_libraries := \
libext2_com_err \
libext2_blkid \
@@ -56,7 +64,10 @@ tune2fs_static_libraries := \
libext2_uuid_static \
libext2_e2p \
libext2fs
-LOCAL_STATIC_LIBRARIES += libtune2fs $(tune2fs_static_libraries)
+ifneq ($(wildcard external/e2fsprogs/misc/tune2fs.h),)
+ LOCAL_STATIC_LIBRARIES += libtune2fs $(tune2fs_static_libraries)
+ LOCAL_CFLAGS += -DHAVE_LIBTUNE2FS
+endif
LOCAL_C_INCLUDES += external/e2fsprogs/misc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
diff --git a/updater/install.cpp b/updater/install.cpp
index 74feb56be..1c7964053 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -56,8 +56,12 @@
#include "openssl/sha.h"
#include "ota_io.h"
#include "updater.h"
+#include "applypatch/applypatch.h"
+#include "flashutils/flashutils.h"
#include "install.h"
+#ifdef HAVE_LIBTUNE2FS
#include "tune2fs.h"
+#endif
#ifdef USE_EXT4
#include "make_ext4fs.h"
@@ -1478,6 +1482,7 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) {
memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command));
FILE* f = fopen(filename, "r+b");
fseek(f, offsetof(struct bootloader_message, command), SEEK_SET);
+ fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR);
ota_fwrite(buffer, sizeof(((struct bootloader_message*)0)->command), 1, f);
fclose(f);
free(filename);
@@ -1520,6 +1525,7 @@ Value* SetStageFn(const char* name, State* state, int argc, Expr* argv[]) {
// package installation.
FILE* f = fopen(filename, "r+b");
fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET);
+ fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR);
int to_write = strlen(stagestr)+1;
int max_size = sizeof(((struct bootloader_message*)0)->stage);
if (to_write > max_size) {
@@ -1546,6 +1552,7 @@ Value* GetStageFn(const char* name, State* state, int argc, Expr* argv[]) {
char buffer[sizeof(((struct bootloader_message*)0)->stage)];
FILE* f = fopen(filename, "rb");
fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET);
+ fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR);
ota_fread(buffer, sizeof(buffer), 1, f);
fclose(f);
buffer[sizeof(buffer)-1] = '\0';
@@ -1585,6 +1592,7 @@ Value* EnableRebootFn(const char* name, State* state, int argc, Expr* argv[]) {
}
Value* Tune2FsFn(const char* name, State* state, int argc, Expr* argv[]) {
+#ifdef HAVE_LIBTUNE2FS
if (argc == 0) {
return ErrorAbort(state, kArgsParsingFailure, "%s() expects args, got %d", name, argc);
}
@@ -1613,6 +1621,9 @@ Value* Tune2FsFn(const char* name, State* state, int argc, Expr* argv[]) {
name, result);
}
return StringValue(strdup("t"));
+#else
+ return ErrorAbort(state, "%s() support not present, no libtune2fs", name);
+#endif // HAVE_LIBTUNE2FS
}
void RegisterInstallFunctions() {
diff --git a/updater/updater.cpp b/updater/updater.cpp
index e956dd557..452c3530f 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <string.h>
#include "edify/expr.h"
@@ -35,6 +36,8 @@
// Where in the package we expect to find the edify script to execute.
// (Note it's "updateR-script", not the older "update-script".)
#define SCRIPT_NAME "META-INF/com/google/android/updater-script"
+#define SELINUX_CONTEXTS_ZIP "file_contexts"
+#define SELINUX_CONTEXTS_TMP "/tmp/file_contexts"
extern bool have_eio_error;
@@ -100,6 +103,23 @@ int main(int argc, char** argv) {
}
script[script_entry->uncompLen] = '\0';
+ const ZipEntry* file_contexts_entry = mzFindZipEntry(&za, SELINUX_CONTEXTS_ZIP);
+ if (file_contexts_entry != NULL) {
+ int file_contexts_fd = creat(SELINUX_CONTEXTS_TMP, 0644);
+ if (file_contexts_fd < 0) {
+ fprintf(stderr, "Could not extract %s to '%s'\n", SELINUX_CONTEXTS_ZIP, SELINUX_CONTEXTS_TMP);
+ return 3;
+ }
+
+ int ret_val = mzExtractZipEntryToFile(&za, file_contexts_entry, file_contexts_fd);
+ close(file_contexts_fd);
+
+ if (!ret_val) {
+ fprintf(stderr, "Could not extract '%s'\n", SELINUX_CONTEXTS_ZIP);
+ return 3;
+ }
+ }
+
// Configure edify's functions.
RegisterBuiltins();
@@ -118,11 +138,19 @@ int main(int argc, char** argv) {
return 6;
}
- struct selinux_opt seopts[] = {
- { SELABEL_OPT_PATH, "/file_contexts" }
- };
+ if (access(SELINUX_CONTEXTS_TMP, R_OK) == 0) {
+ struct selinux_opt seopts[] = {
+ { SELABEL_OPT_PATH, SELINUX_CONTEXTS_TMP }
+ };
- sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+ sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+ } else {
+ struct selinux_opt seopts[] = {
+ { SELABEL_OPT_PATH, "/file_contexts" }
+ };
+
+ sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+ }
if (!sehandle) {
fprintf(cmd_pipe, "ui_print Warning: No file_contexts\n");