Files
operating-system/buildroot-external/ota/rauc-hook
Stefan Agner 19c03729f3 Accept installation with intel-nuc in compatible string (#1265)
* Accept installation with intel-nuc in compatible string

For the OS release 6 intel-nuc gets renamed to generic-x86-64. Since
the machine name is in the OS compatible string we need to make sure
OS release 5 installation can update to release 6 despite the new
machine name.
2021-03-09 23:53:15 +01:00

80 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
##
# Hooks
case "$1" in
install-check)
if [ "$RAUC_MF_COMPATIBLE" = "$RAUC_SYSTEM_COMPATIBLE" ]; then
exit 0
fi
# Be compatible with hassos OS ID
# shellcheck disable=SC2039
rauc_os_compatible=${RAUC_MF_COMPATIBLE/haos-/hassos-}
if [ "$rauc_os_compatible" = "$RAUC_SYSTEM_COMPATIBLE" ]; then
exit 0
fi
# generic-x86-64: Be compatible with intel-nuc
# shellcheck disable=SC2039
rauc_board_compatible=${rauc_os_compatible/generic-x86-64/intel-nuc}
if [ "${rauc_board_compatible}" = "$RAUC_SYSTEM_COMPATIBLE" ]; then
exit 0
fi
echo "Compatible does not match!" 1>&2
exit 10
;;
slot-install)
# Use install handlers below
;;
*)
exit 1
;;
esac
# Handle boot hocks
if [ "${RAUC_SLOT_CLASS}" = "boot" ]; then
BOOT_TMP=/tmp/boot-tmp
BOOT_NEW=/tmp/boot-new
BOOT_MNT=/mnt/boot
mkdir -p "${BOOT_TMP}"
mkdir -p "${BOOT_NEW}"
# Mount boot
if ! systemctl -q is-active mnt-boot.mount; then
systemctl start mnt-boot.mount
fi
mount "${RAUC_IMAGE_NAME}" "${BOOT_NEW}"
# Backup boot config
cp -f "${BOOT_MNT}"/*.txt "${BOOT_TMP}/"
# Update
cp -rf "${BOOT_NEW}"/* "${BOOT_MNT}/"
# Restore boot config
cp -f "${BOOT_TMP}"/*.txt "${BOOT_MNT}/"
umount "${BOOT_NEW}"
rm -rf "${BOOT_TMP}" "${BOOT_NEW}"
fi
# Handle spl install
if [ "${RAUC_SLOT_CLASS}" = "spl" ]; then
DEVICE_CHILD="$(findfs LABEL="hassos-boot")"
DEVICE_ROOT="/dev/$(lsblk -no pkname "${DEVICE_CHILD}")"
if sfdisk -dq "${DEVICE_ROOT}" | grep -q 'label: gpt'; then
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc bs=512 seek=2 skip=2
else
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc bs=1 count=440
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc bs=512 seek=1 skip=1
fi
fi
##
# Fixups
exit 0