summaryrefslogtreecommitdiff
path: root/postinst
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2016-03-30 18:50:59 -0700
committerAlex Deymo <deymo@google.com>2016-03-30 20:09:24 -0700
commit74ef144cd4192ef47dac6a8c844c3aeaece19b9e (patch)
treefb18f0d0a75befc992ed3397a026edb14f57fd15 /postinst
parenteaa9c1dc0c2c7bd4570e0b7c605bac207e6ab3a3 (diff)
downloadextras-74ef144cd4192ef47dac6a8c844c3aeaece19b9e.tar.gz
postinst: Update postinstall_example.
The postinstall step now receives two parameters: the target slot and the progress file descriptor. This file descriptor is a pipe where the postinstall program can write back to the updater what's its current progress. Bug: 27880754 TEST=Deployed an image with the postinstall example installed. Change-Id: I0afedb47556885d4e3b3f1b93be82314153ffc19
Diffstat (limited to 'postinst')
-rw-r--r--postinst/postinst.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/postinst/postinst.sh b/postinst/postinst.sh
index b6a4d201..5ab2021a 100644
--- a/postinst/postinst.sh
+++ b/postinst/postinst.sh
@@ -40,11 +40,32 @@
# wrapper script to use the new ldso to run your program (see the
# --generate-wrappers option in lddtree.py for an example).
+# We get called with two parameters: <target_slot> <status_fd>
+# * <target_slot> is the slot where the new system was just copied. This is
+# normally either 0 or 1. You can get the target suffix running
+# `bootctl get-suffix ${target_slot}`
+# * <status_fd> is a file descriptor number where this script can write to to
+# report the progress of the process. See examples below.
+
+target_slot="$1"
+status_fd="$2"
+
my_dir=$(dirname "$0")
+# We can notify the updater of the progress of our program by writing to the
+# status file descriptor "set_progress <frac>\n".
+print -u${status_fd} "global_progress 0"
+
echo "The output of this program will show up in the logs." >&2
+
+# We are half way done, so we set 0.5.
+print -u${status_fd} "global_progress 0.5"
+
echo "Note that this program runs from ${my_dir}"
+# Actually, we were done.
+print -u${status_fd} "global_progress 1.0"
+
# 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.