From 8dd2327bbd120ed68f37778a6e5b1ed7aedd81ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 20 Jun 2020 12:17:07 +0100 Subject: [PATCH] home-assistant: add update script --- pkgs/servers/home-assistant/update.sh | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 pkgs/servers/home-assistant/update.sh diff --git a/pkgs/servers/home-assistant/update.sh b/pkgs/servers/home-assistant/update.sh new file mode 100755 index 000000000000..11189cf3577a --- /dev/null +++ b/pkgs/servers/home-assistant/update.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p nix -p jq -p curl -p bash -p git -p nix-update -i bash + +set -eux + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$DIR" + +CURRENT_VERSION=$(nix eval --raw '(with import ../../.. {}; home-assistant.version)') +TARGET_VERSION=$(curl https://api.github.com/repos/home-assistant/core/releases/latest | jq -r '.name') +MANIFEST=$(curl https://raw.githubusercontent.com/home-assistant/core/${TARGET_VERSION}/homeassistant/components/frontend/manifest.json) +FRONTEND_VERSION=$(echo $MANIFEST | jq -r '.requirements[] | select(startswith("home-assistant-frontend")) | sub(".*==(?.*)"; .vers)') + +if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then + echo "home-assistant is up-to-date: ${CURRENT_VERSION}" + exit 0 +fi + + +sed -i -e "s/version =.*/version = \"${TARGET_VERSION}\";/" \ + component-packages.nix + +sed -i -e "s/hassVersion =.*/hassVersion = \"${TARGET_VERSION}\";/" \ + default.nix + +./parse-requirements.py +( + cd ../../.. + nix-update --version "$FRONTEND_VERSION" home-assistant.hass-frontend + nix-update --version "$TARGET_VERSION" --build home-assistant +) + +git add ./component-packages.nix ./default.nix ./frontend.nix +git commit -m "homeassistant: ${CURRENT_VERSION} -> ${TARGET_VERSION}"