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

View File

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

View File

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

View File

@ -10,17 +10,17 @@ readonly verbose
if [ "$verbose" -gt '1' ] if [ "$verbose" -gt '1' ]
then then
set -x set -x
v_flags='-v' v_flags='-v=1'
x_flags='-x' x_flags='-x=1'
elif [ "$verbose" -gt '0' ] elif [ "$verbose" -gt '0' ]
then then
set -x set -x
v_flags='-v' v_flags='-v=1'
x_flags='' x_flags='-x=0'
else else
set +x set +x
v_flags='' v_flags='-v=0'
x_flags='' x_flags='-x=0'
fi fi
readonly v_flags x_flags readonly v_flags x_flags
@ -28,18 +28,17 @@ set -e -f -u
if [ "${RACE:-1}" -eq '0' ] if [ "${RACE:-1}" -eq '0' ]
then then
race_flags='' race_flags='--race=0'
else else
race_flags='--race' race_flags='--race=1'
fi fi
readonly race_flags readonly race_flags
go="${GO:-go}" 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 readonly go timeout_flags cover_flags count_flags
# Don't use quotes with flag variables because we want an empty space if those "$go" test "$count_flags" "$cover_flags" "$race_flags" "$timeout_flags" "$x_flags" "$v_flags" ./...
# aren't set.
"$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 # bump_minor is an awk program that reads a minor release version, increments
# the minor part of it, and prints the next version. # the minor part of it, and prints the next version.
#
# shellcheck disable=SC2016
bump_minor='/^v[0-9]+\.[0-9]+\.0$/ { bump_minor='/^v[0-9]+\.[0-9]+\.0$/ {
print($1 "." $2 + 1 ".0"); print($1 "." $2 + 1 ".0");
@ -66,7 +68,7 @@ get_last_minor_zero() {
| head -n 1 | head -n 1
} }
channel="$CHANNEL" channel="${CHANNEL:?please set CHANNEL}"
readonly channel readonly channel
case "$channel" case "$channel"
@ -86,7 +88,7 @@ in
num_commits_since_minor="$( git rev-list "${last_minor_zero}..HEAD" | wc -l )" 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 # The output of darwin's implementation of wc needs to be trimmed from
# redundant spaces. # 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 readonly num_commits_since_minor
# next_minor is the next minor release version. # next_minor is the next minor release version.