From 55c9b54b13305683e67300f2e172a9453f5b0526 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 27 Dec 2021 14:58:19 +0100 Subject: [PATCH] Check if Busybox supports oflag (#1692) (#1694) * Check if Busybox supports oflag It seems that Busybox' dd shipped with OS release 5 and earlier does not support oflag. Check if the flag is supported before making use of it. * Exit if a command in the update scripts returns an error This makes sure that the update isn't marked as successful in case there is an error in the update script. --- buildroot-external/ota/rauc-hook | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/buildroot-external/ota/rauc-hook b/buildroot-external/ota/rauc-hook index 92410492c..549211fdf 100755 --- a/buildroot-external/ota/rauc-hook +++ b/buildroot-external/ota/rauc-hook @@ -1,5 +1,7 @@ #!/bin/sh +set -o errexit + ## # Hooks @@ -65,12 +67,17 @@ if [ "${RAUC_SLOT_CLASS}" = "spl" ]; then DEVICE_ROOT="/dev/$(lsblk -no pkname "${DEVICE_CHILD}")" PART_TABLE="$(sfdisk -lqJ "${DEVICE_ROOT}")" PART_LABEL="$(echo "${PART_TABLE}" | jq -r '.partitiontable.label')" + FLAGS="" + + if dd oflag=direct if=/dev/null 2> /dev/null; then + FLAGS="oflag=direct" + fi if [ "${PART_LABEL}" = "gpt" ]; then - dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc oflag=direct bs=512 seek=2 skip=2 + dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=512 seek=2 skip=2 else - dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc oflag=direct bs=1 count=440 - dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc oflag=direct bs=512 seek=1 skip=1 + dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=1 count=440 + dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=512 seek=1 skip=1 fi fi