Pull request: scripts: imp sh scripts

Updates #2275.

Squashed commit of the following:

commit 2c44e7f490eafcfb2798037f9e0b7e6f8af42b75
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri May 21 15:32:44 2021 +0300

    scripts: imp sh scripts
This commit is contained in:
Ainar Garipov 2021-05-21 15:40:44 +03:00
parent c6888326b0
commit 01a25323f8
4 changed files with 13 additions and 23 deletions

View File

@ -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

View File

@ -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'

View File

@ -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.

View File

@ -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