VERSION.txt is embedded into the server and the agent, so a plain go build reports the real version and build.sh no longer injects it.
47 lines
1.7 KiB
Bash
Executable File
47 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Build the LPRA server (for the local host OS *and* Linux) and cross-compile
|
|
# the Linux agent binaries served at /download/.
|
|
set -eu
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# The version comes from VERSION.txt, which is embedded into every binary.
|
|
LDFLAGS="-s -w"
|
|
echo ">> version $(cat VERSION.txt)"
|
|
|
|
mkdir -p dist bin
|
|
|
|
echo ">> building server (local: $(go env GOOS)/$(go env GOARCH))"
|
|
go build -trimpath -ldflags "$LDFLAGS" -o bin/lpra-server ./cmd/server
|
|
|
|
echo ">> building server linux/amd64"
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o bin/lpra-server-linux-amd64 ./cmd/server
|
|
|
|
echo ">> building server linux/arm64"
|
|
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o bin/lpra-server-linux-arm64 ./cmd/server
|
|
|
|
echo ">> building agent linux/amd64"
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o dist/agent-linux-amd64 ./cmd/agent
|
|
|
|
echo ">> building agent linux/arm64"
|
|
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o dist/agent-linux-arm64 ./cmd/agent
|
|
|
|
echo ">> building agent darwin/arm64 + amd64"
|
|
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o bin/agent-darwin-arm64 ./cmd/agent
|
|
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" \
|
|
-o bin/agent-darwin-amd64 ./cmd/agent
|
|
|
|
echo
|
|
echo "Done."
|
|
echo " server (local): bin/lpra-server"
|
|
echo " server (Linux): bin/lpra-server-linux-amd64, bin/lpra-server-linux-arm64"
|
|
echo " agents (Linux): dist/agent-linux-amd64, dist/agent-linux-arm64"
|
|
echo
|
|
echo "On the Linux host copy the matching server binary to /opt/lpra/lpra-server,"
|
|
echo "e.g.: cp bin/lpra-server-linux-amd64 /opt/lpra/lpra-server"
|