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
|
2023-01-11 11:48:46 +00:00
|
|
|
# verbosity level greater than 0. Show the environment and every command that
|
|
|
|
# is run if the verbosity level is greater than 1. 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
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$verbose" -gt '1' ]; then
|
2020-12-30 15:26:25 +00:00
|
|
|
env
|
|
|
|
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() {
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$verbose" -gt '0' ]; then
|
2020-12-30 15:26:25 +00:00
|
|
|
# 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:-}"
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$version" = 'v0.0.0' ] || [ "$version" = '' ]; then
|
|
|
|
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.
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "${ARCH:-}" != '' ]; then
|
2021-03-10 17:12:18 +00:00
|
|
|
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
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "${OS:-}" != '' ]; then
|
2021-03-10 17:12:18 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
# Require the gpg key and passphrase to be set if the signing is required.
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$sign" -eq '1' ]; 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}"
|
2024-09-11 17:39:54 +01:00
|
|
|
signer_api_key="${SIGNER_API_KEY:?please set SIGNER_API_KEY or unset SIGN}"
|
|
|
|
deploy_script_path="${DEPLOY_SCRIPT_PATH:?please set DEPLOY_SCRIPT_PATH or unset SIGN}"
|
2021-05-19 18:31:20 +01:00
|
|
|
else
|
|
|
|
gpg_key_passphrase=''
|
|
|
|
gpg_key=''
|
2024-09-11 17:39:54 +01:00
|
|
|
signer_api_key=''
|
|
|
|
deploy_script_path=''
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
2024-09-11 17:39:54 +01:00
|
|
|
readonly gpg_key_passphrase gpg_key signer_api_key deploy_script_path
|
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'
|
2024-11-06 15:45:21 +00:00
|
|
|
for tool in gpg gzip sed sha256sum tar zip; do
|
|
|
|
if ! command -v "$tool" >/dev/null; then
|
|
|
|
if [ "$tool" = 'sha256sum' ] && command -v 'shasum' >/dev/null; 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
|
|
|
|
2023-06-21 15:14:10 +01:00
|
|
|
# os arch arm mips
|
2021-05-19 18:31:20 +01:00
|
|
|
platforms="\
|
2023-06-21 15:14:10 +01:00
|
|
|
darwin amd64 - -
|
|
|
|
darwin arm64 - -
|
|
|
|
freebsd 386 - -
|
|
|
|
freebsd amd64 - -
|
|
|
|
freebsd arm 5 -
|
|
|
|
freebsd arm 6 -
|
|
|
|
freebsd arm 7 -
|
|
|
|
freebsd arm64 - -
|
|
|
|
linux 386 - -
|
|
|
|
linux amd64 - -
|
|
|
|
linux arm 5 -
|
|
|
|
linux arm 6 -
|
|
|
|
linux arm 7 -
|
|
|
|
linux arm64 - -
|
|
|
|
linux mips - softfloat
|
|
|
|
linux mips64 - softfloat
|
|
|
|
linux mips64le - softfloat
|
|
|
|
linux mipsle - softfloat
|
|
|
|
linux ppc64le - -
|
2024-08-08 11:38:26 +01:00
|
|
|
linux riscv64 - -
|
2023-06-21 15:14:10 +01:00
|
|
|
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
|
|
|
|
2024-09-11 17:39:54 +01:00
|
|
|
# Function sign signs the specified build as intended by the target operating
|
|
|
|
# system.
|
|
|
|
sign() {
|
|
|
|
# Only sign if needed.
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$sign" -ne '1' ]; then
|
2024-09-11 17:39:54 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the arguments. Here and below, use the "sign_" prefix for all
|
|
|
|
# variables local to function sign.
|
|
|
|
sign_os="$1"
|
|
|
|
sign_bin_path="$2"
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$sign_os" != 'windows' ]; then
|
|
|
|
gpg \
|
|
|
|
--default-key "$gpg_key" \
|
|
|
|
--detach-sig \
|
|
|
|
--passphrase "$gpg_key_passphrase" \
|
|
|
|
--pinentry-mode loopback -q "$sign_bin_path" \
|
2024-09-11 17:39:54 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
return
|
2024-11-06 15:45:21 +00:00
|
|
|
elif [ "$channel" = 'beta' ] || [ "$channel" = 'release' ]; then
|
|
|
|
signed_bin_path="${sign_bin_path}.signed"
|
2024-09-11 17:39:54 +01:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
env INPUT_FILE="$sign_bin_path" \
|
|
|
|
OUTPUT_FILE="$signed_bin_path" \
|
|
|
|
SIGNER_API_KEY="$signer_api_key" \
|
|
|
|
"$deploy_script_path" sign-executable
|
2024-09-11 17:39:54 +01:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
mv "$signed_bin_path" "$sign_bin_path"
|
|
|
|
fi
|
2024-09-11 17:39:54 +01:00
|
|
|
}
|
|
|
|
|
2023-06-21 15:14:10 +01:00
|
|
|
# Function build builds the release for one platform. It builds a binary and an
|
|
|
|
# archive.
|
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.
|
2024-11-06 15:45:21 +00:00
|
|
|
build_dir="${dist}/${1}/AdGuardHome" \
|
|
|
|
build_ar="$2" \
|
|
|
|
build_os="$3" \
|
|
|
|
build_arch="$4" \
|
|
|
|
build_arm="$5" \
|
|
|
|
build_mips="$6" \
|
2020-12-30 15:26:25 +00:00
|
|
|
;
|
|
|
|
|
2021-05-19 18:31:20 +01:00
|
|
|
# Use the ".exe" filename extension if we build a Windows release.
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$build_os" = 'windows' ]; then
|
2020-12-30 15:26:25 +00:00
|
|
|
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.
|
2024-11-06 15:45:21 +00:00
|
|
|
env GOARCH="$build_arch" \
|
|
|
|
GOARM="${build_arm#-}" \
|
|
|
|
GOMIPS="${build_mips#-}" \
|
|
|
|
GOOS="$os" \
|
|
|
|
VERBOSE="$((verbose - 1))" \
|
|
|
|
VERSION="$version" \
|
|
|
|
OUT="$build_output" \
|
|
|
|
sh ./scripts/make/go-build.sh
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
log "$build_output"
|
|
|
|
|
2024-09-11 17:39:54 +01:00
|
|
|
sign "$os" "$build_output"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
# 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.
|
2024-11-06 15:45:21 +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.
|
2024-11-06 15:45:21 +00:00
|
|
|
(cd "${dist}/${1}" && zip -9 -q -r "../../${build_archive}" "./AdGuardHome")
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
*)
|
2020-12-30 15:26:25 +00:00
|
|
|
build_archive="./${dist}/${build_ar}.tar.gz"
|
2024-11-06 15:45:21 +00:00
|
|
|
tar -C "./${dist}/${1}" -c -f - "./AdGuardHome" | gzip -9 - >"$build_archive"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
log "$build_archive"
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2024-11-06 15:45:21 +00:00
|
|
|
echo "$platforms" | while read -r os arch arm mips; 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.
|
2024-11-06 15:45:21 +00:00
|
|
|
#
|
|
|
|
# shellcheck disable=SC2295
|
|
|
|
if [ "${arches##* $arch *}" != '' ]; then
|
2021-03-10 17:12:18 +00:00
|
|
|
log "$arch excluded, continuing"
|
|
|
|
|
|
|
|
continue
|
2024-11-06 15:45:21 +00:00
|
|
|
elif [ "${oses##* $os *}" != '' ]; then
|
2021-03-10 17:12:18 +00:00
|
|
|
log "$os excluded, continuing"
|
|
|
|
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
case "$arch" in
|
|
|
|
arm)
|
2020-12-30 15:26:25 +00:00
|
|
|
dir="AdGuardHome_${os}_${arch}_${arm}"
|
|
|
|
ar="AdGuardHome_${os}_${arch}v${arm}"
|
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
mips*)
|
2020-12-30 15:26:25 +00:00
|
|
|
dir="AdGuardHome_${os}_${arch}_${mips}"
|
|
|
|
ar="$dir"
|
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
*)
|
2020-12-30 15:26:25 +00:00
|
|
|
dir="AdGuardHome_${os}_${arch}"
|
|
|
|
ar="$dir"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-06-21 15:14:10 +01:00
|
|
|
build "$dir" "$ar" "$os" "$arch" "$arm" "$mips"
|
2020-12-30 15:26:25 +00:00
|
|
|
done
|
|
|
|
|
2021-05-04 14:07:59 +01:00
|
|
|
log "packing frontend"
|
|
|
|
|
|
|
|
build_archive="./${dist}/AdGuardHome_frontend.tar.gz"
|
2024-11-06 15:45:21 +00:00
|
|
|
tar -c -f - ./build | gzip -9 - >"$build_archive"
|
2021-05-04 14:07:59 +01:00
|
|
|
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() {
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$use_shasum" -eq '0' ]; then
|
2022-08-15 16:46:19 +01:00
|
|
|
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}"
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
: >./checksums.txt
|
2022-08-15 16:46:19 +01:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
for archive in ./*.zip ./*.tar.gz; do
|
2022-08-15 16:46:19 +01:00
|
|
|
# Make sure that we don't try to calculate a checksum for a glob pattern
|
|
|
|
# that matched no files.
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ ! -f "$archive" ]; then
|
2022-08-15 16:46:19 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
calculate_checksums "$archive" >>./checksums.txt
|
2022-08-15 16:46:19 +01:00
|
|
|
done
|
2020-12-30 15:26:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
log "writing versions"
|
|
|
|
|
2024-11-06 15:45:21 +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.
|
2024-11-06 15:45:21 +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\",
|
2024-11-06 15:45:21 +00:00
|
|
|
" >>"$version_json"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2023-02-27 14:07:31 +00:00
|
|
|
# Add the MIPS* object keys without the "softfloat" part to mitigate the
|
|
|
|
# consequences of #5373.
|
|
|
|
#
|
|
|
|
# TODO(a.garipov): Remove this around fall 2023.
|
|
|
|
echo "
|
|
|
|
\"download_linux_mips64\": \"${version_download_url}/AdGuardHome_linux_mips64_softfloat.tar.gz\",
|
|
|
|
\"download_linux_mips64le\": \"${version_download_url}/AdGuardHome_linux_mips64le_softfloat.tar.gz\",
|
|
|
|
\"download_linux_mipsle\": \"${version_download_url}/AdGuardHome_linux_mipsle_softfloat.tar.gz\",
|
2024-11-06 15:45:21 +00:00
|
|
|
" >>"$version_json"
|
2023-02-27 14:07:31 +00:00
|
|
|
|
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.
|
2024-11-06 15:45:21 +00:00
|
|
|
ar_files="$(find "./${dist}" ! -name "${dist}" -prune \( -name '*.tar.gz' -o -name '*.zip' \))"
|
|
|
|
ar_files_len="$(echo "$ar_files" | wc -l)"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly ar_files ar_files_len
|
2021-03-10 17:12:18 +00:00
|
|
|
|
|
|
|
i='1'
|
|
|
|
# Don't use quotes to get word splitting.
|
2024-11-06 15:45:21 +00:00
|
|
|
for f in $ar_files; do
|
2021-03-10 17:12:18 +00:00
|
|
|
platform="$f"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-03-10 17:12:18 +00:00
|
|
|
# Remove the prefix.
|
2023-06-21 15:14:10 +01:00
|
|
|
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.
|
2023-06-21 15:14:10 +01:00
|
|
|
filename="${f#"./${dist}/"}"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$i" -eq "$ar_files_len" ]; then
|
|
|
|
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"" >>"$version_json"
|
2021-03-10 17:12:18 +00:00
|
|
|
else
|
2024-11-06 15:45:21 +00:00
|
|
|
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >>"$version_json"
|
2021-03-10 17:12:18 +00:00
|
|
|
fi
|
2020-12-31 10:55:39 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
i="$((i + 1))"
|
2021-03-10 17:12:18 +00:00
|
|
|
done
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
echo '}' >>"$version_json"
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
log "finished"
|