-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·61 lines (50 loc) · 1.45 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# build.sh
# Builds the nats-server for the s390x architecture within a Debian package
# Usage:
# ./build.sh [-n | --nats-release url]
#
# Dependencies:
# bash >= 5.x to support this script
# curl: to download the nats release tarball
# golang: to build nats-server for s390x
# nfpm: for debian packaging
set -Eeuo pipefail
nats_release=https://github.com/nats-io/nats-server/archive/refs/tags/v2.8.4.tar.gz
INSTALL_ARGS=$(getopt -o n: --long nats-release: -- "$@")
eval set -- "$INSTALL_ARGS"
while true; do
case "$1" in
-n|--nats-release)
nats_release="$2"
shift 2
;;
--)
shift;
break
;;
esac
done
echo "***********************************"
echo "building nats release $nats_release"
echo "***********************************"
# clean existing build environment
rm -rf build
mkdir -p build/nats-server/release
# extract file name and version number
file_name="${nats_release##*/}"
version_number="${file_name::-7}"
# download NATS release
curl -L -o build/"$file_name" "$nats_release"
cd build && \
tar -xzf "$file_name" --strip 1 -C nats-server && \
cd -
# build NATS for s390x
echo "Building NATS version $version_number"
cd build/nats-server && \
GOOS=linux GOARCH=s390x go build -o ../release/nats-server && \
cd -
echo "NATS build complete."
echo "nats-server is located in build/release/nats-server"
echo "Creating deb package file"
nfpm package --packager deb --target build/release