-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-deb
executable file
·216 lines (159 loc) · 3.75 KB
/
create-deb
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#! /usr/bin/env mulle-bash
[ "${TRACE}" = 'YES' ] && set -x && : "$0" "$@"
SSHFLAGS="${SSHFLAGS:--q -t}"
# this script is run on the VM host
VM="buster"
if [ $# -ne 0 ]
then
VM="$1"
shift
fi
VERSION="${VERSION:-17.0.6.0}"
case "$RC" in
RC*)
RC="-$RC"
;;
[0-9]*)
RC="-RC$RC"
;;
*)
RC=
;;
esac
# https://stackoverflow.com/questions/37453525/how-can-i-check-specific-server-running-or-notusing-virsh-commands-before-i-s
is_vm_running()
{
local vm="$1"
local tmp
tmp=$(virsh list --all | grep " ${vm} " | awk '{ print $3}')
if [ "x$tmp" == "x" ] || [ "x$tmp" != "xrunning" ]
then
return 1
fi
return 0
}
start()
{
local vm="$1"
local user="$2"
if is_vm_running "${vm}"
then
return
fi
virsh net-start default 2> /dev/null
while ! is_vm_running "${vm}"
do
sleep 1
virsh start "${vm}" && break
done
while ! ssh "${user}@${vm}" true > /dev/null 2>&1
do
sleep 1
done
}
prepare()
{
local vm="$1"
local user="$2"
local version="$3"
local rc="$4"
local preparescript
preparescript="\
( [ -d mulle-clang-cpack ] || git clone 'https://github.com/mulle-cc/mulle-clang-cpack.git' ) &&
( cd mulle-clang-cpack && git pull ) &&
( cd mulle-clang-cpack && git checkout mulle/${version%\.*} )
"
ssh ${SSHFLAGS} "${user}@${vm}" "${preparescript}" || exit 1
local buildscript
buildscript="VERSION=\"${version}\" RC=\"${rc}\" ./mulle-clang-cpack/package-build clean download"
ssh ${SSHFLAGS} "${user}@${vm}" "${buildscript}" || exit 1
}
build()
{
local vm="$1"
local user="$2"
local version="$3"
local rc="$4"
local buildscript
buildscript="MAKETOOL=\"${MAKETOOL}\" \
VERSION=\"${version}\" \
RC="${rc}" \
./mulle-clang-cpack/package-build build"
ssh ${SSHFLAGS} "${user}@${vm}" "${buildscript}" || exit 1
}
verpack()
{
local vm="$1"
local user="$2"
local version="$3"
local rc="$4"
local buildscript
buildscript="MAKETOOL=\"${MAKETOOL}\" \
VERSION=\"${version}\" \
RC="${rc}" \
./mulle-clang-cpack/package-build verpack"
ssh ${SSHFLAGS} "${user}@${vm}" "${buildscript}" || exit 1
}
download()
{
local vm="$1"
local user="$2"
local version="$3"
local rc="$4"
local dist
dist="$( ssh ${SSHFLAGS} "${user}@${vm}" "lsb_release -sc" )" || exit 1
# not sure who gives me a \r here
dist="`tr -d '\015' <<< "${dist}" `"
local filename
local debname
debname="main"
case "${version}" in
*-*)
debname="${version#*-}"
version="${version%-*}"
;;
esac
local srcfilename
srcfilename="mulle-clang-${version}${rc}-${dist}-amd64.deb"
filename="mulle-clang-${version}${rc}-${dist}-amd64.deb"
scp "${user}@${vm}:${srcfilename}" "${filename}"
}
upload()
{
local vm="$1"
local user="$2"
local version="$3"
local rc="$4"
local dist
dist="$( ssh ${SSHFLAGS} "${user}@${vm}" "lsb_release -sc" )" || exit 1
# not sure who gives me a \r here
dist="`tr -d '\015' <<< "${dist}" `"
local filename
local debname
debname="main"
case "${version}" in
*-*)
debname="${version#*-}"
version="${version%-*}"
;;
esac
filename="mulle-clang-${version}${rc}-${dist}-amd64.deb"
ssh ${SSHFLAGS} "oswald" mkdir -p "debian-software/dists/${dist}/${debname}/binary-amd64" || exit 1
scp "${filename}" "oswald:debian-software/dists/${dist}/${debname}/binary-amd64/"
# ssh oswald "cd debian-software && ./update.sh && ./upload.sh"
}
main()
{
while [ $# -ne 0 ]
do
echo "////// $1 \\\\\\\\\\\\" >&2
"$1" "${VM}" "${USER}" "${VERSION}" "${RC}" || exit 1
shift
done
}
if [ $# -eq 0 ]
then
main start prepare build verpack download upload
else
main "$@"
fi