summaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
Diffstat (limited to 'updater')
-rw-r--r--updater/Android.mk19
-rw-r--r--updater/install.cpp17
-rw-r--r--updater/updater.cpp18
3 files changed, 47 insertions, 7 deletions
diff --git a/updater/Android.mk b/updater/Android.mk
index 86dc48e30..cef6b963f 100644
--- a/updater/Android.mk
+++ b/updater/Android.mk
@@ -14,13 +14,18 @@
LOCAL_PATH := $(call my-dir)
-tune2fs_static_libraries := \
- libext2_com_err \
- libext2_blkid \
- libext2_quota \
- libext2_uuid \
- libext2_e2p \
- libext2fs
+ifneq ($(wildcard external/e2fsprogs/misc/tune2fs.h),)
+ tune2fs_static_libraries := \
+ libext2_com_err \
+ libext2_blkid \
+ libext2_quota \
+ libext2_uuid \
+ libext2_e2p \
+ libext2fs
+ LOCAL_CFLAGS += -DHAVE_LIBTUNE2FS
+else
+ tune2fs_static_libraries :=
+endif
updater_common_static_libraries := \
libapplypatch \
diff --git a/updater/install.cpp b/updater/install.cpp
index bfe91e7f9..0d473fce4 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -60,6 +60,19 @@
#include "error_code.h"
#include "mounts.h"
#include "ota_io.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"
+#include "wipe.h"
+#endif
+
#include "otautil/DirUtil.h"
#include "print_sha1.h"
#include "tune2fs.h"
@@ -993,6 +1006,7 @@ Value* EnableRebootFn(const char* name, State* state, const std::vector<std::uni
}
Value* Tune2FsFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
+#ifdef HAVE_LIBTUNE2FS
if (argv.empty()) {
return ErrorAbort(state, kArgsParsingFailure, "%s() expects args, got %zu", name, argv.size());
}
@@ -1019,6 +1033,9 @@ Value* Tune2FsFn(const char* name, State* state, const std::vector<std::unique_p
return ErrorAbort(state, kTune2FsFailure, "%s() returned error code %d", name, result);
}
return StringValue("t");
+#else
+ return ErrorAbort(state, kTune2FsFailure, "%s() support not present, no libtune2fs", name);
+#endif // HAVE_LIBTUNE2FS
}
void RegisterInstallFunctions() {
diff --git a/updater/updater.cpp b/updater/updater.cpp
index 1d8fa8e92..25bd541b0 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <string.h>
#include <string>
@@ -46,6 +47,9 @@
// (Note it's "updateR-script", not the older "update-script".)
static constexpr const char* 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;
struct selabel_handle *sehandle;
@@ -167,6 +171,20 @@ int main(int argc, char** argv) {
}
ota_io_init(za, state.is_retry);
+ 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);
+ } else {
+ struct selinux_opt seopts[] = {
+ { SELABEL_OPT_PATH, "/file_contexts" }
+ };
+
+ sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+ }
+
std::string result;
bool status = Evaluate(&state, root, &result);