mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-15 09:58:42 -07:00
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`.
|
||||
|
||||
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`.
|
||||
* `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
|
||||
|
@ -6,19 +6,19 @@
|
||||
# reader only has superficial knowledge of the POSIX shell language and
|
||||
# alike. Experienced readers may find it overly verbose.
|
||||
|
||||
# The default verbosity level is 0. Show every command that is run if
|
||||
# the caller requested verbosity level greater than 0. Show the
|
||||
# environment if the callre requested verbosity level greater than 1.
|
||||
# Otherwise, print nothing.
|
||||
# The default verbosity level is 0. Show log messages if the caller
|
||||
# requested verbosity level greather than 0. Show every command that is
|
||||
# run if the verbosity level is greater than 1. Show the environment if
|
||||
# the verbosity level is greater than 2. Otherwise, print nothing.
|
||||
#
|
||||
# The level of verbosity for the build script is the same minus one
|
||||
# level. See below in build().
|
||||
readonly verbose="${VERBOSE:-0}"
|
||||
if [ "$verbose" -gt '1' ]
|
||||
if [ "$verbose" -gt '2' ]
|
||||
then
|
||||
env
|
||||
set -x
|
||||
elif [ "$verbose" -gt '0' ]
|
||||
elif [ "$verbose" -gt '1' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
@ -58,6 +58,30 @@ fi
|
||||
log "channel '$channel'"
|
||||
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
|
||||
# required.
|
||||
if [ "$sign" = '1' ]
|
||||
@ -196,7 +220,7 @@ build() {
|
||||
|
||||
log "$build_archive"
|
||||
|
||||
if [ "$build_snap" = '0' ]
|
||||
if [ "$build_snap" = '0' -o "$snap_enabled" = '0' ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
@ -259,6 +283,30 @@ log "starting builds"
|
||||
# tweak the values where necessary, and feed to build.
|
||||
echo "$platforms" | while read -r os arch arm mips snap
|
||||
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"
|
||||
in
|
||||
(arm)
|
||||
@ -280,15 +328,20 @@ done
|
||||
|
||||
log "calculating checksums"
|
||||
|
||||
# Calculate the checksums of the files in a subshell with file expansion
|
||||
# enabled (+f) so that we don't need to use find or basename.
|
||||
# Calculate the checksums of the files in a subshell with a different
|
||||
# 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}"
|
||||
|
||||
files="$( \
|
||||
find . ! -name . -prune\
|
||||
\( -name '*.tar.gz' -o -name '*.zip' \)
|
||||
)"
|
||||
|
||||
# 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"
|
||||
@ -330,39 +383,39 @@ echo "
|
||||
\"download_linux_mips64le\": \"${version_download_url}/AdGuardHome_linux_mips64le_softfloat.tar.gz\",
|
||||
" >> "$version_json"
|
||||
|
||||
(
|
||||
# Use +f here so that ls works and we don't need to use find.
|
||||
set +f
|
||||
# Same as with checksums above, don't use ls, because files matching one
|
||||
# of the patterns may be absent.
|
||||
readonly ar_files="$( \
|
||||
find "./${dist}/" ! -name "${dist}" -prune\
|
||||
\( -name '*.tar.gz' -o -name '*.zip' \)
|
||||
)"
|
||||
readonly ar_files_len="$(echo "$ar_files" | wc -l)"
|
||||
|
||||
readonly ar_files="$(ls -1 -A -q "./${dist}/"*.tar.gz "./${dist}/"*.zip)"
|
||||
readonly ar_files_len="$(echo "$ar_files" | wc -l)"
|
||||
i='1'
|
||||
# Don't use quotes to get word splitting.
|
||||
for f in $ar_files
|
||||
do
|
||||
platform="$f"
|
||||
|
||||
i='1'
|
||||
# Don't use quotes to get word splitting.
|
||||
for f in $ar_files
|
||||
do
|
||||
platform="$f"
|
||||
# Remove the prefix.
|
||||
platform="${platform#./${dist}/AdGuardHome_}"
|
||||
|
||||
# Remove the prefix.
|
||||
platform="${platform#./${dist}/AdGuardHome_}"
|
||||
# Remove the filename extensions.
|
||||
platform="${platform%.zip}"
|
||||
platform="${platform%.tar.gz}"
|
||||
|
||||
# Remove the filename extensions.
|
||||
platform="${platform%.zip}"
|
||||
platform="${platform%.tar.gz}"
|
||||
# Use the filename's base path.
|
||||
filename="${f#./${dist}/}"
|
||||
|
||||
# Use the filename's base path.
|
||||
filename="${f#./${dist}/}"
|
||||
if [ "$i" = "$ar_files_len" ]
|
||||
then
|
||||
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"" >> "$version_json"
|
||||
else
|
||||
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >> "$version_json"
|
||||
fi
|
||||
|
||||
if [ "$i" = "$ar_files_len" ]
|
||||
then
|
||||
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"" >> "$version_json"
|
||||
else
|
||||
echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >> "$version_json"
|
||||
fi
|
||||
|
||||
i="$(( i + 1 ))"
|
||||
done
|
||||
)
|
||||
i="$(( i + 1 ))"
|
||||
done
|
||||
|
||||
echo '}' >> "$version_json"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user