mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-12-25 04:45:45 +00:00
* Use Genimage for declarative image layout instead of s[fg]disk and dd * Change partition type to hybrid for M1, M1S and Green This is what it really is, so just make sure only one "fix" function is called. * Change efi BOOT_SYS to gpt There is no reason to have separate efi and boot sys, since all boards that use efi also use grub as the loader. * Change BOOT_SYS to more explanatory PARTITION_TABLE_TYPE * Add units to DISK_SIZE * Add forced-primary patch and use it in MBR images * Avoid disabling SC2155, remove old comments
63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
|
|
function prepare_rauc_signing() {
|
|
local key="/build/key.pem"
|
|
local cert="/build/cert.pem"
|
|
|
|
if [ ! -f "${key}" ]; then
|
|
echo "Generating a self-signed certificate for development"
|
|
"${BR2_EXTERNAL_HASSOS_PATH}"/scripts/generate-signing-key.sh "${cert}" "${key}"
|
|
fi
|
|
}
|
|
|
|
|
|
function write_rauc_config() {
|
|
mkdir -p "${TARGET_DIR}/etc/rauc"
|
|
|
|
local ota_compatible
|
|
ota_compatible="$(hassos_rauc_compatible)"
|
|
|
|
export ota_compatible
|
|
export BOOTLOADER PARTITION_TABLE_TYPE BOOT_SPL
|
|
|
|
(
|
|
"${HOST_DIR}/bin/tempio" \
|
|
-template "${BR2_EXTERNAL_HASSOS_PATH}/ota/system.conf.gtpl"
|
|
) > "${TARGET_DIR}/etc/rauc/system.conf"
|
|
}
|
|
|
|
|
|
function install_rauc_certs() {
|
|
local cert="/build/cert.pem"
|
|
|
|
if [ "${DEPLOYMENT}" == "development" ]; then
|
|
# Contains development and release certificate
|
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/ota/dev-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem"
|
|
else
|
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/ota/rel-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem"
|
|
fi
|
|
|
|
# Add local self-signed certificate (if not trusted by the dev or release
|
|
# certificate it is a self-signed certificate, dev-ca.pem contains both)
|
|
if ! openssl verify -CAfile "${BR2_EXTERNAL_HASSOS_PATH}/ota/dev-ca.pem" -no-CApath "${cert}"; then
|
|
echo "Adding self-signed certificate to keyring."
|
|
openssl x509 -in "${cert}" -text >> "${TARGET_DIR}/etc/rauc/keyring.pem"
|
|
fi
|
|
}
|
|
|
|
|
|
function install_bootloader_config() {
|
|
if [ "${BOOTLOADER}" == "uboot" ]; then
|
|
# shellcheck disable=SC1117
|
|
echo -e "/dev/disk/by-partlabel/hassos-bootstate\t0x0000\t${BOOT_ENV_SIZE}" > "${TARGET_DIR}/etc/fw_env.config"
|
|
fi
|
|
|
|
# Fix MBR
|
|
if [ "${PARTITION_TABLE_TYPE}" == "mbr" ]; then
|
|
mkdir -p "${TARGET_DIR}/usr/lib/udev/rules.d"
|
|
cp -f "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/mbr-part.rules" "${TARGET_DIR}/usr/lib/udev/rules.d/"
|
|
fi
|
|
}
|