RAUC: Copy old /cfg to the new /cfg during updates
It seems that RAUC doesn't really have a concept of hooks that are
already located on the system being updated. One could completely
replace some steps, but that's not what I want to do because I do not
really want to duplicate the logic for rootfs.
Instead, let's go with hooks stored in the individual bundles. In the
end, I do not think that this is a huge drawback -- the updates will
have to contain this hook "somewhere", either in the rootfs, or in the
bundle metadata. Having it just in the bundle metadata is no worse. In
fact, it's better because changes take effect immediately.
How this works:
- an empty tarball is needed because RAUC otherwise attempts to mmap() a
directory when no image file name is given
- because there's an empty tarball, the cfg FS gets wiped at first
- this empty tarball is then extracted over the just-made FS
- finally, our hooks runs and copies stuff from the existing /cfg into
the new /cfg
This all means that any configuration changed after this update won't
survive a reboot into the new software. This should probably be
documented somewhere.
Change-Id: I12b11ab93f53f99f1d8875655fa9ec9575830586
diff --git a/board/czechlight/common/rauc-hook.sh b/board/czechlight/common/rauc-hook.sh
new file mode 100755
index 0000000..65401d6
--- /dev/null
+++ b/board/czechlight/common/rauc-hook.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+case "$1" in
+ slot-post-install)
+ case "$RAUC_SLOT_CLASS" in
+ cfg)
+ if [[ -d /cfg/etc ]]; then
+ cp -a /cfg/etc ${RAUC_SLOT_MOUNT_POINT}/
+ fi
+ ;;
+ *)
+ echo "Internal error: hook mismatched"
+ exit 11
+ esac
+ ;;
+ *)
+ echo "Internal error: unrecognized hook"
+ exit 11
+ ;;
+esac
+
+exit 0