Pull request: all: improve build reproducibility
Updates #2959. Squashed commit of the following: commit 2178c73835454b75b6b0790322df3975e1d14f10 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Apr 30 19:34:39 2021 +0300 all: improve build reproducibility
This commit is contained in:
parent
9846eeb1d8
commit
1402145cdd
|
@ -65,7 +65,7 @@ Optional environment:
|
||||||
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
|
||||||
`build-release.sh`.
|
`build-release.sh`.
|
||||||
* `VERSION`: release version. Will be set by `version.sh` if it is unset or
|
* `VERSION`: release version. Will be set by `version.sh` if it is unset or
|
||||||
it has the default `Makefile` value of `v0.0.0`.
|
if it has the default `Makefile` value of `v0.0.0`.
|
||||||
|
|
||||||
### `clean.sh`: Cleanup
|
### `clean.sh`: Cleanup
|
||||||
|
|
||||||
|
@ -78,6 +78,8 @@ Required environment:
|
||||||
### `go-build.sh`: Build The Backend
|
### `go-build.sh`: Build The Backend
|
||||||
|
|
||||||
Optional environment:
|
Optional environment:
|
||||||
|
* `BUILD_TIME`: If set, overrides the build time information. Useful for
|
||||||
|
reproducible builds.
|
||||||
* `GOARM`: ARM processor options for the Go compiler.
|
* `GOARM`: ARM processor options for the Go compiler.
|
||||||
* `GOMIPS`: ARM processor options for the Go compiler.
|
* `GOMIPS`: ARM processor options for the Go compiler.
|
||||||
* `GO`: set an alternarive name for the Go compiler.
|
* `GO`: set an alternarive name for the Go compiler.
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# every package that is processed if the caller requested verbosity
|
# every package that is processed if the caller requested verbosity
|
||||||
# level greater than 0. Also show subcommands if the requested
|
# level greater than 0. Also show subcommands if the requested
|
||||||
# verbosity level is greater than 1. Otherwise, do nothing.
|
# verbosity level is greater than 1. Otherwise, do nothing.
|
||||||
verbose="${VERBOSE:-0}"
|
readonly verbose="${VERBOSE:-0}"
|
||||||
if [ "$verbose" -gt '1' ]
|
if [ "$verbose" -gt '1' ]
|
||||||
then
|
then
|
||||||
env
|
env
|
||||||
|
@ -33,10 +33,10 @@ fi
|
||||||
set -e -f -u
|
set -e -f -u
|
||||||
|
|
||||||
# Allow users to set the Go version.
|
# Allow users to set the Go version.
|
||||||
go="${GO:-go}"
|
readonly go="${GO:-go}"
|
||||||
|
|
||||||
# Require the channel to be set and validate the value.
|
# Require the channel to be set and validate the value.
|
||||||
channel="$CHANNEL"
|
readonly channel="$CHANNEL"
|
||||||
case "$channel"
|
case "$channel"
|
||||||
in
|
in
|
||||||
('development'|'edge'|'beta'|'release')
|
('development'|'edge'|'beta'|'release')
|
||||||
|
@ -52,10 +52,10 @@ esac
|
||||||
# Require the version to be set.
|
# Require the version to be set.
|
||||||
#
|
#
|
||||||
# TODO(a.garipov): Additional validation?
|
# TODO(a.garipov): Additional validation?
|
||||||
version="$VERSION"
|
readonly version="$VERSION"
|
||||||
|
|
||||||
# Set date and time of the current build.
|
# Set date and time of the current build unless already set.
|
||||||
buildtime="$(date -u +%FT%TZ%z)"
|
readonly buildtime="${BUILD_TIME:-$( date -u +%FT%TZ%z )}"
|
||||||
|
|
||||||
# Set the linker flags accordingly: set the release channel and the
|
# Set the linker flags accordingly: set the release channel and the
|
||||||
# current version as well as goarm and gomips variable values, if the
|
# current version as well as goarm and gomips variable values, if the
|
||||||
|
@ -106,7 +106,7 @@ fi
|
||||||
export CGO_ENABLED="$cgo_enabled"
|
export CGO_ENABLED="$cgo_enabled"
|
||||||
export GO111MODULE='on'
|
export GO111MODULE='on'
|
||||||
|
|
||||||
readonly build_flags="${BUILD_FLAGS:-$race_flags $out_flags $par_flags $v_flags $x_flags}"
|
readonly build_flags="${BUILD_FLAGS:-$race_flags --trimpath $out_flags $par_flags $v_flags $x_flags}"
|
||||||
|
|
||||||
# Don't use quotes with flag variables to get word splitting.
|
# Don't use quotes with flag variables to get word splitting.
|
||||||
"$go" generate $v_flags $x_flags ./main.go
|
"$go" generate $v_flags $x_flags ./main.go
|
||||||
|
|
Loading…
Reference in New Issue