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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
#!/usr/bin/env bash
# Copyright © 2015-2016 Collabora Ltd.
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -euo pipefail
set -x
NULL=
# ci_distro:
# OS distribution in which we are testing
# Typical values: auto, ubuntu, debian, ; maybe fedora in future
: "${ci_distro:=auto}"
# ci_host:
# Either "native", or an Autoconf --host argument to cross-compile
# the package
: "${ci_host:=native}"
# ci_in_docker:
# "yes" if we are running inside a Docker image.
: "${ci_in_docker:=no}"
# ci_local_packages:
# prefer local packages instead of distribution
: "${ci_local_packages:=yes}"
# ci_suite:
# OS suite (release, branch) in which we are testing.
# Typical values: auto (detect at runtime), ci_distro=debian: bullseye, buster, ci_distro=fedora: 35, rawhide
: "${ci_suite:=auto}"
# ci_variant:
# One of debug, reduced, legacy, production
: "${ci_variant:=production}"
# print used command line
set +x; env | awk 'BEGIN { s = "" } $1 ~ /^ci_/ { s=s " " $0} END { print s " " SCRIPT }' SCRIPT=$0; set -x
if [ $(id -u) = 0 ]; then
sudo=
else
sudo=sudo
fi
# choose distribution
if [ "$ci_distro" = "auto" ]; then
ci_distro=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
echo "detected ci_distro as '${ci_distro}'"
fi
# choose suite
if [ "$ci_suite" = "auto" ]; then
ci_suite=$(. /etc/os-release; if test -v VERSION_CODENAME; then echo ${VERSION_CODENAME}; else echo ${VERSION_ID}; fi)
echo "detected ci_suite as '${ci_suite}'"
fi
case "$ci_distro" in
(debian*|ubuntu*)
# Don't ask questions, just do it
sudo="$sudo env DEBIAN_FRONTEND=noninteractive"
# Debian Docker images use httpredir.debian.org but it seems to be
# unreliable; use a CDN instead
$sudo sed -i -e 's/httpredir\.debian\.org/deb.debian.org/g' \
/etc/apt/sources.list
case "$ci_host" in
(i686-w64-mingw32)
$sudo dpkg --add-architecture i386
;;
(x86_64-w64-mingw32)
# assume the host or container is x86_64 already
;;
esac
$sudo apt-get -qq -y update
packages=()
case "$ci_host" in
(i686-w64-mingw32)
packages=(
"${packages[@]}"
binutils-mingw-w64-i686
g++-mingw-w64-i686
wine32 wine
)
;;
(x86_64-w64-mingw32)
packages=(
"${packages[@]}"
binutils-mingw-w64-x86-64
g++-mingw-w64-x86-64
wine64 wine
)
;;
esac
if [ "$ci_host/$ci_variant/$ci_suite" = "native/production/buster" ]; then
packages=(
"${packages[@]}"
qttools5-dev-tools
qt5-default
)
fi
packages=(
"${packages[@]}"
adduser
ca-certificates
ccache
clang
cmake
debhelper
dh-autoreconf
dh-exec
docbook-xml
docbook-xsl
doxygen
dpkg-dev
ducktype
g++
gcc
git
gnome-desktop-testing
libapparmor-dev
libaudit-dev
libcap-ng-dev
libexpat-dev
libglib2.0-dev
libselinux1-dev
libsystemd-dev
libx11-dev
llvm
meson
ninja-build
sudo
valgrind
wget
xauth
xmlto
xsltproc
xvfb
yelp-tools
zstd
)
$sudo apt-get -qq -y --no-install-recommends install "${packages[@]}"
if [ "$ci_in_docker" = yes ]; then
# Add the user that we will use to do the build inside the
# Docker container, and let them use sudo
if ! getent passwd user > /dev/null; then
adduser --disabled-password --gecos "" user
fi
echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
chmod 0440 /etc/sudoers.d/nopasswd
fi
;;
(opensuse*)
zypper="/usr/bin/zypper --non-interactive"
# system
packages=(
sudo
)
# build system
packages=(
"${packages[@]}"
cmake
meson
)
# docs
packages=(
"${packages[@]}"
docbook_4
docbook-xsl-stylesheets
doxygen
libqt5-qttools
libxslt-tools
yelp-tools
)
# dbus (autogen.sh)
packages=(
"${packages[@]}"
which
)
# choose distribution
id=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
case "$id" in
(opensuse-leap)
version=$(. /etc/os-release; echo ${VERSION_ID} | sed 's, ,_,g')
repo="openSUSE_Leap_$version"
# Use a newer CMake (3.21) version for JUnit XML support on openSUSE Leap.
if ! zypper lr cmake > /dev/null; then
$zypper ar --refresh --no-gpgcheck --name cmake \
"https://download.opensuse.org/repositories/devel:tools:building/$version/devel:tools:building.repo"
fi
;;
(opensuse-tumbleweed)
repo="openSUSE_Tumbleweed"
;;
(*)
echo "ci_suite not specified, please choose one from 'leap' or 'tumbleweed'"
exit 1
;;
esac
case "$ci_host" in
(*-w64-mingw32)
# cross
packages=(
"${packages[@]}"
wine
xvfb-run
)
# add required repos
if [ "${ci_host%%-*}" = x86_64 ]; then
bits="64"
else
bits="32"
fi
(
p=$(zypper lr | grep "windows_mingw_win${bits}" || true)
if [ -z "$p" ]; then
$zypper ar --refresh --no-gpgcheck \
"https://download.opensuse.org/repositories/windows:/mingw/$repo/windows:mingw.repo"
$zypper ar --refresh --no-gpgcheck \
"https://download.opensuse.org/repositories/windows:/mingw:/win${bits}/$repo/windows:mingw:win${bits}.repo"
fi
)
packages=(
"${packages[@]}"
mingw${bits}-cross-cmake
mingw${bits}-cross-gcc-c++
mingw${bits}-cross-meson
mingw${bits}-cross-pkgconf
mingw${bits}-glib2-devel
mingw${bits}-libexpat-devel
)
;;
(*)
packages=(
"${packages[@]}"
gcc-c++
glib2-devel
libX11-devel
libexpat-devel
systemd-devel
)
;;
esac
$zypper install --allow-vendor-change "${packages[@]}"
if [ "$ci_in_docker" = yes ]; then
# Add the user that we will use to do the build inside the
# Docker container, and let them use sudo
if ! getent passwd user >/dev/null; then
useradd -m user
passwd -ud user
fi
echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
chmod 0440 /etc/sudoers.d/nopasswd
fi
;;
(freebsd*)
$sudo pkg update
$sudo pkg upgrade -y
packages=(
bash
cmake
docbook-xml
docbook-xsl
expat
glib
git
gmake
libX11
libxslt
meson
ninja
pkgconf
python3
xmlto
)
$sudo pkg install -y "${packages[@]}"
;;
esac
#
# manual package setup
#
case "$ci_distro" in
(debian*|ubuntu*)
# Make sure we have a messagebus user, even if the dbus package
# isn't installed
$sudo adduser --system --quiet --home /nonexistent --no-create-home \
--disabled-password --group messagebus
;;
(opensuse*)
# test-bus depends on group 'bin'
$sudo getent group bin >/dev/null || /usr/sbin/groupadd -r bin
# Make sure we have a messagebus user, even if the dbus package
# isn't installed
getent group messagebus >/dev/null || /usr/sbin/groupadd -r messagebus
getent passwd messagebus >/dev/null || /usr/sbin/useradd -r -s /usr/bin/false -c "User for D-Bus" -d /run/dbus -g messagebus messagebus
;;
(freebsd*)
# Make sure we have a messagebus user, even if the dbus package
# isn't installed (using the same UID/GID as the dbus package).
pw groupshow messagebus || $sudo pw groupadd -n messagebus -g 556
pw usershow messagebus || $sudo pw useradd -n messagebus -u 556 -c "D-BUS Daemon User" -d /nonexistent -s /usr/sbin/nologin -g 556
;;
(*)
echo "Don't know how to set up ${ci_distro}" >&2
exit 1
;;
esac
if [ "$ci_local_packages" = yes ]; then
case "$ci_host" in
(*-w64-mingw32)
cpu="${ci_host%%-*}"
mirror="https://repo.msys2.org/mingw/$cpu"
dep_prefix=$(pwd)/${ci_host}-prefix
# clean install dir, if present
rm -rf ${dep_prefix}
install -d "${dep_prefix}"
wget -O files.lst ${mirror}
sed 's,^<a href=",,g;s,">.*$,,g' files.lst | grep -v "\.db" | grep -v "\.files" | grep ".*zst$" | sort > filenames.lst
packages=(
bzip2
expat
gcc-libs
gettext
glib2
iconv
libffi
libiconv
libwinpthread-git
pcre
pcre2
zlib
)
for pkg in "${packages[@]}" ; do
filename=$(grep -F "mingw-w64-${cpu}-${pkg}-" filenames.lst | tail -1)
if [ -z ${filename} ]; then
echo "could not find filename for package '${pkg}'"
exit 1
fi
# Remove previously downloaded file, which can happen
# when run locally
if [ -f ${filename} ]; then
rm -rf ${filename}
fi
wget ${mirror}/${filename}
tar -C ${dep_prefix} --strip-components=1 -xvf ${filename}
done
;;
esac
fi
# vim:set sw=4 sts=4 et:
|