forked from xcat2/goconserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirty-debuild
executable file
·112 lines (89 loc) · 2.74 KB
/
dirty-debuild
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#
# warn_if_bad Put out warning message(s) if $1 has bad RC.
#
# $1 0 (pass) or non-zero (fail).
# $2+ Remaining arguments printed only if the $1 is non-zero.
#
# Incoming $1 is returned unless it is 0
#
function warn_if_bad()
{
local -i rc="$1"
local script="${0##*/}"
# Ignore if no problems
[ "${rc}" -eq "0" ] && return 0
# Broken
shift
echo "${script}: $@" >&2
return "${rc}"
}
#
# exit_if_bad Put out error message(s) if $1 has bad RC.
#
# $1 0 (pass) or non-zero (fail).
# $2+ Remaining arguments printed only if the $1 is non-zero.
#
# Exits with 1 unless $1 is 0
#
function exit_if_bad()
{
warn_if_bad "$@" || exit 1
return 0
}
TMP_DIR=""
function internal_cleanup()
{
[ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}"
}
#trap internal_cleanup EXIT
TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)"
exit_if_bad "$?" "Above listed required command(s) not found."
# Main
if [ -z "$1" ]
then
echo "Usage: ${0##*/} <goconserver binary tarball>"
echo
echo "Examples:"
echo " ${0##*/} goconserver_linux_ppc64le.tar.gz"
echo " ${0##*/} https://github.com/xcat2/goconserver/files/1505167/goconserver_linux_ppc64le.tar.gz"
exit 0
fi
BASE_DIR="${0%/*}"
GOCONSERVER_BINARY_TARBALL="$1"
"${BASE_DIR}/prep-tarball" "${GOCONSERVER_BINARY_TARBALL}"
exit_if_bad "$?" "prep-tarball failed."
tmp_b="${GOCONSERVER_BINARY_TARBALL##*/}"
tmp_b="${tmp_b%%.*}"
ARCH="${tmp_b##*_}"
GOCONSERVER_REPACK_TARBALL="goconserver-repack-${ARCH}.tar.gz"
case "${ARCH}" in
"ppc64le")
ARCH="ppc64el"
;;
esac
GOCONSERVER_PREP_TARBALL="goconserver.tar.gz"
EXTRACT_DIR="goconserver-${VERSION:-0.0.1}"
rm -rf "${EXTRACT_DIR}.orig" "${EXTRACT_DIR}"
ln -s -f "${GOCONSERVER_REPACK_TARBALL}" "${GOCONSERVER_PREP_TARBALL}"
alien -d -g -c -k --version=${VERSION:-0.0.1} "${GOCONSERVER_PREP_TARBALL}"
rm -f "${GOCONSERVER_PREP_TARBALL}"
sed -i -e 's/^Copyright: .*$/Copyright: EPL/' \
"${EXTRACT_DIR}/debian/copyright"
sed -i -e 's/^Architecture: .*$/Architecture: '"${ARCH}"'/' \
-e 's/^Maintainer: .*$/Maintainer: GONG Jie <[email protected]>/' \
-e '/^Description:/,$d' \
"${EXTRACT_DIR}/debian/control"
cat <<-EOF >>"${EXTRACT_DIR}/debian/control"
Description: Independent tool to provide terminal session service.
goconserver is written in golang and is a part of microservice of xcat3. It
can work as a independent tool to provide the terminal session service.
Terminal session could run in the background and help logging the terminal
content.
EOF
cat <<-EOF >"${EXTRACT_DIR}/debian/changelog"
goconserver (${VERSION:-0.0.1}-snap$(date '+%Y%m%d%H%M')) experimental; urgency=low
* Converted from .tgz format to .deb by alien version 8.95
-- GONG Jie <[email protected]> $(date -R)
EOF
( cd "${EXTRACT_DIR}" && debian/rules binary )