Pull request: scripts: imp all

Merge in DNS/adguard-home from imp-sh to master

Squashed commit of the following:

commit d574deae73e5c07e1e9ef43152de8d86b276c623
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Jun 10 20:00:56 2021 +0300

    scripts: imp all
This commit is contained in:
Ainar Garipov 2021-06-10 20:09:00 +03:00
parent 89694763f5
commit e0d89ba267
6 changed files with 44 additions and 59 deletions

View File

@ -14,9 +14,9 @@ fi
set -e -f -u
# Require these to be set. The channel value is validated later.
channel="$CHANNEL"
commit="$COMMIT"
dist_dir="$DIST_DIR"
channel="${CHANNEL:?please set CHANNEL}"
commit="${COMMIT:?please set COMMIT}"
dist_dir="${DIST_DIR:?please set DIST_DIR}"
readonly channel commit dist_dir
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]

View File

@ -47,7 +47,7 @@ log 'starting to build AdGuard Home release'
# Require the channel to be set. Additional validation is performed later by
# go-build.sh.
channel="$CHANNEL"
channel="${CHANNEL:?please set CHANNEL}"
readonly channel
# Check VERSION against the default value from the Makefile. If it is that, use
@ -93,8 +93,8 @@ fi
# Require the gpg key and passphrase to be set if the signing is required.
if [ "$sign" -eq '1' ]
then
gpg_key_passphrase="$GPG_KEY_PASSPHRASE"
gpg_key="$GPG_KEY"
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}"
else
gpg_key_passphrase=''
gpg_key=''
@ -360,10 +360,9 @@ log "calculating checksums"
(
cd "./${dist}"
files="$( find . ! -name . -prune \( -name '*.tar.gz' -o -name '*.zip' \) )"
# Don't use quotes to get word splitting.
$sha256sum_cmd $files > ./checksums.txt
find . ! -name . -prune \( -name '*.tar.gz' -o -name '*.zip' \)\
-exec "$sha256sum_cmd" {} +\
> ./checksums.txt
)
log "writing versions"

View File

@ -10,7 +10,7 @@ fi
set -e -f -u
dist_dir="$DIST_DIR"
dist_dir="${DIST_DIR:?please set DIST_DIR}"
sudo_cmd="${SUDO:-}"
readonly dist_dir sudo_cmd

View File

@ -17,17 +17,17 @@ if [ "$verbose" -gt '1' ]
then
env
set -x
v_flags='-v'
x_flags='-x'
v_flags='-v=1'
x_flags='-x=1'
elif [ "$verbose" -gt '0' ]
then
set -x
v_flags='-v'
x_flags=''
v_flags='-v=1'
x_flags='-x=0'
else
set +x
v_flags=''
x_flags=''
v_flags='-v=0'
x_flags='-x=0'
fi
readonly x_flags v_flags
@ -41,7 +41,7 @@ go="${GO:-go}"
readonly go
# Require the channel to be set and validate the value.
channel="$CHANNEL"
channel="${CHANNEL:?please set CHANNEL}"
readonly channel
case "$channel"
@ -88,38 +88,28 @@ then
fi
# Allow users to limit the build's parallelism.
parallelism="${PARALLELISM:-}"
parallelism="${PARALLELISM:-0}"
readonly parallelism
if [ "${parallelism}" != '' ]
then
par_flags="-p ${parallelism}"
else
par_flags=''
fi
readonly par_flags
p_flags="-p=${parallelism}"
readonly p_flags
# Allow users to specify a different output name.
out="${OUT:-}"
out="${OUT:-AdGuardHome}"
readonly out
if [ "$out" != '' ]
then
out_flags="-o ${out}"
else
out_flags=''
fi
readonly out_flags
o_flags="-o=${out}"
readonly o_flags
# Allow users to enable the race detector. Unfortunately, that means that cgo
# must be enabled.
if [ "${RACE:-0}" -eq '0' ]
then
cgo_enabled='0'
race_flags=''
race_flags='--race=0'
else
cgo_enabled='1'
race_flags='--race'
race_flags='--race=1'
fi
readonly cgo_enabled race_flags
@ -127,11 +117,6 @@ CGO_ENABLED="$cgo_enabled"
GO111MODULE='on'
export CGO_ENABLED GO111MODULE
build_flags="${BUILD_FLAGS:-$race_flags --trimpath $out_flags $par_flags $v_flags $x_flags}"
readonly build_flags
# Don't use quotes with flag variables to get word splitting.
"$go" generate $v_flags $x_flags ./main.go
# Don't use quotes with flag variables to get word splitting.
"$go" build --ldflags "$ldflags" $build_flags
"$go" build --ldflags "$ldflags" "$race_flags" --trimpath "$o_flags" "$p_flags" "$v_flags"\
"$x_flags"

View File

@ -10,17 +10,17 @@ readonly verbose
if [ "$verbose" -gt '1' ]
then
set -x
v_flags='-v'
x_flags='-x'
v_flags='-v=1'
x_flags='-x=1'
elif [ "$verbose" -gt '0' ]
then
set -x
v_flags='-v'
x_flags=''
v_flags='-v=1'
x_flags='-x=0'
else
set +x
v_flags=''
x_flags=''
v_flags='-v=0'
x_flags='-x=0'
fi
readonly v_flags x_flags
@ -28,18 +28,17 @@ set -e -f -u
if [ "${RACE:-1}" -eq '0' ]
then
race_flags=''
race_flags='--race=0'
else
race_flags='--race'
race_flags='--race=1'
fi
readonly race_flags
go="${GO:-go}"
timeout_flags="${TIMEOUT_FLAGS:---timeout 30s}"
cover_flags='--coverprofile ./coverage.txt'
count_flags='--count 1'
count_flags='--count=1'
cover_flags='--coverprofile=./coverage.txt'
timeout_flags="${TIMEOUT_FLAGS:---timeout=30s}"
readonly go timeout_flags cover_flags count_flags
# Don't use quotes with flag variables because we want an empty space if those
# aren't set.
"$go" test $count_flags $cover_flags $race_flags $timeout_flags $x_flags $v_flags ./...
"$go" test "$count_flags" "$cover_flags" "$race_flags" "$timeout_flags" "$x_flags" "$v_flags" ./...

View File

@ -34,6 +34,8 @@ set -e -f -u
# bump_minor is an awk program that reads a minor release version, increments
# the minor part of it, and prints the next version.
#
# shellcheck disable=SC2016
bump_minor='/^v[0-9]+\.[0-9]+\.0$/ {
print($1 "." $2 + 1 ".0");
@ -66,7 +68,7 @@ get_last_minor_zero() {
| head -n 1
}
channel="$CHANNEL"
channel="${CHANNEL:?please set CHANNEL}"
readonly channel
case "$channel"
@ -86,7 +88,7 @@ in
num_commits_since_minor="$( git rev-list "${last_minor_zero}..HEAD" | wc -l )"
# The output of darwin's implementation of wc needs to be trimmed from
# redundant spaces.
num_commits_since_minor="$( echo ${num_commits_since_minor} | tr -d '[:space:]' )"
num_commits_since_minor="$( echo "$num_commits_since_minor" | tr -d '[:space:]' )"
readonly num_commits_since_minor
# next_minor is the next minor release version.