2021-09-22 15:38:15 +00:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i bash -p curl gnugrep nix-prefetch jq
|
|
|
|
|
|
|
|
# This file is based on /pkgs/servers/gotify/update.sh
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
dirname="$(dirname "$0")"
|
|
|
|
bins="$dirname/bins.nix"
|
|
|
|
|
|
|
|
latest_release=$(curl --silent https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest)
|
|
|
|
version=$(jq -r '.tag_name' <<<"$latest_release")
|
|
|
|
|
|
|
|
echo "got version $version"
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
schema_version=$(curl --silent "https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/${version}/internal/configmigrate/configmigrate.go" \
|
|
|
|
| grep -Po '(?<=const LastSchemaVersion uint = )[[:digit:]]+$')
|
2022-10-30 15:09:59 +00:00
|
|
|
|
|
|
|
echo "got schema_version $schema_version"
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
declare -A systems
|
|
|
|
systems[linux_386]=i686-linux
|
|
|
|
systems[linux_amd64]=x86_64-linux
|
|
|
|
systems[linux_arm64]=aarch64-linux
|
2023-02-16 17:41:37 +00:00
|
|
|
systems[linux_armv6]=armv6l-linux
|
|
|
|
systems[linux_armv7]=armv7l-linux
|
2021-09-22 15:38:15 +00:00
|
|
|
systems[darwin_amd64]=x86_64-darwin
|
2022-04-27 09:35:20 +00:00
|
|
|
systems[darwin_arm64]=aarch64-darwin
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
echo '{ fetchurl, fetchzip }:' > "$bins"
|
2022-04-27 09:35:20 +00:00
|
|
|
echo '{' >> "$bins"
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
for asset in $(curl --silent https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -c '.assets[]') ; do
|
|
|
|
url="$(jq -r '.browser_download_url' <<< "$asset")"
|
2023-02-16 17:41:37 +00:00
|
|
|
adg_system="$(grep -Eo '(darwin|linux)_(386|amd64|arm64|armv6|armv7)' <<< "$url" || true)"
|
2021-09-22 15:38:15 +00:00
|
|
|
if [ -n "$adg_system" ]; then
|
|
|
|
fetch="$(grep '\.zip$' <<< "$url" > /dev/null && echo fetchzip || echo fetchurl)"
|
|
|
|
nix_system=${systems[$adg_system]}
|
|
|
|
nix_src="$(nix-prefetch -s --output nix $fetch --url $url)"
|
2022-04-27 09:35:20 +00:00
|
|
|
echo "$nix_system = $fetch $nix_src;" >> $bins
|
2021-09-22 15:38:15 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo '}' >> "$bins"
|
|
|
|
|
|
|
|
sed -i -r -e "s/version\s*?=\s*?.*?;/version = \"${version#v}\";/" "$dirname/default.nix"
|
2022-10-30 15:09:59 +00:00
|
|
|
sed -i -r -e "s/schema_version\s*?=\s*?.*?;/schema_version = ${schema_version};/" "$dirname/default.nix"
|