From e1f757c3cfdf99ad3356227ceaaea4bb5ecae61e Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 10 Oct 2024 09:30:29 +0200 Subject: [PATCH 1/4] 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. --- buildroot-external/package/hassio/Config.in | 6 ++++++ .../package/hassio/create-data-partition.sh | 3 ++- .../package/hassio/dind-import-containers.sh | 4 ++++ buildroot-external/package/hassio/hassio.mk | 8 ++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/buildroot-external/package/hassio/Config.in b/buildroot-external/package/hassio/Config.in index f7a6a84c294..537f3bcf480 100644 --- a/buildroot-external/package/hassio/Config.in +++ b/buildroot-external/package/hassio/Config.in @@ -18,4 +18,10 @@ config BR2_PACKAGE_HASSIO_MACHINE help Machine to pull containers for (used for landing page). +config BR2_PACKAGE_HASSIO_CHANNEL + string "Default Channel" + default "stable" + help + Channel to use by default. + endif diff --git a/buildroot-external/package/hassio/create-data-partition.sh b/buildroot-external/package/hassio/create-data-partition.sh index aa272486e3f..97ac0259372 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 639d421e48f..019e83e2a10 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 317107d840b..62666364d43 100644 --- a/buildroot-external/package/hassio/hassio.mk +++ b/buildroot-external/package/hassio/hassio.mk @@ -9,13 +9,13 @@ 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/$(BR2_PACKAGE_HASSIO_CHANNEL).json" 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) | jq '.core = "landingpage"' > $(@D)/version.json endef define HASSIO_BUILD_CMDS @@ -23,14 +23,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)" "$(BR2_PACKAGE_HASSIO_CHANNEL)" endef $(eval $(generic-package)) From cf8446cca2b0c8bec37efbaebe777059c8f3c402 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 18 Nov 2024 13:01:11 +0100 Subject: [PATCH 2/4] Use choice instead of string variable --- buildroot-external/package/hassio/Config.in | 19 ++++++++++++++++--- buildroot-external/package/hassio/hassio.mk | 11 +++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/buildroot-external/package/hassio/Config.in b/buildroot-external/package/hassio/Config.in index 537f3bcf480..dc4c9decf03 100644 --- a/buildroot-external/package/hassio/Config.in +++ b/buildroot-external/package/hassio/Config.in @@ -18,10 +18,23 @@ config BR2_PACKAGE_HASSIO_MACHINE help Machine to pull containers for (used for landing page). -config BR2_PACKAGE_HASSIO_CHANNEL - string "Default Channel" - default "stable" +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/hassio.mk b/buildroot-external/package/hassio/hassio.mk index 62666364d43..0f662cfe86a 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/$(BR2_PACKAGE_HASSIO_CHANNEL).json" +HASSIO_VERSION_URL = "https://version.home-assistant.io/" +ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_STABLE),y) +HASSIO_VERSION_FILE = "stable.json" +else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_BETA),y) +HASSIO_VERSION_FILE = "beta.json" +else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_DEV),y) +HASSIO_VERSION_FILE = "dev.json" +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)/version.json + curl -s $(HASSIO_VERSION_URL)$(HASSIO_VERSION_FILE) | jq '.core = "landingpage"' > $(@D)/version.json endef define HASSIO_BUILD_CMDS From 8cfa907c0cf9a366cc8373e8ee20781f0a71055b Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 18 Nov 2024 14:14:30 +0100 Subject: [PATCH 3/4] Fix channel in Supervisor updater.json config --- buildroot-external/package/hassio/hassio.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildroot-external/package/hassio/hassio.mk b/buildroot-external/package/hassio/hassio.mk index 0f662cfe86a..423be2d17d7 100644 --- a/buildroot-external/package/hassio/hassio.mk +++ b/buildroot-external/package/hassio/hassio.mk @@ -11,18 +11,18 @@ HASSIO_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio HASSIO_SITE_METHOD = local HASSIO_VERSION_URL = "https://version.home-assistant.io/" ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_STABLE),y) -HASSIO_VERSION_FILE = "stable.json" +HASSIO_VERSION_CHANNEL = "stable" else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_BETA),y) -HASSIO_VERSION_FILE = "beta.json" +HASSIO_VERSION_CHANNEL = "beta" else ifeq ($(BR2_PACKAGE_HASSIO_CHANNEL_DEV),y) -HASSIO_VERSION_FILE = "dev.json" +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)$(HASSIO_VERSION_FILE) | jq '.core = "landingpage"' > $(@D)/version.json + curl -s $(HASSIO_VERSION_URL)$(HASSIO_VERSION_CHANNEL)".json" | jq '.core = "landingpage"' > $(@D)/version.json endef define HASSIO_BUILD_CMDS @@ -37,7 +37,7 @@ endef HASSIO_INSTALL_IMAGES = YES define HASSIO_INSTALL_IMAGES_CMDS - $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio/create-data-partition.sh "$(@D)" "$(BINARIES_DIR)" "$(BR2_PACKAGE_HASSIO_CHANNEL)" + $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio/create-data-partition.sh "$(@D)" "$(BINARIES_DIR)" "$(HASSIO_VERSION_CHANNEL)" endef $(eval $(generic-package)) From c21cca3fe2c083b6a3e24092dd3b3377142bbe08 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 18 Nov 2024 14:38:44 +0100 Subject: [PATCH 4/4] Add newlines --- buildroot-external/package/hassio/Config.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildroot-external/package/hassio/Config.in b/buildroot-external/package/hassio/Config.in index dc4c9decf03..7f802015e3f 100644 --- a/buildroot-external/package/hassio/Config.in +++ b/buildroot-external/package/hassio/Config.in @@ -23,18 +23,22 @@ choice 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