From f169f78bb00a1cefeb00662b67d63c3ded06fb56 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 18 Nov 2024 14:39:46 +0100 Subject: [PATCH] Add Kconfig option for Supervisor channel (#3618) * Add Makefile variable for Supervisor channel Allow to set the release channel pre-installed Home Assistant components like Supervisor and add-on are fetched from. This channel is then also used at runtime. * Use choice instead of string variable * Fix channel in Supervisor updater.json config * Add newlines --- buildroot-external/package/hassio/Config.in | 23 +++++++++++++++++++ .../package/hassio/create-data-partition.sh | 3 ++- .../package/hassio/dind-import-containers.sh | 4 ++++ buildroot-external/package/hassio/hassio.mk | 15 ++++++++---- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/buildroot-external/package/hassio/Config.in b/buildroot-external/package/hassio/Config.in index f7a6a84c2..7f802015e 100644 --- a/buildroot-external/package/hassio/Config.in +++ b/buildroot-external/package/hassio/Config.in @@ -18,4 +18,27 @@ config BR2_PACKAGE_HASSIO_MACHINE help Machine to pull containers for (used for landing page). +choice + prompt "Default Channel" + default BR2_PACKAGE_HASSIO_CHANNEL_STABLE + help + Channel to use by default. + +config BR2_PACKAGE_HASSIO_CHANNEL_STABLE + bool "Stable" + help + Stable channel. + +config BR2_PACKAGE_HASSIO_CHANNEL_BETA + bool "Beta" + help + Beta channel. + +config BR2_PACKAGE_HASSIO_CHANNEL_DEV + bool "Dev" + help + Dev channel. + +endchoice + endif diff --git a/buildroot-external/package/hassio/create-data-partition.sh b/buildroot-external/package/hassio/create-data-partition.sh index aa272486e..97ac02593 100755 --- a/buildroot-external/package/hassio/create-data-partition.sh +++ b/buildroot-external/package/hassio/create-data-partition.sh @@ -3,6 +3,7 @@ set -e build_dir=$1 dst_dir=$2 +channel=$3 data_img="${dst_dir}/data.ext4" @@ -24,7 +25,7 @@ container=$(docker run --privileged -e DOCKER_TLS_CERTDIR="" \ -v "${build_dir}":/build \ -d docker:27.2-dind --storage-driver overlay2) -docker exec "${container}" sh /build/dind-import-containers.sh +docker exec "${container}" sh /build/dind-import-containers.sh "${channel}" docker stop "${container}" diff --git a/buildroot-external/package/hassio/dind-import-containers.sh b/buildroot-external/package/hassio/dind-import-containers.sh index 639d421e4..019e83e2a 100755 --- a/buildroot-external/package/hassio/dind-import-containers.sh +++ b/buildroot-external/package/hassio/dind-import-containers.sh @@ -1,6 +1,8 @@ #!/bin/sh set -e +channel=$1 + APPARMOR_URL="https://version.home-assistant.io/apparmor.txt" # Make sure we can talk to the Docker daemon @@ -27,3 +29,5 @@ docker tag "${supervisor}" "ghcr.io/home-assistant/${arch}-hassio-supervisor:lat # Setup AppArmor mkdir -p "/data/supervisor/apparmor" wget -O "/data/supervisor/apparmor/hassio-supervisor" "${APPARMOR_URL}" + +echo "{ \"channel\": \"${channel}\" }" > /data/supervisor/updater.json diff --git a/buildroot-external/package/hassio/hassio.mk b/buildroot-external/package/hassio/hassio.mk index 317107d84..423be2d17 100644 --- a/buildroot-external/package/hassio/hassio.mk +++ b/buildroot-external/package/hassio/hassio.mk @@ -9,13 +9,20 @@ HASSIO_LICENSE = Apache License 2.0 # HASSIO_LICENSE_FILES = $(BR2_EXTERNAL_HASSOS_PATH)/../LICENSE HASSIO_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio HASSIO_SITE_METHOD = local -HASSIO_VERSION_URL = "https://version.home-assistant.io/stable.json" +HASSIO_VERSION_URL = "https://version.home-assistant.io/" +ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_STABLE),y) +HASSIO_VERSION_CHANNEL = "stable" +else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_BETA),y) +HASSIO_VERSION_CHANNEL = "beta" +else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_DEV),y) +HASSIO_VERSION_CHANNEL = "dev" +endif HASSIO_CONTAINER_IMAGES_ARCH = supervisor dns audio cli multicast observer core define HASSIO_CONFIGURE_CMDS # Deploy only landing page for "core" by setting version to "landingpage" - curl -s $(HASSIO_VERSION_URL) | jq '.core = "landingpage"' > $(@D)/stable.json + curl -s $(HASSIO_VERSION_URL)$(HASSIO_VERSION_CHANNEL)".json" | jq '.core = "landingpage"' > $(@D)/version.json endef define HASSIO_BUILD_CMDS @@ -23,14 +30,14 @@ define HASSIO_BUILD_CMDS $(Q)mkdir -p $(HASSIO_DL_DIR) $(foreach image,$(HASSIO_CONTAINER_IMAGES_ARCH),\ $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio/fetch-container-image.sh \ - $(BR2_PACKAGE_HASSIO_ARCH) $(BR2_PACKAGE_HASSIO_MACHINE) $(@D)/stable.json $(image) "$(HASSIO_DL_DIR)" "$(@D)/images" + $(BR2_PACKAGE_HASSIO_ARCH) $(BR2_PACKAGE_HASSIO_MACHINE) $(@D)/version.json $(image) "$(HASSIO_DL_DIR)" "$(@D)/images" ) endef HASSIO_INSTALL_IMAGES = YES define HASSIO_INSTALL_IMAGES_CMDS - $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio/create-data-partition.sh "$(@D)" "$(BINARIES_DIR)" + $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio/create-data-partition.sh "$(@D)" "$(BINARIES_DIR)" "$(HASSIO_VERSION_CHANNEL)" endef $(eval $(generic-package))