2015-10-31 13:13:38 +01:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
2017-12-06 20:22:55 +01:00
|
|
|
|
if [ -d $GOOS ]; then OS=$(go env GOOS); else OS=$GOOS; fi
|
2023-03-01 20:38:30 +01:00
|
|
|
|
if [ -d $CGO_ENABLED ]; then CGO_ENABLED=$(go env CGO_ENABLED); else OS=$CGO_ENABLED; fi
|
2017-12-06 20:22:55 +01:00
|
|
|
|
|
2021-08-12 22:26:39 -06:00
|
|
|
|
VERSION=$(grep "Version =" internal/buildinfo/VERSION.go|cut -d '"' -f2)
|
2016-02-22 21:54:32 +01:00
|
|
|
|
|
2025-09-03 18:51:27 +02:00
|
|
|
|
# Go 1.24 or later is required
|
2018-02-17 21:36:54 +01:00
|
|
|
|
GO_POINT_VERSION=$(go version| perl -ne 'm/go1\.(\d+)/; print $1;')
|
2025-09-03 18:51:27 +02:00
|
|
|
|
[ "$GO_POINT_VERSION" -lt "24" ] && echo "Go 1.24 or later required" && exit 1;
|
2015-10-31 13:13:38 +01:00
|
|
|
|
|
2018-04-21 11:51:17 +02:00
|
|
|
|
AX25VERSION="0.0.12-rc4"
|
|
|
|
|
|
AX25DIST="libax25-${AX25VERSION}"
|
2025-07-30 17:42:59 +02:00
|
|
|
|
AX25DIST_URL="https://ubuntu.hi.no/ubuntu/pool/universe/liba/libax25/libax25_${AX25VERSION}.orig.tar.gz"
|
2017-08-12 00:41:35 +02:00
|
|
|
|
function install_libax25 {
|
|
|
|
|
|
mkdir -p .build && cd .build
|
2018-04-21 11:51:17 +02:00
|
|
|
|
[[ -f "${AX25DIST}" ]] || curl -LSsf "${AX25DIST_URL}" | tar zx
|
|
|
|
|
|
cd "${AX25DIST}/" && ./configure --prefix=/ && make && cd ../../
|
2017-08-12 00:41:35 +02:00
|
|
|
|
}
|
2022-03-18 11:34:37 -06:00
|
|
|
|
function build_web {
|
2025-09-19 21:31:40 +02:00
|
|
|
|
bash web/make.bash
|
2022-03-18 11:34:37 -06:00
|
|
|
|
}
|
2025-08-12 10:24:34 +02:00
|
|
|
|
function embed {
|
2025-08-12 19:02:44 +02:00
|
|
|
|
curl -LSsf "https://www.sidc.be/SILSO/FORECASTS/KFprediCM.txt" > internal/propagation/silso/KFprediCM.txt && go test ./internal/propagation/silso
|
2025-08-12 10:24:34 +02:00
|
|
|
|
curl -LSsf 'https://api.winlink.org/gateway/status.json?key=1880278F11684B358F36845615BD039A&mode=AnyAll&HistoryHours=48&ServiceCodes=PUBLIC' | gzip -9 > internal/cmsapi/gateway_status.json.gz && go test ./internal/cmsapi
|
|
|
|
|
|
}
|
2025-09-17 21:23:21 +02:00
|
|
|
|
function pre_release {
|
|
|
|
|
|
build_web > /dev/null
|
|
|
|
|
|
embed
|
|
|
|
|
|
go tool govulncheck ./...
|
|
|
|
|
|
}
|
2017-08-12 00:41:35 +02:00
|
|
|
|
|
2025-08-12 10:24:34 +02:00
|
|
|
|
[[ "$1" == "libax25" ]] && { install_libax25; exit $?; }
|
|
|
|
|
|
[[ "$1" == "web" ]] && { build_web; exit $?; }
|
|
|
|
|
|
[[ "$1" == "embed" ]] && { embed; exit $?; }
|
2025-09-17 21:23:21 +02:00
|
|
|
|
[[ "$1" == "pre-release" ]] && { pre_release; exit $?; }
|
2017-08-12 00:41:35 +02:00
|
|
|
|
|
2016-09-19 20:04:54 +02:00
|
|
|
|
# Link against libax25 (statically) on Linux
|
2023-03-01 20:38:30 +01:00
|
|
|
|
if [[ "$OS" == "linux"* ]] && [[ "$CGO_ENABLED" == "1" ]]; then
|
2017-08-12 00:41:35 +02:00
|
|
|
|
TAGS="libax25 $TAGS"
|
|
|
|
|
|
LIB=".build/${AX25DIST}/.libs/libax25.a"
|
|
|
|
|
|
if [[ -z "$CGO_LDFLAGS" ]] && [[ -f "$LIB" ]]; then
|
|
|
|
|
|
export CGO_CFLAGS="-I$(pwd)/.build/${AX25DIST}"
|
|
|
|
|
|
export CGO_LDFLAGS="$(pwd)/${LIB}"
|
|
|
|
|
|
fi
|
|
|
|
|
|
if [[ -z "$CGO_LDFLAGS" ]]; then
|
|
|
|
|
|
echo "WARNING: No static libax25 library available."
|
|
|
|
|
|
echo " Linking against shared library instead. To fix"
|
|
|
|
|
|
echo " this issue, set CGO_LDFLAGS to the full path of"
|
|
|
|
|
|
echo " libax25.a, or run 'make.bash libax25' to download"
|
|
|
|
|
|
echo " and compile ${AX25DIST} in .build/"
|
2016-09-19 20:03:17 +02:00
|
|
|
|
else
|
2017-08-12 00:41:35 +02:00
|
|
|
|
TAGS="static $TAGS"
|
2016-09-19 20:03:17 +02:00
|
|
|
|
fi
|
2023-03-01 20:38:30 +01:00
|
|
|
|
else
|
|
|
|
|
|
if [[ "$OS" == "linux"* ]]; then
|
|
|
|
|
|
echo "WARNING: CGO unavailable. libax25 (ax25+linux) will not be supported with this build."
|
|
|
|
|
|
fi
|
2016-09-19 20:03:17 +02:00
|
|
|
|
fi
|
2015-11-01 21:56:16 +01:00
|
|
|
|
|
2020-05-27 22:57:32 +02:00
|
|
|
|
echo -e "Downloading Go dependencies..."
|
|
|
|
|
|
go mod download
|
2016-05-07 22:10:47 +02:00
|
|
|
|
|
2016-09-19 20:03:17 +02:00
|
|
|
|
echo "Running tests..."
|
2021-10-24 14:01:32 +02:00
|
|
|
|
if [[ "$SKIP_TESTS" == "1" ]]; then
|
|
|
|
|
|
echo "Skipping."
|
|
|
|
|
|
else
|
|
|
|
|
|
go test -tags "$TAGS" ./... github.com/la5nta/wl2k-go/...
|
|
|
|
|
|
fi
|
2016-09-19 20:03:17 +02:00
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
|
|
echo "Building Pat v$VERSION..."
|
2025-12-20 12:45:31 +01:00
|
|
|
|
go build -tags "$TAGS"
|
2016-09-12 18:23:16 +02:00
|
|
|
|
|
2022-03-22 17:49:11 -06:00
|
|
|
|
# Build macOS pkg
|
2017-12-06 20:22:55 +01:00
|
|
|
|
if [[ "$OS" == "darwin"* ]] && command -v packagesbuild >/dev/null 2>&1; then
|
2022-03-22 17:49:11 -06:00
|
|
|
|
ARCH=$(go env GOARCH)
|
2016-09-19 20:03:17 +02:00
|
|
|
|
echo "Generating macOS installer package..."
|
2016-09-12 18:23:16 +02:00
|
|
|
|
packagesbuild osx/pat.pkgproj
|
2022-03-22 17:49:11 -06:00
|
|
|
|
mv 'Pat :: A Modern Winlink Client.pkg' "pat_${VERSION}_darwin_${ARCH}_unsigned.pkg"
|
2016-09-12 18:23:16 +02:00
|
|
|
|
fi
|
2016-09-19 20:03:17 +02:00
|
|
|
|
|
|
|
|
|
|
echo -e "Enjoy!"
|