|
@@ -31,17 +31,17 @@ export PKG_CONFIG=${PKG_CONFIG:-pkg-config}
|
|
# We're a nice, sexy, little shell script, and people might try to run us;
|
|
# We're a nice, sexy, little shell script, and people might try to run us;
|
|
# but really, they shouldn't. We want to be in a container!
|
|
# but really, they shouldn't. We want to be in a container!
|
|
inContainer="AssumeSoInitially"
|
|
inContainer="AssumeSoInitially"
|
|
-if [[ "$(go env GOHOSTOS)" = 'windows' ]]; then
|
|
|
|
- if [[ -z "$FROM_DOCKERFILE" ]]; then
|
|
|
|
|
|
+if [ "$(go env GOHOSTOS)" = 'windows' ]; then
|
|
|
|
+ if [ -z "$FROM_DOCKERFILE" ]; then
|
|
unset inContainer
|
|
unset inContainer
|
|
fi
|
|
fi
|
|
else
|
|
else
|
|
- if [[ "$PWD" != "/go/src/$DOCKER_PKG" ]]; then
|
|
|
|
|
|
+ if [ "$PWD" != "/go/src/$DOCKER_PKG" ]; then
|
|
unset inContainer
|
|
unset inContainer
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
|
|
-if [[ -z "$inContainer" ]]; then
|
|
|
|
|
|
+if [ -z "$inContainer" ]; then
|
|
{
|
|
{
|
|
echo "# WARNING! I don't seem to be running in a Docker container."
|
|
echo "# WARNING! I don't seem to be running in a Docker container."
|
|
echo "# The result of this command might be an incorrect build, and will not be"
|
|
echo "# The result of this command might be an incorrect build, and will not be"
|
|
@@ -67,11 +67,11 @@ DEFAULT_BUNDLES=(
|
|
|
|
|
|
VERSION=${VERSION:-dev}
|
|
VERSION=${VERSION:-dev}
|
|
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
|
|
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
|
|
-if [[ "$DOCKER_GITCOMMIT" ]]; then
|
|
|
|
|
|
+if [ "$DOCKER_GITCOMMIT" ]; then
|
|
GITCOMMIT="$DOCKER_GITCOMMIT"
|
|
GITCOMMIT="$DOCKER_GITCOMMIT"
|
|
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
|
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
|
- if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
|
|
|
|
|
|
+ if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
|
GITCOMMIT="$GITCOMMIT-unsupported"
|
|
GITCOMMIT="$GITCOMMIT-unsupported"
|
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
echo "# GITCOMMIT = $GITCOMMIT"
|
|
echo "# GITCOMMIT = $GITCOMMIT"
|
|
@@ -90,14 +90,14 @@ else
|
|
exit 1
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
-if [[ "$AUTO_GOPATH" ]]; then
|
|
|
|
|
|
+if [ "$AUTO_GOPATH" ]; then
|
|
rm -rf .gopath
|
|
rm -rf .gopath
|
|
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
|
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
|
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
|
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
|
export GOPATH="${PWD}/.gopath"
|
|
export GOPATH="${PWD}/.gopath"
|
|
fi
|
|
fi
|
|
|
|
|
|
-if [[ ! "$GOPATH" ]]; then
|
|
|
|
|
|
+if [ ! "$GOPATH" ]; then
|
|
echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH'
|
|
echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH'
|
|
echo >&2 ' alternatively, set AUTO_GOPATH=1'
|
|
echo >&2 ' alternatively, set AUTO_GOPATH=1'
|
|
exit 1
|
|
exit 1
|
|
@@ -137,7 +137,7 @@ fi
|
|
# Use these flags when compiling the tests and final binary
|
|
# Use these flags when compiling the tests and final binary
|
|
|
|
|
|
IAMSTATIC='true'
|
|
IAMSTATIC='true'
|
|
-if [[ -z "$DOCKER_DEBUG" ]]; then
|
|
|
|
|
|
+if [ -z "$DOCKER_DEBUG" ]; then
|
|
LDFLAGS='-w'
|
|
LDFLAGS='-w'
|
|
fi
|
|
fi
|
|
|
|
|
|
@@ -148,12 +148,12 @@ EXTLDFLAGS_STATIC='-static'
|
|
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
|
|
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
|
|
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
|
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
|
|
|
|
|
-BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
|
|
|
|
|
|
+BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" )
|
|
|
|
|
|
# Test timeout.
|
|
# Test timeout.
|
|
-if [[ "${DOCKER_ENGINE_GOARCH}" == "arm64" ]] || [[ "${DOCKER_ENGINE_GOARCH}" == "arm" ]]; then
|
|
|
|
|
|
+if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
|
|
: ${TIMEOUT:=10m}
|
|
: ${TIMEOUT:=10m}
|
|
-elif [[ "${DOCKER_ENGINE_GOARCH}" == "windows" ]]; then
|
|
|
|
|
|
+elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then
|
|
: ${TIMEOUT:=8m}
|
|
: ${TIMEOUT:=8m}
|
|
else
|
|
else
|
|
: ${TIMEOUT:=5m}
|
|
: ${TIMEOUT:=5m}
|
|
@@ -164,7 +164,7 @@ LDFLAGS_STATIC_DOCKER="
|
|
-extldflags \"$EXTLDFLAGS_STATIC\"
|
|
-extldflags \"$EXTLDFLAGS_STATIC\"
|
|
"
|
|
"
|
|
|
|
|
|
-if [[ "$(uname -s)" = 'FreeBSD' ]]; then
|
|
|
|
|
|
+if [ "$(uname -s)" = 'FreeBSD' ]; then
|
|
# Tell cgo the compiler is Clang, not GCC
|
|
# Tell cgo the compiler is Clang, not GCC
|
|
# https://code.google.com/p/go/source/browse/src/cmd/cgo/gcc.go?spec=svne77e74371f2340ee08622ce602e9f7b15f29d8d3&r=e6794866ebeba2bf8818b9261b54e2eef1c9e588#752
|
|
# https://code.google.com/p/go/source/browse/src/cmd/cgo/gcc.go?spec=svne77e74371f2340ee08622ce602e9f7b15f29d8d3&r=e6794866ebeba2bf8818b9261b54e2eef1c9e588#752
|
|
export CC=clang
|
|
export CC=clang
|
|
@@ -181,7 +181,7 @@ bundle() {
|
|
}
|
|
}
|
|
|
|
|
|
main() {
|
|
main() {
|
|
- if [[ -z "${KEEPBUNDLE-}" ]]; then
|
|
|
|
|
|
+ if [ -z "${KEEPBUNDLE-}" ]; then
|
|
echo "Removing bundles/"
|
|
echo "Removing bundles/"
|
|
rm -rf "bundles/*"
|
|
rm -rf "bundles/*"
|
|
echo
|
|
echo
|
|
@@ -189,13 +189,13 @@ main() {
|
|
mkdir -p bundles
|
|
mkdir -p bundles
|
|
|
|
|
|
# Windows and symlinks don't get along well
|
|
# Windows and symlinks don't get along well
|
|
- if [[ "$(go env GOHOSTOS)" != 'windows' ]]; then
|
|
|
|
|
|
+ if [ "$(go env GOHOSTOS)" != 'windows' ]; then
|
|
rm -f bundles/latest
|
|
rm -f bundles/latest
|
|
# preserve latest symlink for backward compatibility
|
|
# preserve latest symlink for backward compatibility
|
|
ln -sf . bundles/latest
|
|
ln -sf . bundles/latest
|
|
fi
|
|
fi
|
|
|
|
|
|
- if [[ $# -lt 1 ]]; then
|
|
|
|
|
|
+ if [ $# -lt 1 ]; then
|
|
bundles=(${DEFAULT_BUNDLES[@]})
|
|
bundles=(${DEFAULT_BUNDLES[@]})
|
|
else
|
|
else
|
|
bundles=($@)
|
|
bundles=($@)
|