-
Notifications
You must be signed in to change notification settings - Fork 0
/
package
executable file
·52 lines (45 loc) · 1.61 KB
/
package
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
#!/usr/bin/env bash
set -euo pipefail
export DIST_DIR="dist"
ERL_ROOT=$(erl -noinput -eval 'io:format("~s",[code:root_dir()]),halt().')
ERL_DIR=$(basename $ERL_ROOT)
./build
tar -czf _build/emqx_data_converter.tar.gz -C "$DIST_DIR" .
rm -rf _build/emqx_data_converter
rm -rf _build/$ERL_DIR
UNAME="$(uname -s)"
case "$UNAME" in
Darwin)
DIST='macos'
VERSION_ID="$(sw_vers | grep 'ProductVersion' | cut -d':' -f 2 | cut -d'.' -f1 | tr -d ' \t')"
SYSTEM="${DIST}${VERSION_ID}"
;;
Linux)
# /etc/os-release on amazon linux 2 contains both rhel and centos strings
if grep -q -i 'amzn' /etc/*-release; then
DIST='amzn'
VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')"
elif grep -q -i 'rhel' /etc/*-release; then
DIST='el'
VERSION_ID="$(rpm --eval '%{rhel}')"
else
DIST="$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')"
VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')"
fi
SYSTEM="$(echo "${DIST}${VERSION_ID}" | sed -r 's/([a-zA-Z]*)-.*/\1/g')"
;;
esac
ARCH="$(uname -m)"
case "$ARCH" in
x86_64)
ARCH='amd64'
;;
aarch64)
ARCH='arm64'
;;
arm*)
ARCH=arm
;;
esac
VSN="${VSN:-$(grep -E ".+vsn.+" _build/default/lib/emqx_data_converter/ebin/emqx_data_converter.app | cut -d '"' -f2)}"
cp "./_build/emqx_data_converter.tar.gz" "./emqx-data-converter-${VSN}-${SYSTEM}-${ARCH}.tar.gz"