From 01a25323f8edd1296e1d8796851ff636326b8fe4 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Fri, 21 May 2021 15:40:44 +0300 Subject: [PATCH] Pull request: scripts: imp sh scripts Updates #2275. Squashed commit of the following: commit 2c44e7f490eafcfb2798037f9e0b7e6f8af42b75 Author: Ainar Garipov Date: Fri May 21 15:32:44 2021 +0300 scripts: imp sh scripts --- scripts/README.md | 4 ++-- scripts/install.sh | 5 ++++- scripts/make/build-release.sh | 24 +++++------------------- scripts/make/go-build.sh | 3 ++- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index d6ad3ada..e4e1e7f1 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -53,13 +53,13 @@ Optional environment: make ARCH='amd64 arm64' OS='darwin linux' … build-release ``` The default value is `''`, which means build everything. + * `BUILD_SNAP`: `0` to not build Snapcraft packages, `1` to build. The + default value is `1`. * `DIST_DIR`: the directory to build a release into. The default value is `dist`. * `GO`: set an alternarive name for the Go compiler. * `SIGN`: `0` to not sign the resulting packages, `1` to sign. The default value is `1`. - * `SNAP`: `0` to not build Snapcraft packages, `1` to build. The default - value is `1`. * `VERBOSE`: `1` to be verbose, `2` to also print environment. This script calls `go-build.sh` with the verbosity level one level lower, so to get verbosity level `2` in `go-build.sh`, set this to `3` when calling diff --git a/scripts/install.sh b/scripts/install.sh index 5876e8c4..92cb6162 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -255,7 +255,10 @@ fix_darwin() { return 0 fi - # TODO: Remove when Mac M1 native support is added. + # TODO(e.burkov): Remove after we release at least one stable release + # with Apple Silicon support. + # + # See https://github.com/AdguardTeam/AdGuardHome/issues/2443. if [ "$cpu" = 'arm64' ] then cpu='amd64' diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index 32289dc9..8b6668d9 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -39,7 +39,7 @@ log() { if [ "$verbose" -gt '0' ] then # Don't use quotes to get word splitting. - echo $@ 1>&2 + echo "$1" 1>&2 fi } @@ -83,7 +83,7 @@ else fi readonly oses -snap_enabled="${SNAP:-1}" +snap_enabled="${BUILD_SNAP:-1}" readonly snap_enabled if [ "$snap_enabled" -eq '0' ] @@ -106,12 +106,6 @@ readonly gpg_key_passphrase gpg_key dist="${DIST_DIR:-dist}" readonly dist -# Give users the ability to override the go command from environment. For -# example, to build two releases with two different Go versions and test the -# difference. -go="${GO:-go}" -readonly go - log "checking tools" # Make sure we fail gracefully if one of the tools we need is missing. Use @@ -119,9 +113,9 @@ log "checking tools" sha256sum_cmd='sha256sum' for tool in gpg gzip sed "$sha256sum_cmd" snapcraft tar zip do - if ! which "$tool" > /dev/null + if ! command -v "$tool" > /dev/null then - if [ "$tool" = "$sha256sum_cmd" ] && which 'shasum' > /dev/null + if [ "$tool" = "$sha256sum_cmd" ] && command -v 'shasum' > /dev/null then # macOS doesn't have sha256sum installed by default, but # it does have shasum. @@ -138,15 +132,7 @@ readonly sha256sum_cmd # Data section. Arrange data into space-separated tables for read -r to read. # Use 0 for missing values. - -arms='5 -6 -7' -readonly arms - -mipses='softfloat' -readonly mipses - +# # TODO(a.garipov): Remove armv6, because it was always overwritten by armv7. # Rename armv7 to armhf. Rename the 386 snap to i386. diff --git a/scripts/make/go-build.sh b/scripts/make/go-build.sh index d740611d..ecf572e1 100644 --- a/scripts/make/go-build.sh +++ b/scripts/make/go-build.sh @@ -35,7 +35,8 @@ readonly x_flags v_flags # expansion (-f), and consider undefined variables as errors (-u). set -e -f -u -# Allow users to set the Go version. +# Allow users to override the go command from environment. For example, to +# build two releases with two different Go versions and test the difference. go="${GO:-go}" readonly go