all: sync with master; upd chlog
This commit is contained in:
@@ -5,11 +5,12 @@ verbose="${VERBOSE:-0}"
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
debug_flags='-D'
|
||||
debug_flags='--debug=1'
|
||||
else
|
||||
set +x
|
||||
debug_flags=''
|
||||
debug_flags='--debug=0'
|
||||
fi
|
||||
readonly debug_flags
|
||||
|
||||
set -e -f -u
|
||||
|
||||
@@ -61,21 +62,22 @@ readonly docker_output
|
||||
case "$channel"
|
||||
in
|
||||
('release')
|
||||
docker_image_full_name="${docker_image_name}:${version}"
|
||||
docker_tags="--tag ${docker_image_name}:latest"
|
||||
docker_version_tag="--tag=${docker_image_name}:${version}"
|
||||
docker_channel_tag="--tag=${docker_image_name}:latest"
|
||||
;;
|
||||
('beta')
|
||||
docker_image_full_name="${docker_image_name}:${version}"
|
||||
docker_tags="--tag ${docker_image_name}:beta"
|
||||
docker_version_tag="--tag=${docker_image_name}:${version}"
|
||||
docker_channel_tag="--tag=${docker_image_name}:beta"
|
||||
;;
|
||||
('edge')
|
||||
# Don't set the version tag when pushing to the edge channel.
|
||||
docker_image_full_name="${docker_image_name}:edge"
|
||||
docker_tags=''
|
||||
# Set the version tag to an empty string when pushing to the edge channel.
|
||||
docker_version_tag=''
|
||||
docker_channel_tag="--tag=${docker_image_name}:edge"
|
||||
;;
|
||||
('development')
|
||||
docker_image_full_name="${docker_image_name}"
|
||||
docker_tags=''
|
||||
# Set both tags to an empty string for development builds.
|
||||
docker_version_tag=''
|
||||
docker_channel_tag=''
|
||||
;;
|
||||
(*)
|
||||
echo "invalid channel '$channel', supported values are\
|
||||
@@ -83,7 +85,7 @@ in
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
readonly docker_image_full_name docker_tags
|
||||
readonly docker_version_tag docker_channel_tag
|
||||
|
||||
# Copy the binaries into a new directory under new names, so that it's easier to
|
||||
# COPY them later. DO NOT remove the trailing underscores. See file
|
||||
@@ -117,10 +119,13 @@ cp "./docker/web-bind.awk"\
|
||||
cp "./docker/healthcheck.sh"\
|
||||
"${dist_docker_scripts}/healthcheck.sh"
|
||||
|
||||
# Don't use quotes with $docker_tags and $debug_flags because we want word
|
||||
# splitting and or an empty space if tags are empty.
|
||||
# Don't use quotes with $docker_version_tag and $docker_channel_tag, because we
|
||||
# want word splitting and or an empty space if tags are empty.
|
||||
#
|
||||
# TODO(a.garipov): Once flag --tag of docker buildx build supports commas, use
|
||||
# them instead.
|
||||
$sudo_cmd docker\
|
||||
$debug_flags\
|
||||
"$debug_flags"\
|
||||
buildx build\
|
||||
--build-arg BUILD_DATE="$build_date"\
|
||||
--build-arg DIST_DIR="$dist_dir"\
|
||||
@@ -128,7 +133,7 @@ $sudo_cmd docker\
|
||||
--build-arg VERSION="$version"\
|
||||
--output "$docker_output"\
|
||||
--platform "$docker_platforms"\
|
||||
$docker_tags\
|
||||
-t "$docker_image_full_name"\
|
||||
$docker_version_tag\
|
||||
$docker_channel_tag\
|
||||
-f ./docker/Dockerfile\
|
||||
.
|
||||
|
||||
@@ -78,14 +78,6 @@ else
|
||||
fi
|
||||
readonly oses
|
||||
|
||||
snap_enabled="${BUILD_SNAP:-1}"
|
||||
readonly snap_enabled
|
||||
|
||||
if [ "$snap_enabled" -eq '0' ]
|
||||
then
|
||||
log 'snap: disabled'
|
||||
fi
|
||||
|
||||
# Require the gpg key and passphrase to be set if the signing is required.
|
||||
if [ "$sign" -eq '1' ]
|
||||
then
|
||||
@@ -106,7 +98,7 @@ log "checking tools"
|
||||
# Make sure we fail gracefully if one of the tools we need is missing. Use
|
||||
# alternatives when available.
|
||||
use_shasum='0'
|
||||
for tool in gpg gzip sed sha256sum snapcraft tar zip
|
||||
for tool in gpg gzip sed sha256sum tar zip
|
||||
do
|
||||
if ! command -v "$tool" > /dev/null
|
||||
then
|
||||
@@ -128,36 +120,36 @@ readonly use_shasum
|
||||
# Data section. Arrange data into space-separated tables for read -r to read.
|
||||
# Use a hyphen for missing values.
|
||||
|
||||
# os arch arm mips snap
|
||||
# os arch arm mips
|
||||
platforms="\
|
||||
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 - - -"
|
||||
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 - -
|
||||
openbsd amd64 - -
|
||||
openbsd arm64 - -
|
||||
windows 386 - -
|
||||
windows amd64 - -
|
||||
windows arm64 - -"
|
||||
readonly platforms
|
||||
|
||||
# Function build builds the release for one platform. It builds a binary, an
|
||||
# archive and, if needed, a snap package.
|
||||
# Function build builds the release for one platform. It builds a binary and an
|
||||
# archive.
|
||||
build() {
|
||||
# Get the arguments. Here and below, use the "build_" prefix for all
|
||||
# variables local to function build.
|
||||
@@ -167,7 +159,6 @@ build() {
|
||||
build_arch="$4"\
|
||||
build_arm="$5"\
|
||||
build_mips="$6"\
|
||||
build_snap="$7"\
|
||||
;
|
||||
|
||||
# Use the ".exe" filename extension if we build a Windows release.
|
||||
@@ -229,52 +220,13 @@ build() {
|
||||
esac
|
||||
|
||||
log "$build_archive"
|
||||
|
||||
# Exit if we don't need to build the Snap package.
|
||||
if [ "$build_snap" = '-' ] || [ "$snap_enabled" -eq '0' ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
# Prepare the Snap build.
|
||||
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"
|
||||
cp "$build_output" './scripts/snap/local/adguard-home-web.sh' "$build_snap_dir"
|
||||
cp -r './scripts/snap/gui' "${build_snap_dir}/meta/"
|
||||
|
||||
# Create a snap.yaml file, setting the values.
|
||||
sed -e 's/%VERSION%/'"$version"'/'\
|
||||
-e 's/%ARCH%/'"$build_snap"'/'\
|
||||
./scripts/snap/snap.tmpl.yaml\
|
||||
>"${build_snap_dir}/meta/snap.yaml"
|
||||
|
||||
# TODO(a.garipov): The snapcraft tool will *always* write everything,
|
||||
# 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.
|
||||
set +e
|
||||
build_snapcraft_output="$(
|
||||
snapcraft pack "$build_snap_dir" --output "$build_snap_output" 2>&1
|
||||
)"
|
||||
build_snapcraft_exit_code="$?"
|
||||
set -e
|
||||
if [ "$build_snapcraft_exit_code" -ne '0' ]
|
||||
then
|
||||
log "$build_snapcraft_output"
|
||||
exit "$build_snapcraft_exit_code"
|
||||
fi
|
||||
|
||||
log "$build_snap_output"
|
||||
}
|
||||
|
||||
log "starting builds"
|
||||
|
||||
# Go over all platforms defined in the space-separated table above, tweak the
|
||||
# values where necessary, and feed to build.
|
||||
echo "$platforms" | while read -r os arch arm mips snap
|
||||
echo "$platforms" | while read -r os arch arm mips
|
||||
do
|
||||
# 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
|
||||
@@ -314,7 +266,7 @@ do
|
||||
;;
|
||||
esac
|
||||
|
||||
build "$dir" "$ar" "$os" "$arch" "$arm" "$mips" "$snap"
|
||||
build "$dir" "$ar" "$os" "$arch" "$arm" "$mips"
|
||||
done
|
||||
|
||||
log "packing frontend"
|
||||
@@ -413,14 +365,14 @@ do
|
||||
platform="$f"
|
||||
|
||||
# Remove the prefix.
|
||||
platform="${platform#./${dist}/AdGuardHome_}"
|
||||
platform="${platform#"./${dist}/AdGuardHome_"}"
|
||||
|
||||
# Remove the filename extensions.
|
||||
platform="${platform%.zip}"
|
||||
platform="${platform%.tar.gz}"
|
||||
|
||||
# Use the filename's base path.
|
||||
filename="${f#./${dist}/}"
|
||||
filename="${f#"./${dist}/"}"
|
||||
|
||||
if [ "$i" -eq "$ar_files_len" ]
|
||||
then
|
||||
|
||||
@@ -130,6 +130,7 @@ underscores() {
|
||||
-e '_freebsd.go'\
|
||||
-e '_linux.go'\
|
||||
-e '_little.go'\
|
||||
-e '_next.go'\
|
||||
-e '_openbsd.go'\
|
||||
-e '_others.go'\
|
||||
-e '_test.go'\
|
||||
@@ -169,6 +170,18 @@ run_linter govulncheck ./...
|
||||
|
||||
run_linter gocyclo --over 10 .
|
||||
|
||||
# TODO(a.garipov): Enable for all.
|
||||
run_linter gocognit --over 10\
|
||||
./internal/aghalg/\
|
||||
./internal/aghchan/\
|
||||
./internal/aghhttp/\
|
||||
./internal/aghio/\
|
||||
./internal/next/\
|
||||
./internal/tools/\
|
||||
./internal/version/\
|
||||
./internal/whois/\
|
||||
;
|
||||
|
||||
run_linter ineffassign ./...
|
||||
|
||||
run_linter unparam ./...
|
||||
@@ -185,8 +198,25 @@ run_linter nilness ./...
|
||||
|
||||
run_linter -e shadow --strict ./...
|
||||
|
||||
# TODO(a.garipov): Enable in v0.108.0.
|
||||
# run_linter gosec --quiet ./...
|
||||
# TODO(a.garipov): Enable for all.
|
||||
run_linter gosec --quiet\
|
||||
./internal/aghalg\
|
||||
./internal/aghchan\
|
||||
./internal/aghhttp\
|
||||
./internal/aghio\
|
||||
./internal/aghnet\
|
||||
./internal/aghos\
|
||||
./internal/aghtest\
|
||||
./internal/dhcpd\
|
||||
./internal/dhcpsvc\
|
||||
./internal/dnsforward\
|
||||
./internal/next\
|
||||
./internal/schedule\
|
||||
./internal/stats\
|
||||
./internal/tools\
|
||||
./internal/version\
|
||||
./internal/whois\
|
||||
;
|
||||
|
||||
# TODO(a.garipov): Enable --blank?
|
||||
run_linter errcheck --asserts ./...
|
||||
|
||||
@@ -38,6 +38,7 @@ readonly go
|
||||
rm -f\
|
||||
bin/errcheck\
|
||||
bin/fieldalignment\
|
||||
bin/gocognit\
|
||||
bin/gocyclo\
|
||||
bin/gofumpt\
|
||||
bin/gosec\
|
||||
@@ -69,6 +70,7 @@ env\
|
||||
github.com/kisielk/errcheck\
|
||||
github.com/kyoh86/looppointer/cmd/looppointer\
|
||||
github.com/securego/gosec/v2/cmd/gosec\
|
||||
github.com/uudashr/gocognit/cmd/gocognit\
|
||||
golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment\
|
||||
golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness\
|
||||
golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow\
|
||||
|
||||
Reference in New Issue
Block a user