aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@foundries.io>2022-11-17 13:22:41 +0000
committerAnders Roxell <anders.roxell@gmail.com>2022-11-23 16:29:46 +0100
commit7779fb6d77a3aa9026dee2b88c3850f47be0ced3 (patch)
tree3c448d53579574b222202599e926214f07e8f682
parentea0537f5a22ef5a928defdbcf45ec6731f60cbcc (diff)
automated: linux: allow ostree to keep single kernel
When doing OTA upgrade ostree might decide that kernel image didn't change and keep just single file for "old" and "new" sysroot versions. This means that corrupting the kernel will brick the board and the rollback wouldn't be possible. This patch addresses the issue by creating a "fake" kernel and updating uEnv.txt. This is a bit more invasive than the previous approach but seems to be the simplest way of forcing "bad kernel" based rollback. Signed-off-by: Milosz Wasilewski <milosz.wasilewski@foundries.io>
-rwxr-xr-xautomated/linux/ota-rollback/download-update.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/automated/linux/ota-rollback/download-update.sh b/automated/linux/ota-rollback/download-update.sh
index 27049ac5..29b60f0a 100755
--- a/automated/linux/ota-rollback/download-update.sh
+++ b/automated/linux/ota-rollback/download-update.sh
@@ -204,9 +204,20 @@ if [ "${UPGRADE_AVAILABLE}" -eq 1 ]; then
cat /boot/loader/uEnv.txt
. /boot/loader/uEnv.txt
# shellcheck disable=SC2154
- echo "Corrupting kernel image ${kernel_image}"
- # shellcheck disable=SC2154
- echo bad > "${kernel_image}"
+ if [ "${kernel_image}" = "${kernel_image2}" ]; then
+ # when there is just one kernel, create a fake one and update uEnv.txt
+ # shellcheck disable=SC2154
+ kernel_dirname=$(dirname "${kernel_image}")
+ # shellcheck disable=SC2154
+ echo "bad" > "${kernel_dirname}/vmlinuz-corrupt"
+ # shellcheck disable=SC2154
+ sed -i "s|kernel_image=${kernel_image}|kernel_image=${kernel_dirname}/vmlinuz-corrupt|g" /boot/loader/uEnv.txt
+ else
+ # shellcheck disable=SC2154
+ echo "Corrupting kernel image ${kernel_image}"
+ # shellcheck disable=SC2154
+ echo bad > "${kernel_image}"
+ fi
fi
else
lava-test-raise "No-update-available-${TYPE}"