2020-12-30 15:26:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# AdGuard Home Release Script
|
|
|
|
#
|
2021-05-19 18:31:20 +01:00
|
|
|
# The commentary in this file is written with the assumption that the reader
|
|
|
|
# only has superficial knowledge of the POSIX shell language and alike.
|
|
|
|
# Experienced readers may find it overly verbose.
|
|
|
|
|
|
|
|
# The default verbosity level is 0. Show log messages if the caller requested
|
2022-02-01 17:00:32 +00:00
|
|
|
# verbosity level greater than 0. Show every command that is run if the
|
2021-05-19 18:31:20 +01:00
|
|
|
# verbosity level is greater than 1. Show the environment if the verbosity
|
|
|
|
# level is greater than 2. Otherwise, print nothing.
|
2020-12-30 15:26:25 +00:00
|
|
|
#
|
2021-05-19 18:31:20 +01:00
|
|
|
# The level of verbosity for the build script is the same minus one level. See
|
|
|
|
# below in build().
|
|
|
|
verbose="${VERBOSE:-0}"
|
|
|
|
readonly verbose
|
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
if [ "$verbose" -gt '2' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
|
|
|
env
|
|
|
|
set -x
|
2021-03-10 17:12:18 +00:00
|
|
|
elif [ "$verbose" -gt '1' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
# By default, sign the packages, but allow users to skip that step.
|
2021-05-19 18:31:20 +01:00
|
|
|
sign="${SIGN:-1}"
|
|
|
|
readonly sign
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
# Exit the script if a pipeline fails (-e), prevent accidental filename
|
|
|
|
# expansion (-f), and consider undefined variables as errors (-u).
|
|
|
|
set -e -f -u
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Function log is an echo wrapper that writes to stderr if the caller requested
|
|
|
|
# verbosity level greater than 0. Otherwise, it does nothing.
|
2020-12-30 15:26:25 +00:00
|
|
|
log() {
|
|
|
|
if [ "$verbose" -gt '0' ]
|
|
|
|
then
|
|
|
|
# Don't use quotes to get word splitting.
|
2021-05-21 13:40:44 +01:00
|
|
|
echo "$1" 1>&2
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
log 'starting to build AdGuard Home release'
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Require the channel to be set. Additional validation is performed later by
|
|
|
|
# go-build.sh.
|
2021-06-10 18:09:00 +01:00
|
|
|
channel="${CHANNEL:?please set CHANNEL}"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly channel
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Check VERSION against the default value from the Makefile. If it is that, use
|
|
|
|
# the version calculation script.
|
2021-05-24 19:46:33 +01:00
|
|
|
version="${VERSION:-}"
|
|
|
|
if [ "$version" = 'v0.0.0' ] || [ "$version" = '' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
2021-05-19 18:31:20 +01:00
|
|
|
version="$( sh ./scripts/make/version.sh )"
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly version
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
log "channel '$channel'"
|
|
|
|
log "version '$version'"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Check architecture and OS limiters. Add spaces to the local versions for
|
|
|
|
# better pattern matching.
|
2021-03-10 17:12:18 +00:00
|
|
|
if [ "${ARCH:-}" != '' ]
|
|
|
|
then
|
|
|
|
log "arches: '$ARCH'"
|
2021-05-19 18:31:20 +01:00
|
|
|
arches=" $ARCH "
|
2021-03-10 17:12:18 +00:00
|
|
|
else
|
2021-05-19 18:31:20 +01:00
|
|
|
arches=''
|
2021-03-10 17:12:18 +00:00
|
|
|
fi
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly arches
|
2021-03-10 17:12:18 +00:00
|
|
|
|
|
|
|
if [ "${OS:-}" != '' ]
|
|
|
|
then
|
|
|
|
log "oses: '$OS'"
|
2021-05-19 18:31:20 +01:00
|
|
|
oses=" $OS "
|
2021-03-10 17:12:18 +00:00
|
|
|
else
|
2021-05-19 18:31:20 +01:00
|
|
|
oses=''
|
2021-03-10 17:12:18 +00:00
|
|
|
fi
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly oses
|
|
|
|
|
2021-05-21 13:40:44 +01:00
|
|
|
snap_enabled="${BUILD_SNAP:-1}"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly snap_enabled
|
2021-03-10 17:12:18 +00:00
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
if [ "$snap_enabled" -eq '0' ]
|
2021-03-10 17:12:18 +00:00
|
|
|
then
|
|
|
|
log 'snap: disabled'
|
|
|
|
fi
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Require the gpg key and passphrase to be set if the signing is required.
|
|
|
|
if [ "$sign" -eq '1' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
2021-06-10 18:09:00 +01:00
|
|
|
gpg_key_passphrase="${GPG_KEY_PASSPHRASE:?please set GPG_KEY_PASSPHRASE or unset SIGN}"
|
|
|
|
gpg_key="${GPG_KEY:?please set GPG_KEY or unset SIGN}"
|
2021-05-19 18:31:20 +01:00
|
|
|
else
|
|
|
|
gpg_key_passphrase=''
|
|
|
|
gpg_key=''
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly gpg_key_passphrase gpg_key
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
# The default distribution files directory is dist.
|
2021-05-19 18:31:20 +01:00
|
|
|
dist="${DIST_DIR:-dist}"
|
|
|
|
readonly dist
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
log "checking tools"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Make sure we fail gracefully if one of the tools we need is missing. Use
|
|
|
|
# alternatives when available.
|
2022-08-15 16:46:19 +01:00
|
|
|
use_shasum='0'
|
|
|
|
for tool in gpg gzip sed sha256sum snapcraft tar zip
|
2020-12-30 15:26:25 +00:00
|
|
|
do
|
2021-05-21 13:40:44 +01:00
|
|
|
if ! command -v "$tool" > /dev/null
|
2021-05-19 18:31:20 +01:00
|
|
|
then
|
2022-08-15 16:46:19 +01:00
|
|
|
if [ "$tool" = 'sha256sum' ] && command -v 'shasum' > /dev/null
|
2021-05-19 18:31:20 +01:00
|
|
|
then
|
2022-08-15 16:46:19 +01:00
|
|
|
# macOS doesn't have sha256sum installed by default, but it does
|
|
|
|
# have shasum.
|
2021-05-19 18:31:20 +01:00
|
|
|
log 'replacing sha256sum with shasum -a 256'
|
2022-08-15 16:46:19 +01:00
|
|
|
use_shasum='1'
|
2021-05-19 18:31:20 +01:00
|
|
|
else
|
|
|
|
log "pieces don't fit, '$tool' not found"
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2020-12-30 15:26:25 +00:00
|
|
|
done
|
2022-08-15 16:46:19 +01:00
|
|
|
readonly use_shasum
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Data section. Arrange data into space-separated tables for read -r to read.
|
2022-02-09 18:21:34 +00:00
|
|
|
# Use a hyphen for missing values.
|
2020-12-30 20:18:15 +00:00
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
# os arch arm mips snap
|
2021-05-19 18:31:20 +01:00
|
|
|
platforms="\
|
2022-02-09 18:21:34 +00:00
|
|
|
darwin amd64 - - -
|
|
|
|
darwin arm64 - - -
|
|
|
|
freebsd 386 - - -
|
|
|
|
freebsd amd64 - - -
|
|
|
|
freebsd arm 5 - -
|
|
|
|
freebsd arm 6 - -
|
|
|
|
freebsd arm 7 - -
|
|
|
|
freebsd arm64 - - -
|
|
|
|
linux 386 - - i386
|
|
|
|
linux amd64 - - amd64
|
|
|
|
linux arm 5 - -
|
|
|
|
linux arm 6 - -
|
|
|
|
linux arm 7 - armhf
|
|
|
|
linux arm64 - - arm64
|
|
|
|
linux mips - softfloat -
|
|
|
|
linux mips64 - softfloat -
|
|
|
|
linux mips64le - softfloat -
|
|
|
|
linux mipsle - softfloat -
|
|
|
|
linux ppc64le - - -
|
|
|
|
openbsd amd64 - - -
|
|
|
|
openbsd arm64 - - -
|
|
|
|
windows 386 - - -
|
|
|
|
windows amd64 - - -
|
|
|
|
windows arm64 - - -"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly platforms
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Function build builds the release for one platform. It builds a binary, an
|
|
|
|
# archive and, if needed, a snap package.
|
2020-12-30 15:26:25 +00:00
|
|
|
build() {
|
2021-05-19 18:31:20 +01:00
|
|
|
# Get the arguments. Here and below, use the "build_" prefix for all
|
|
|
|
# variables local to function build.
|
2020-12-30 15:26:25 +00:00
|
|
|
build_dir="${dist}/${1}/AdGuardHome"\
|
|
|
|
build_ar="$2"\
|
|
|
|
build_os="$3"\
|
|
|
|
build_arch="$4"\
|
|
|
|
build_arm="$5"\
|
|
|
|
build_mips="$6"\
|
|
|
|
build_snap="$7"\
|
|
|
|
;
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Use the ".exe" filename extension if we build a Windows release.
|
2020-12-30 15:26:25 +00:00
|
|
|
if [ "$build_os" = 'windows' ]
|
|
|
|
then
|
|
|
|
build_output="./${build_dir}/AdGuardHome.exe"
|
|
|
|
else
|
|
|
|
build_output="./${build_dir}/AdGuardHome"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "./${build_dir}"
|
|
|
|
|
|
|
|
# Build the binary.
|
|
|
|
#
|
2022-02-09 18:21:34 +00:00
|
|
|
# Set GOARM and GOMIPS to an empty string if $build_arm and $build_mips are
|
|
|
|
# the zero value by removing the hyphen as if it's a prefix.
|
2020-12-30 15:26:25 +00:00
|
|
|
#
|
2021-05-19 18:31:20 +01:00
|
|
|
# Don't use quotes with $build_par because we want an empty space if
|
|
|
|
# parallelism wasn't set.
|
2020-12-30 15:26:25 +00:00
|
|
|
env\
|
|
|
|
GOARCH="$build_arch"\
|
2022-02-09 18:21:34 +00:00
|
|
|
GOARM="${build_arm#-}"\
|
|
|
|
GOMIPS="${build_mips#-}"\
|
2020-12-30 15:26:25 +00:00
|
|
|
GOOS="$os"\
|
|
|
|
VERBOSE="$(( verbose - 1 ))"\
|
2020-12-31 10:55:39 +00:00
|
|
|
VERSION="$version"\
|
2020-12-30 15:26:25 +00:00
|
|
|
OUT="$build_output"\
|
|
|
|
sh ./scripts/make/go-build.sh\
|
|
|
|
;
|
|
|
|
|
|
|
|
log "$build_output"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
if [ "$sign" -eq '1' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
|
|
|
gpg\
|
|
|
|
--default-key "$gpg_key"\
|
|
|
|
--detach-sig\
|
|
|
|
--passphrase "$gpg_key_passphrase"\
|
|
|
|
--pinentry-mode loopback\
|
|
|
|
-q\
|
|
|
|
"$build_output"\
|
|
|
|
;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Prepare the build directory for archiving.
|
|
|
|
cp ./CHANGELOG.md ./LICENSE.txt ./README.md "$build_dir"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Make archives. Windows and macOS prefer ZIP archives; the rest,
|
|
|
|
# gzipped tarballs.
|
2020-12-30 15:26:25 +00:00
|
|
|
case "$build_os"
|
|
|
|
in
|
|
|
|
('darwin'|'windows')
|
2021-05-04 14:07:59 +01:00
|
|
|
build_archive="./${dist}/${build_ar}.zip"
|
2022-02-09 18:21:34 +00:00
|
|
|
# TODO(a.garipov): Find an option similar to the -C option of tar for
|
|
|
|
# zip.
|
2021-05-04 14:07:59 +01:00
|
|
|
( cd "${dist}/${1}" && zip -9 -q -r "../../${build_archive}" "./AdGuardHome" )
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
build_archive="./${dist}/${build_ar}.tar.gz"
|
2021-05-04 14:07:59 +01:00
|
|
|
tar -C "./${dist}/${1}" -c -f - "./AdGuardHome" | gzip -9 - > "$build_archive"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
log "$build_archive"
|
|
|
|
|
2022-02-09 18:21:34 +00:00
|
|
|
# Exit if we don't need to build the Snap package.
|
|
|
|
if [ "$build_snap" = '-' ] || [ "$snap_enabled" -eq '0' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2022-02-09 18:21:34 +00:00
|
|
|
# Prepare the Snap build.
|
2020-12-30 15:26:25 +00:00
|
|
|
build_snap_output="./${dist}/AdGuardHome_${build_snap}.snap"
|
|
|
|
build_snap_dir="${build_snap_output}.dir"
|
|
|
|
|
|
|
|
# Create the meta subdirectory and copy files there.
|
|
|
|
mkdir -p "${build_snap_dir}/meta"
|
2022-02-09 18:21:34 +00:00
|
|
|
cp "$build_output" './scripts/snap/local/adguard-home-web.sh' "$build_snap_dir"
|
|
|
|
cp -r './scripts/snap/gui' "${build_snap_dir}/meta/"
|
2020-12-30 20:18:15 +00:00
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
# Create a snap.yaml file, setting the values.
|
|
|
|
sed -e 's/%VERSION%/'"$version"'/'\
|
2022-02-09 18:21:34 +00:00
|
|
|
-e 's/%ARCH%/'"$build_snap"'/'\
|
2020-12-30 15:26:25 +00:00
|
|
|
./scripts/snap/snap.tmpl.yaml\
|
|
|
|
>"${build_snap_dir}/meta/snap.yaml"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# TODO(a.garipov): The snapcraft tool will *always* write everything,
|
2022-02-09 18:21:34 +00:00
|
|
|
# including errors, to stdout. And there doesn't seem to be a way to change
|
|
|
|
# that. So, save the combined output, but only show it when snapcraft
|
|
|
|
# actually fails.
|
2020-12-30 15:26:25 +00:00
|
|
|
set +e
|
|
|
|
build_snapcraft_output="$(
|
2021-04-09 13:07:18 +01:00
|
|
|
snapcraft pack "$build_snap_dir" --output "$build_snap_output" 2>&1
|
2020-12-30 15:26:25 +00:00
|
|
|
)"
|
|
|
|
build_snapcraft_exit_code="$?"
|
|
|
|
set -e
|
2022-02-09 18:21:34 +00:00
|
|
|
if [ "$build_snapcraft_exit_code" -ne '0' ]
|
2020-12-30 15:26:25 +00:00
|
|
|
then
|
|
|
|
log "$build_snapcraft_output"
|
|
|
|
exit "$build_snapcraft_exit_code"
|
|
|
|
fi
|
|
|
|
|
|
|
|
log "$build_snap_output"
|
|
|
|
}
|
|
|
|
|
|
|
|
log "starting builds"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Go over all platforms defined in the space-separated table above, tweak the
|
|
|
|
# values where necessary, and feed to build.
|
2020-12-30 15:26:25 +00:00
|
|
|
echo "$platforms" | while read -r os arch arm mips snap
|
|
|
|
do
|
2021-05-19 18:31:20 +01:00
|
|
|
# See if the architecture or the OS is in the allowlist. To do so, try
|
|
|
|
# removing everything that matches the pattern (well, a prefix, but that
|
|
|
|
# doesn't matter here) containing the arch or the OS.
|
2021-03-10 17:12:18 +00:00
|
|
|
#
|
2021-05-19 18:31:20 +01:00
|
|
|
# For example, when $arches is " amd64 arm64 " and $arch is "amd64",
|
|
|
|
# then the pattern to remove is "* amd64 *", so the whole string becomes
|
|
|
|
# empty. On the other hand, if $arch is "windows", then the pattern is
|
|
|
|
# "* windows *", which doesn't match, so nothing is removed.
|
2021-03-10 17:12:18 +00:00
|
|
|
#
|
|
|
|
# See https://stackoverflow.com/a/43912605/1892060.
|
|
|
|
if [ "${arches##* $arch *}" != '' ]
|
|
|
|
then
|
|
|
|
log "$arch excluded, continuing"
|
|
|
|
|
|
|
|
continue
|
|
|
|
elif [ "${oses##* $os *}" != '' ]
|
|
|
|
then
|
|
|
|
log "$os excluded, continuing"
|
|
|
|
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
case "$arch"
|
|
|
|
in
|
|
|
|
(arm)
|
|
|
|
dir="AdGuardHome_${os}_${arch}_${arm}"
|
|
|
|
ar="AdGuardHome_${os}_${arch}v${arm}"
|
|
|
|
;;
|
|
|
|
(mips*)
|
|
|
|
dir="AdGuardHome_${os}_${arch}_${mips}"
|
|
|
|
ar="$dir"
|
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
dir="AdGuardHome_${os}_${arch}"
|
|
|
|
ar="$dir"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
build "$dir" "$ar" "$os" "$arch" "$arm" "$mips" "$snap"
|
|
|
|
done
|
|
|
|
|
2021-05-04 14:07:59 +01:00
|
|
|
log "packing frontend"
|
|
|
|
|
|
|
|
build_archive="./${dist}/AdGuardHome_frontend.tar.gz"
|
|
|
|
tar -c -f - ./build ./build2 | gzip -9 - > "$build_archive"
|
|
|
|
log "$build_archive"
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
log "calculating checksums"
|
|
|
|
|
2022-08-15 16:46:19 +01:00
|
|
|
# calculate_checksums uses the previously detected SHA-256 tool to calculate
|
|
|
|
# checksums. Do not use find with -exec, since shasum requires arguments.
|
|
|
|
calculate_checksums() {
|
|
|
|
if [ "$use_shasum" -eq '0' ]
|
|
|
|
then
|
|
|
|
sha256sum "$@"
|
|
|
|
else
|
|
|
|
shasum -a 256 "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Calculate the checksums of the files in a subshell with a different working
|
|
|
|
# directory. Don't use ls, because files matching one of the patterns may be
|
|
|
|
# absent, which will make ls return with a non-zero status code.
|
2022-08-15 16:46:19 +01:00
|
|
|
#
|
|
|
|
# TODO(a.garipov): Consider calculating these as the build goes.
|
2020-12-30 15:26:25 +00:00
|
|
|
(
|
2022-08-15 16:46:19 +01:00
|
|
|
set +f
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
cd "./${dist}"
|
|
|
|
|
2022-08-15 16:46:19 +01:00
|
|
|
: > ./checksums.txt
|
|
|
|
|
|
|
|
for archive in ./*.zip ./*.tar.gz
|
|
|
|
do
|
|
|
|
# Make sure that we don't try to calculate a checksum for a glob pattern
|
|
|
|
# that matched no files.
|
|
|
|
if [ ! -f "$archive" ]
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
calculate_checksums "$archive" >> ./checksums.txt
|
|
|
|
done
|
2020-12-30 15:26:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
log "writing versions"
|
|
|
|
|
2021-02-02 15:31:47 +00:00
|
|
|
echo "version=$version" > "./${dist}/version.txt"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2022-02-01 17:00:32 +00:00
|
|
|
# Create the version.json file.
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2022-07-28 18:18:07 +01:00
|
|
|
version_download_url="https://static.adtidy.org/adguardhome/${channel}"
|
2021-05-19 18:31:20 +01:00
|
|
|
version_json="./${dist}/version.json"
|
|
|
|
readonly version_download_url version_json
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2022-02-01 17:00:32 +00:00
|
|
|
# If the channel is edge, point users to the "Platforms" page on the Wiki,
|
|
|
|
# because the direct links to the edge packages are listed there.
|
2020-12-30 15:26:25 +00:00
|
|
|
if [ "$channel" = 'edge' ]
|
|
|
|
then
|
2022-02-01 17:00:32 +00:00
|
|
|
announcement_url='https://github.com/AdguardTeam/AdGuardHome/wiki/Platforms'
|
2020-12-30 15:26:25 +00:00
|
|
|
else
|
2022-02-01 16:42:07 +00:00
|
|
|
announcement_url="https://github.com/AdguardTeam/AdGuardHome/releases/tag/${version}"
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
2022-02-01 16:42:07 +00:00
|
|
|
readonly announcement_url
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2022-06-09 15:47:05 +01:00
|
|
|
# TODO(a.garipov): Remove "selfupdate_min_version" in future versions.
|
2020-12-30 15:26:25 +00:00
|
|
|
rm -f "$version_json"
|
|
|
|
echo "{
|
|
|
|
\"version\": \"${version}\",
|
|
|
|
\"announcement\": \"AdGuard Home ${version} is now available!\",
|
2022-02-01 16:42:07 +00:00
|
|
|
\"announcement_url\": \"${announcement_url}\",
|
2020-12-30 15:26:25 +00:00
|
|
|
\"selfupdate_min_version\": \"0.0\",
|
|
|
|
" >> "$version_json"
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Same as with checksums above, don't use ls, because files matching one of the
|
|
|
|
# patterns may be absent.
|
|
|
|
ar_files="$( find "./${dist}/" ! -name "${dist}" -prune \( -name '*.tar.gz' -o -name '*.zip' \) )"
|
|
|
|
ar_files_len="$( echo "$ar_files" | wc -l )"
|
|
|
|
readonly ar_files ar_files_len
|
2021-03-10 17:12:18 +00:00
|
|
|
|
|
|
|
i='1'
|
|
|
|
# Don't use quotes to get word splitting.
|
|
|
|
for f in $ar_files
|
|
|
|
do
|
|
|
|
platform="$f"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
# Remove the prefix.
|
|
|
|
platform="${platform#./${dist}/AdGuardHome_}"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
# Remove the filename extensions.
|
|
|
|
platform="${platform%.zip}"
|
|
|
|
platform="${platform%.tar.gz}"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
# Use the filename's base path.
|
|
|
|
filename="${f#./${dist}/}"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
if [ "$i" -eq "$ar_files_len" ]
|
2021-03-10 17:12:18 +00:00
|
|
|
then
|
|
|
|
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"" >> "$version_json"
|
|
|
|
else
|
|
|
|
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >> "$version_json"
|
|
|
|
fi
|
2020-12-31 10:55:39 +00:00
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
i="$(( i + 1 ))"
|
|
|
|
done
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
echo '}' >> "$version_json"
|
|
|
|
|
|
|
|
log "finished"
|