-
Notifications
You must be signed in to change notification settings - Fork 40
/
ci-linux-build.sh
executable file
·332 lines (311 loc) · 9.62 KB
/
ci-linux-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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#!/bin/bash
#linux build (for github "ubuntu-latest")
#will get dependancies, build and install jaero
#NB will create folders at the same level as the JAERO folder. e.g if you cloned into ~/git/JAERO then you will have the following folders..
#~/git/JFFT
#~/git/JAERO
#~/git/libacars
#~/git/libcorrect
#~/git/libaeroambe
#fail on first error
set -e
#we will need sudo later may as well do a sudo now
if [[ ! $(sudo echo 0) ]]; then exit; fi
sudo apt update
#install dependancies and build tools
if ! apt search qt5-default 2>/dev/null | grep -q qt5-default ; then
echo "cant find qt5-default in repo"
sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
else
echo "found qt5-default in repo"
sudo apt-get install qt5-default
fi
sudo apt-get install cpputest build-essential qtmultimedia5-dev cmake libvorbis-dev libogg-dev libqt5multimedia5-plugins checkinstall libqcustomplot-dev libqt5svg5-dev libzmq3-dev unzip -y
#get script path
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname $SCRIPT)
cd $SCRIPTPATH/..
#qmqtt
FOLDER="qmqtt"
URL="https://github.com/emqx/qmqtt.git"
if [ ! -d "$FOLDER" ] ; then
git clone $URL $FOLDER
cd "$FOLDER"
else
cd "$FOLDER"
git pull $URL
fi
#needed for github actions
git fetch --prune --unshallow --tags || true
git status > /dev/null 2>&1
PACKAGE_VERSION=$(git describe --tags --match 'v*' --dirty 2> /dev/null | tr -d v)
PACKAGE_NAME=qmqtt-dev
MAINTAINER=https://github.com/emqx
PACKAGE_SOURCE=https://github.com/emqx/qmqtt
echo "PACKAGE_NAME="$PACKAGE_NAME
echo "PACKAGE_VERSION="$PACKAGE_VERSION
echo "MAINTAINER="$MAINTAINER
echo "PACKAGE_SOURCE="$PACKAGE_SOURCE
qmake
make
make INSTALL_ROOT=$PWD/release/${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1 install
cd release
cat <<EOT > control
Package: ${PACKAGE_NAME}
Source: ${PACKAGE_SOURCE}
Section: base
Priority: extra
Provides: ${PACKAGE_NAME}
Maintainer: ${MAINTAINER}
Version: ${PACKAGE_VERSION%_*}
License: Eclipse Public License 1.0
Architecture: $(dpkg --print-architecture)
Description: MQTT Client for Qt
EOT
echo "" >> control
mkdir -p ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
cp control ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
dpkg-deb --build ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1
#install the deb package and go back to the main path
sudo apt install ./${PACKAGE_NAME}*.deb -y
sudo ldconfig
cd ../..
#libacars
FOLDER="libacars"
URL="https://github.com/szpajder/libacars"
if [ ! -d "$FOLDER" ] ; then
git clone $URL $FOLDER
cd "$FOLDER"
else
cd "$FOLDER"
git pull $URL
fi
#needed for github actions
git fetch --prune --unshallow --tags || true
git status > /dev/null 2>&1
PACKAGE_VERSION=$(git describe --tags --match 'v*' --dirty 2> /dev/null | tr -d v)
echo "PACKAGE_VERSION="$PACKAGE_VERSION
rm -fr build
mkdir build
cd build
cmake ..
make
sudo checkinstall \
--pkgsource="https://github.com/szpajder/libacars" \
--pkglicense="MIT" \
--maintainer="https://github.com/szpajder" \
--pkgversion="$PACKAGE_VERSION" \
--pkgrelease="1" \
--pkgname=libacars-dev \
--provides=libacars-dev \
--summary="A library for decoding various ACARS message payloads" \
--requires="" \
-y
sudo ldconfig
cd ../..
#libcorrect
FOLDER="libcorrect"
URL="https://github.com/quiet/libcorrect"
if [ ! -d "$FOLDER" ] ; then
git clone $URL $FOLDER
cd "$FOLDER"
else
cd "$FOLDER"
git pull $URL
fi
#needed for github actions
git fetch --prune --unshallow --tags || true
git status > /dev/null 2>&1
PACKAGE_VERSION=1_$(git rev-parse HEAD | cut -c 1-8)
echo "PACKAGE_VERSION="$PACKAGE_VERSION
rm -fr build
mkdir build
cd build
cmake ..
make
sudo checkinstall \
--pkgsource="https://github.com/quiet/libcorrect" \
--pkglicense="BSD-3-Clause License" \
--maintainer="https://github.com/quiet" \
--pkgversion="$PACKAGE_VERSION" \
--pkgrelease="1" \
--pkgname=libcorrect-dev \
--provides=libcorrect-dev \
--summary="C library for Convolutional codes and Reed-Solomon" \
--requires="" \
-y
sudo ldconfig
cd ../..
#JFFT
FOLDER="JFFT"
URL="https://github.com/jontio/JFFT"
if [ ! -d "$FOLDER" ] ; then
git clone $URL $FOLDER
cd "$FOLDER"
else
cd "$FOLDER"
git pull $URL
fi
cd ..
#libaeroambe
FOLDER="libaeroambe"
URL="https://github.com/jontio/libaeroambe"
if [ ! -d "$FOLDER" ] ; then
git clone $URL $FOLDER
cd "$FOLDER"
else
cd "$FOLDER"
git pull $URL
fi
cd mbelib-master
#needed for github actions
git fetch --prune --unshallow --tags || true
git status > /dev/null 2>&1
PACKAGE_VERSION=$(git describe --tags --match 'v*' --dirty 2> /dev/null | tr -d v)
PACKAGE_NAME=libaeroambe-dev
MAINTAINER=nobody
PACKAGE_SOURCE=https://github.com/jontio/libaeroambe
echo "PACKAGE_NAME="$PACKAGE_NAME
echo "PACKAGE_VERSION="$PACKAGE_VERSION
echo "MAINTAINER="$MAINTAINER
echo "PACKAGE_SOURCE="$PACKAGE_SOURCE
#build the old modified libmbe with mini-m patch
rm -fr build
mkdir build
cd build
#need to turn of -fPIC for static linking
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
make
#dont install this as it's an old libmbe clone so instread delete the shared objects and just leave the static one to link with
rm $PWD/*.so*
cd ../../libaeroambe
#change install paths as i'm not sure of the QT define that gets the standard local user install path
sed -i 's/\$\$\[QT_INSTALL_HEADERS\]/\/usr\/local\/include/g' libaeroambe.pro
sed -i 's/\$\$\[QT_INSTALL_LIBS\]/\/usr\/local\/lib\//g' libaeroambe.pro
#add path for the static libmbe.a file
echo 'linux: LIBS += -L$$MBELIB_PATH/build/' >> libaeroambe.pro
echo "" >> libaeroambe.pro
#build the shared library and put it into a deb package
qmake
make
make INSTALL_ROOT=$PWD/release/${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1 install
cd release
cat <<EOT > control
Package: ${PACKAGE_NAME}
Source: ${PACKAGE_SOURCE}
Section: base
Priority: extra
Provides: ${PACKAGE_NAME}
Maintainer: ${MAINTAINER}
Version: ${PACKAGE_VERSION%_*}
License: MIT
Architecture: $(dpkg --print-architecture)
Description: A formal description of a mini-m decoder library
EOT
echo "" >> control
mkdir -p ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
cp control ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
dpkg-deb --build ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1
#install the deb package and go back to the main path
sudo apt install ./${PACKAGE_NAME}*.deb -y
sudo ldconfig
cd ../../..
#basestation
$SCRIPTPATH/ci-create-basestation.sh
#JAERO
cd $SCRIPTPATH
#needed for github actions
git fetch --prune --unshallow --tags || true
git status > /dev/null 2>&1
PACKAGE_VERSION=$(git describe --tags --match 'v*' --dirty 2> /dev/null | tr -d v)
PACKAGE_NAME=jaero
MAINTAINER=https://github.com/jontio
PACKAGE_SOURCE=https://github.com/jontio/JAERO
echo "PACKAGE_NAME="$PACKAGE_NAME
echo "PACKAGE_VERSION="$PACKAGE_VERSION
echo "MAINTAINER="$MAINTAINER
echo "PACKAGE_SOURCE="$PACKAGE_SOURCE
cd JAERO
#run unit tests
#todo error: ‘turnOnNewDeleteOverloads’ is not a member of ‘MemoryLeakWarningPlugin’ happens these days not sure whats happened to this
# maybe it's not needed nowdays. haven't looked into it though
#qmake CONFIG+="CI"
#make
#./JAERO -v
#rm JAERO
#build for release
qmake CONFIG-="CI"
make
make INSTALL_ROOT=$PWD/${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1 install
JAERO_INSTALL_PATH=$(cat JAERO.pro | sed -n -e 's/^INSTALL_PATH[|( ).]= //p')
JAERO_INSTALL_PATH=${JAERO_INSTALL_PATH//$'\r'/}
echo 'JAERO_INSTALL_PATH='${JAERO_INSTALL_PATH}
#add control
cat <<EOT > control
Package: ${PACKAGE_NAME}
Source: ${PACKAGE_SOURCE}
Section: base
Priority: extra
Depends: qtmultimedia5-dev, libvorbis-dev, libogg-dev, libqt5multimedia5-plugins, libqcustomplot-dev, libqt5svg5-dev, libzmq3-dev
Provides: ${PACKAGE_NAME}
Maintainer: ${MAINTAINER}
Version: ${PACKAGE_VERSION%_*}
License: MIT
Architecture: $(dpkg --print-architecture)
Description: Demodulate and decode Aero signals. These signals contain SatCom ACARS messages as used by planes beyond VHF ACARS range
EOT
echo "" >> control
mkdir -p ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
cp control ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/DEBIAN
#add path command
mkdir -p ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/usr/local/bin
cat <<EOT > ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/usr/local/bin/jaero
#!/bin/bash
/opt/jaero/JAERO "\$@"
EOT
chmod +x ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/usr/local/bin/jaero
#basestation if available
if [ -f "../../basestation/basestation.sqb" ]; then
echo "basestation.sqb found. including it in package"
cp ../../basestation/basestation.sqb ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1/opt/jaero/
else
echo "basestation.sqb not found. will be missing from package"
fi
#build and install package
dpkg-deb --build ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1
sudo apt install ./${PACKAGE_NAME}*.deb -y
sudo ldconfig
cd ../..
#package
mkdir -p JAERO/bin
mkdir -p JAERO/bin/jaero
cp JAERO/JAERO/*.deb JAERO/bin/jaero
cp libacars/build/*.deb JAERO/bin/jaero
cp libcorrect/build/*.deb JAERO/bin/jaero
cp libaeroambe/libaeroambe/release/*.deb JAERO/bin/jaero
cp qmqtt/release/*.deb JAERO/bin/jaero
cd JAERO/bin
cat <<EOT > jaero/install.sh
#!/bin/bash
#installs built packages
sudo apt install --reinstall ./*.deb
sudo ldconfig
EOT
chmod +x jaero/install.sh
cat <<EOT > jaero/uninstall.sh
#!/bin/bash
#removes built packages
sudo dpkg --remove qmqtt-dev libacars-dev libcorrect-dev libaeroambe-dev jaero
sudo ldconfig
EOT
chmod +x jaero/uninstall.sh
cat <<EOT > jaero/readme.md
# JAERO ${PACKAGE_VERSION}
### OS: $(lsb_release -d | cut -f 2)
### Build Date: $(date -u)
Cheers,<br>
ci-linux-build.sh
EOT
#compress
tar -czvf ${PACKAGE_NAME}_${PACKAGE_VERSION%_*}-1_linux_$(uname -m).tar.gz jaero
echo "done"