Pull request: scripts: add more control to build-release, imp docs
Updates #2608. Squashed commit of the following: commit 59f68f2da22c111a73660a6b799e0429b79f743d Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Feb 2 15:49:54 2021 +0300 scripts: add more control to build-release, imp docs
This commit is contained in:
parent
2d7042425e
commit
6de54b3b99
|
@ -46,11 +46,20 @@ Required environment:
|
||||||
is `1`.
|
is `1`.
|
||||||
|
|
||||||
Optional environment:
|
Optional environment:
|
||||||
|
* `ARCH` and `OS`: space-separated list of architectures and operating systems
|
||||||
|
for which to build a release. For example, to build only for 64-bit ARM and
|
||||||
|
AMD on Linux and Darwin:
|
||||||
|
```sh
|
||||||
|
make ARCH='amd64 arm64' OS='darwin linux' … build-release
|
||||||
|
```
|
||||||
|
The default value is `''`, which means build everything.
|
||||||
* `DIST_DIR`: the directory to build a release into. The default value is
|
* `DIST_DIR`: the directory to build a release into. The default value is
|
||||||
`dist`.
|
`dist`.
|
||||||
* `GO`: set an alternarive name for the Go compiler.
|
* `GO`: set an alternarive name for the Go compiler.
|
||||||
* `SIGN`: `0` to not sign the resulting packages, `1` to sign. The default
|
* `SIGN`: `0` to not sign the resulting packages, `1` to sign. The default
|
||||||
value is `1`.
|
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
|
* `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
|
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
|
verbosity level `2` in `go-build.sh`, set this to `3` when calling
|
||||||
|
|
|
@ -6,19 +6,19 @@
|
||||||
# reader only has superficial knowledge of the POSIX shell language and
|
# reader only has superficial knowledge of the POSIX shell language and
|
||||||
# alike. Experienced readers may find it overly verbose.
|
# alike. Experienced readers may find it overly verbose.
|
||||||
|
|
||||||
# The default verbosity level is 0. Show every command that is run if
|
# The default verbosity level is 0. Show log messages if the caller
|
||||||
# the caller requested verbosity level greater than 0. Show the
|
# requested verbosity level greather than 0. Show every command that is
|
||||||
# environment if the callre requested verbosity level greater than 1.
|
# run if the verbosity level is greater than 1. Show the environment if
|
||||||
# Otherwise, print nothing.
|
# the verbosity level is greater than 2. Otherwise, print nothing.
|
||||||
#
|
#
|
||||||
# The level of verbosity for the build script is the same minus one
|
# The level of verbosity for the build script is the same minus one
|
||||||
# level. See below in build().
|
# level. See below in build().
|
||||||
readonly verbose="${VERBOSE:-0}"
|
readonly verbose="${VERBOSE:-0}"
|
||||||
if [ "$verbose" -gt '1' ]
|
if [ "$verbose" -gt '2' ]
|
||||||
then
|
then
|
||||||
env
|
env
|
||||||
set -x
|
set -x
|
||||||
elif [ "$verbose" -gt '0' ]
|
elif [ "$verbose" -gt '1' ]
|
||||||
then
|
then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
@ -58,6 +58,30 @@ fi
|
||||||
log "channel '$channel'"
|
log "channel '$channel'"
|
||||||
log "version '$version'"
|
log "version '$version'"
|
||||||
|
|
||||||
|
# Check architecture and OS limiters. Add spaces to the local versions
|
||||||
|
# for better pattern matching.
|
||||||
|
if [ "${ARCH:-}" != '' ]
|
||||||
|
then
|
||||||
|
log "arches: '$ARCH'"
|
||||||
|
readonly arches=" $ARCH "
|
||||||
|
else
|
||||||
|
readonly arches=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${OS:-}" != '' ]
|
||||||
|
then
|
||||||
|
log "oses: '$OS'"
|
||||||
|
readonly oses=" $OS "
|
||||||
|
else
|
||||||
|
readonly oses=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly snap_enabled="${SNAP:-1}"
|
||||||
|
if [ "$snap_enabled" = '0' ]
|
||||||
|
then
|
||||||
|
log 'snap: disabled'
|
||||||
|
fi
|
||||||
|
|
||||||
# Require the gpg key and passphrase to be set if the signing is
|
# Require the gpg key and passphrase to be set if the signing is
|
||||||
# required.
|
# required.
|
||||||
if [ "$sign" = '1' ]
|
if [ "$sign" = '1' ]
|
||||||
|
@ -196,7 +220,7 @@ build() {
|
||||||
|
|
||||||
log "$build_archive"
|
log "$build_archive"
|
||||||
|
|
||||||
if [ "$build_snap" = '0' ]
|
if [ "$build_snap" = '0' -o "$snap_enabled" = '0' ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -259,6 +283,30 @@ log "starting builds"
|
||||||
# tweak the values where necessary, and feed to build.
|
# 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 snap
|
||||||
do
|
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 doesn't matter here) containing the arch or
|
||||||
|
# the OS.
|
||||||
|
#
|
||||||
|
# For example, when $arches is " amd64 arm64 " and $arch is
|
||||||
|
# "amd64", then the pattern to remove is "* amd64 *", so the
|
||||||
|
# whole string becomes empty. On the other hand, if $arch is
|
||||||
|
# "windows", then the pattern is "* windows *", which doesn't
|
||||||
|
# match, so nothing is removed.
|
||||||
|
#
|
||||||
|
# See https://stackoverflow.com/a/43912605/1892060.
|
||||||
|
if [ "${arches##* $arch *}" != '' ]
|
||||||
|
then
|
||||||
|
log "$arch excluded, continuing"
|
||||||
|
|
||||||
|
continue
|
||||||
|
elif [ "${oses##* $os *}" != '' ]
|
||||||
|
then
|
||||||
|
log "$os excluded, continuing"
|
||||||
|
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
case "$arch"
|
case "$arch"
|
||||||
in
|
in
|
||||||
(arm)
|
(arm)
|
||||||
|
@ -280,15 +328,20 @@ done
|
||||||
|
|
||||||
log "calculating checksums"
|
log "calculating checksums"
|
||||||
|
|
||||||
# Calculate the checksums of the files in a subshell with file expansion
|
# Calculate the checksums of the files in a subshell with a different
|
||||||
# enabled (+f) so that we don't need to use find or basename.
|
# working directory. Don't use ls, because files matching one of the
|
||||||
|
# patterns may be absent, which will make ls return with a non-zero
|
||||||
|
# status code.
|
||||||
(
|
(
|
||||||
set +f
|
|
||||||
|
|
||||||
cd "./${dist}"
|
cd "./${dist}"
|
||||||
|
|
||||||
|
files="$( \
|
||||||
|
find . ! -name . -prune\
|
||||||
|
\( -name '*.tar.gz' -o -name '*.zip' \)
|
||||||
|
)"
|
||||||
|
|
||||||
# Don't use quotes to get word splitting.
|
# Don't use quotes to get word splitting.
|
||||||
sha256sum $(ls -1 -A -q *.tar.gz *.zip) > ./checksums.txt
|
sha256sum $files > ./checksums.txt
|
||||||
)
|
)
|
||||||
|
|
||||||
log "writing versions"
|
log "writing versions"
|
||||||
|
@ -330,11 +383,12 @@ echo "
|
||||||
\"download_linux_mips64le\": \"${version_download_url}/AdGuardHome_linux_mips64le_softfloat.tar.gz\",
|
\"download_linux_mips64le\": \"${version_download_url}/AdGuardHome_linux_mips64le_softfloat.tar.gz\",
|
||||||
" >> "$version_json"
|
" >> "$version_json"
|
||||||
|
|
||||||
(
|
# Same as with checksums above, don't use ls, because files matching one
|
||||||
# Use +f here so that ls works and we don't need to use find.
|
# of the patterns may be absent.
|
||||||
set +f
|
readonly ar_files="$( \
|
||||||
|
find "./${dist}/" ! -name "${dist}" -prune\
|
||||||
readonly ar_files="$(ls -1 -A -q "./${dist}/"*.tar.gz "./${dist}/"*.zip)"
|
\( -name '*.tar.gz' -o -name '*.zip' \)
|
||||||
|
)"
|
||||||
readonly ar_files_len="$(echo "$ar_files" | wc -l)"
|
readonly ar_files_len="$(echo "$ar_files" | wc -l)"
|
||||||
|
|
||||||
i='1'
|
i='1'
|
||||||
|
@ -362,7 +416,6 @@ echo "
|
||||||
|
|
||||||
i="$(( i + 1 ))"
|
i="$(( i + 1 ))"
|
||||||
done
|
done
|
||||||
)
|
|
||||||
|
|
||||||
echo '}' >> "$version_json"
|
echo '}' >> "$version_json"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue