Use tempio to generate RAUC configuration files (#1797)

* Add tempio host package

tempio is a template helper using Go's template engine and sprig
functions.

* Use tempio to generate rauc manifest

* Use tempio to generate rauc system.conf
This commit is contained in:
Stefan Agner
2022-03-17 20:28:40 +01:00
committed by GitHub
parent dde7a7b809
commit 616c406e8e
22 changed files with 134 additions and 88 deletions

View File

@@ -3,6 +3,8 @@
function create_ota_update() {
local ota_file="$(hassos_image_name raucb)"
local ota_compatible="$(hassos_rauc_compatible)"
local ota_version="$(hassos_version)"
local rauc_folder="${BINARIES_DIR}/rauc"
local boot="${BINARIES_DIR}/boot.vfat"
local kernel="${BINARIES_DIR}/kernel.img"
@@ -26,35 +28,17 @@ function create_ota_update() {
cp -f "${rootfs}" "${rauc_folder}/rootfs.img"
cp -f "${BR2_EXTERNAL_HASSOS_PATH}/ota/rauc-hook" "${rauc_folder}/hook"
(
echo "[update]"
echo "compatible=$(hassos_rauc_compatible)"
echo "version=$(hassos_version)"
echo "[hooks]"
echo "filename=hook"
echo "hooks=install-check"
echo "[image.boot]"
echo "filename=boot.vfat"
echo "hooks=install"
echo "[image.kernel]"
echo "filename=kernel.img"
if [ "${BOOTLOADER}" == "grub" ]; then
echo "hooks=post-install"
fi
echo "[image.rootfs]"
echo "filename=rootfs.img"
) > "${rauc_folder}/manifest.raucm"
# SPL
if [ "${BOOT_SPL}" == "true" ]; then
cp -f "${spl}" "${rauc_folder}/spl.img"
(
echo "[image.spl]"
echo "filename=spl.img"
echo "hooks=install"
) >> "${rauc_folder}/manifest.raucm"
fi
export BOOTLOADER BOOT_SPL
export ota_compatible ota_version
(
"${HOST_DIR}/bin/host-tempio" \
-template "${BR2_EXTERNAL_HASSOS_PATH}/ota/manifest.raucm.gtpl"
) > "${rauc_folder}/manifest.raucm"
rauc bundle -d --cert="${cert}" --key="${key}" --keyring="${keyring}" "${rauc_folder}" "${ota_file}"
}

View File

@@ -1,73 +1,20 @@
#!/bin/bash
set -e
function _create_rauc_header() {
(
echo "[system]"
echo "compatible=$(hassos_rauc_compatible)"
echo "mountprefix=/run/rauc"
echo "statusfile=/mnt/data/rauc.db"
echo "bootloader=${BOOTLOADER}"
if [ "${BOOTLOADER}" == "grub" ]; then
if [ "${BOOT_SYS}" == "efi" ]; then
echo "grubenv=/mnt/boot/EFI/BOOT/grubenv"
else
echo "grubenv=/mnt/boot/grubenv"
fi
fi
echo "[keyring]"
echo "path=/etc/rauc/keyring.pem"
) > "${TARGET_DIR}/etc/rauc/system.conf"
}
function _write_rauc_boot() {
(
echo "[slot.boot.0]"
echo "device=/dev/disk/by-partlabel/hassos-boot"
echo "type=vfat"
echo "allow-mounted=true"
) >> "${TARGET_DIR}/etc/rauc/system.conf"
# SPL
if ! [ "${BOOT_SPL}" == "true" ]; then
return 0
fi
(
echo "[slot.spl.0]"
echo "device=/dev/disk/by-partlabel/hassos-boot"
echo "type=raw"
) >> "${TARGET_DIR}/etc/rauc/system.conf"
}
function _write_rauc_system() {
local slot_num=${1}
local slot_name=${2}
(
echo "[slot.kernel.${slot_num}]"
echo "device=/dev/disk/by-partlabel/hassos-kernel${slot_num}"
echo "type=raw"
echo "bootname=${slot_name}"
echo "[slot.rootfs.${slot_num}]"
echo "device=/dev/disk/by-partlabel/hassos-system${slot_num}"
echo "type=raw"
echo "parent=kernel.${slot_num}"
) >> "${TARGET_DIR}/etc/rauc/system.conf"
}
function write_rauc_config() {
mkdir -p "${TARGET_DIR}/etc/rauc"
_create_rauc_header
_write_rauc_boot
_write_rauc_system 0 A
_write_rauc_system 1 B
local ota_compatible
ota_compatible="$(hassos_rauc_compatible)"
export ota_compatible
export BOOTLOADER BOOT_SYS BOOT_SPL
(
"${HOST_DIR}/bin/host-tempio" \
-template "${BR2_EXTERNAL_HASSOS_PATH}/ota/system.conf.gtpl"
) > "${TARGET_DIR}/etc/rauc/system.conf"
}