Skip to content

Commit ed5fb03

Browse files
Merge pull request #1 from LinuxForHealth/initial-build
Initial Build
2 parents d06a54f + bf98ace commit ed5fb03

File tree

4 files changed

+127
-15
lines changed

4 files changed

+127
-15
lines changed

.gitignore

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
# Binaries for programs and plugins
2-
*.exe
3-
*.exe~
4-
*.dll
5-
*.so
6-
*.dylib
1+
# exclude build directory
2+
build
73

8-
# Test binary, built with `go test -c`
9-
*.test
10-
11-
# Output of the go coverage tool, specifically when used with LiteIDE
12-
*.out
13-
14-
# Dependency directories (remove the comment below to include it)
15-
# vendor/
4+
# exclude IDE configurations
5+
.idea
6+
.vscode

README.md

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
11
# nats-390x-package
2-
Builds a NATS Server Package for the s390x Architecture Using goreleaser
2+
Builds a NATS Server Package for the s390x Architecture Using [nfpm]
3+
4+
## Dependencies
5+
6+
nats-390x-package has the following dependencies:
7+
8+
- [bash](https://www.gnu.org/software/bash/) 5.x or higher for build scripting
9+
- [curl](https://curl.se/) to download NATS releases
10+
- [go](https://go.dev/) to build NATS from source
11+
- [nfpm](https://github.com/goreleaser/nfpm) to create the debian package
12+
13+
## Quickstart
14+
15+
Run `build.sh` to create a package for nats-server v2.8.4
16+
17+
```shell
18+
user@MBP nats-390x-package % ./build.sh
19+
***********************************
20+
building nats release https://github.com/nats-io/nats-server/archive/refs/tags/v2.8.4.tar.gz
21+
***********************************
22+
% Total % Received % Xferd Average Speed Time Time Time Current
23+
Dload Upload Total Spent Left Speed
24+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
25+
100 1445k 0 1445k 0 0 1979k 0 --:--:-- --:--:-- --:--:-- 9169k
26+
/Users/user/code/lfh/nats-390x-package
27+
Building NATS version v2.8.4
28+
/Users/user/code/lfh/nats-390x-package
29+
NATS build complete.
30+
nats-server is located in build/release/nats-server
31+
Creating deb package file
32+
using deb packager...
33+
created package: build/release/nats-server_2.8.4_s390x.deb
34+
```
35+
36+
`build.sh` is designed to download a "source tarball" from the [nats-server github repo](https://github.com/nats-io/nats-server/releases)
37+
The script is hard-coded to what is, as of now, the current nats-server release, version 2.8.4. To specify a different
38+
release, invoke build.sh with the `-n` or `--nats-release` option
39+
40+
```shell
41+
./build.sh --nats-release https://github.com/nats-io/nats-server/archive/refs/tags/v2.8.2.tar.gz
42+
```

build.sh

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

nfpm.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# nfpm configuration file
2+
# values for this file are taken from the https://github.com/nats-io/nats-server project
3+
name: nats-server
4+
arch: s390x
5+
platform: linux
6+
version: v2.8.4
7+
version_schema: semvar
8+
description: High-Performance server for NATS, the cloud native messaging system.
9+
vendor: Synadia Inc.
10+
homepage: https://nats.io
11+
license: Apache 2.0
12+
replaces:
13+
- nats-server
14+
provides:
15+
- nats-server
16+
maintainer: "LinuxForHealth"
17+
contents:
18+
- src: ./build/release/nats-server
19+
dst: /usr/local/bin/nats-server
20+

0 commit comments

Comments
 (0)