summaryrefslogtreecommitdiff
path: root/postinst
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2016-03-02 18:02:17 -0800
committerAlex Deymo <deymo@google.com>2016-03-02 18:05:42 -0800
commitc4aecefead494452012cdc75afc8bab5dbdf8a99 (patch)
treed55ab2c96fbfcc95047c53d3b419041741ac2cca /postinst
parent9e0f649ea94cce48df7bfca238fecac1ed1dac98 (diff)
downloadextras-c4aecefead494452012cdc75afc8bab5dbdf8a99.tar.gz
postinst: Update postinstall_example documentation.
We don't need the /postinst symlink anymore, instead we should provide the path to the executable in the config. An example of how to setup that is now included in the documentation of postinstall_example. Bug: 27177071 TEST=Deployed this script as postinstall on edison-eng. Change-Id: I2f7bd50174db42a57d25277883b0ec795ca17144
Diffstat (limited to 'postinst')
-rw-r--r--postinst/Android.mk6
-rw-r--r--postinst/postinst.sh37
2 files changed, 26 insertions, 17 deletions
diff --git a/postinst/Android.mk b/postinst/Android.mk
index b0dec050..c804cfca 100644
--- a/postinst/Android.mk
+++ b/postinst/Android.mk
@@ -21,10 +21,4 @@ LOCAL_MODULE:= postinst_example
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_SRC_FILES := postinst.sh
-
-# Create a symlink from /postinst to our default post-install script in the
-# same filesystem as /postinst.
-# TODO(deymo): Remove this symlink and add the path to the product config.
-LOCAL_POST_INSTALL_CMD := \
- $(hide) ln -sf bin/postinst_example $(TARGET_OUT)/postinst
include $(BUILD_PREBUILT)
diff --git a/postinst/postinst.sh b/postinst/postinst.sh
index eb98e79f..b6a4d201 100644
--- a/postinst/postinst.sh
+++ b/postinst/postinst.sh
@@ -18,18 +18,33 @@
# This is an example post-install script. This script will be executed by the
# update_engine right after finishing writing all the partitions, but before
-# marking the new slot as active.
-#
+# marking the new slot as active. To enable running this program, insert these
+# lines in your product's .mk file (without the # at the beginning):
+
+# AB_OTA_POSTINSTALL_CONFIG += \
+# RUN_POSTINSTALL_system=true \
+# POSTINSTALL_PATH_system=bin/postinst_example \
+# FILESYSTEM_TYPE_system=ext4 \
+
# This script receives no arguments. argv[0] will include the absolute path to
-# the script, including the temporary directory where the new partition was
-# mounted.
-#
-# This script will run in the context of the old kernel and old system. Note
-# that the absolute path used in first line of this script (/system/bin/sh) is
-# indeed the old system's sh binary. If you use a compiled program, you might
-# want to link it statically or use a wrapper script to use the new ldso to run
-# your program (see the --generate-wrappers option in lddtree.py for example).
-#
+# the script, including the directory where the new partition was mounted.
+#
+# The script will run from the "postinstall" SELinux domain, from the old system
+# environment (kernel, SELinux rules, etc). New rules and domains introduced by
+# the new system won't be available when this script runs, instead, all the
+# files in the mounted directory will have the attribute "postinstall_file". All
+# the files accessed from here would need to be allowed in the old system or
+# those accesses will fail. For example, the absolute path used in the first
+# line of this script (/system/bin/sh) is indeed the old system's sh binary. If
+# you use a compiled program, you might want to link it statically or use a
+# wrapper script to use the new ldso to run your program (see the
+# --generate-wrappers option in lddtree.py for an example).
+
+my_dir=$(dirname "$0")
+
+echo "The output of this program will show up in the logs." >&2
+echo "Note that this program runs from ${my_dir}"
+
# If the exit code of this program is an error code (different from 0), the
# update will fail and the new slot will not be marked as active.