forked from blueprint-freespeech/ricochet-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbm.conf
422 lines (401 loc) · 15.1 KB
/
rbm.conf
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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# vim: filetype=yaml sw=2
debug: '[% GET ! ENV.RBM_NO_DEBUG %]'
compress_tar: gz
output_dir: "out/[% project %]"
tmp_dir: '[% c("basedir") %]/tmp'
build_log: '[% GET ENV.RBM_LOGS_DIR ? ENV.RBM_LOGS_DIR : "logs" %]/[% project %][% IF c("var/osname") %]-[% c("var/osname") %][% END %].log'
pkg_type: build
steps:
src-tarballs:
compress_tar: xz
src-tarballs: |
#!/bin/bash
set -e
mkdir -p '[% dest_dir %]'
mv -vf '[% project %]-[% c("version") %].tar.xz' '[% dest_dir %]/[% c("filename") %]'
# buildconf contains build options that the user can change in rbm.local.conf
# When adding a new option to buildconf, a default value should be defined
# in var/build_id, so that changing this option does not affect the build_id.
buildconf:
num_procs: '[% GET ENV.RBM_NUM_PROCS ? ENV.RBM_NUM_PROCS : "4" %]'
git_signtag_opt: '-s'
var:
# version must be in the form D.D.D, major.minor.buildNumber
# each digit must be able to fit within a 16 bit unsigned int, as this value is converted into
# the FILEVERSION field in the .rc file for Windows
# see: https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
# see: https://stackoverflow.com/questions/43261649/how-do-i-set-my-application-version-for-windows-in-qt
tego_version: '3.0.8'
multi_lingual: 0
build_mar: 1
# By default, we sort the list of installed packages. This allows sharing
# containers with identical list of packages, even if they are not listed
# in the same order. In the cases where the installation order is
# important, sort_deps should be set to 0.
sort_deps: 1
build_id: '[% sha256(c("var/build_id_txt", { buildconf => { num_procs => 4 } })).substr(0, 6) %]'
build_id_txt: |
[% c("version") %]
[% IF c("git_hash") || c("hg_hash"); GET c("abbrev"); END; %]
[% IF c("var/container/use_container") && ! c("var/container/global_disable") -%]
[% c("var/container/suite") %]
[% c("var/container/arch") %]
[% END -%]
input_files: [% c("input_files_id") %]
build:
[% SET step = c("step") -%]
[% c(step, { filename => 'f', output_dir => '/out', norec => {} }) %]
container:
dir: '[% c("rbm_tmp_dir") %]/rbm-containers/[% sha256(c("build_id")) %]'
user: rbm
disable_network:
# disable network in the build scripts
build: 1
input_files_list: |
[% FOREACH file IN c("input_files_by_name").keys.sort -%]
[% c("input_files_by_name/" _ file) %]
[% END -%]
faketime: "faketime -f \"[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]\""
touch: "[% USE date %]touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %]"
rezip: |
rezip_tmpdir=$(mktemp -d)
mkdir -p "$rezip_tmpdir/z"
unzip -d "$rezip_tmpdir/z" -- [% c("rezip_file") %] || [ $? -lt 3 ]
pushd "$rezip_tmpdir/z"
[% c("zip", {
zip_src => [ '.' ],
zip_args => '$rezip_tmpdir/new.zip',
}) %]
popd
mv -f -- "$rezip_tmpdir/new.zip" [% c("rezip_file") %]
rm -Rf "$rezip_tmpdir"
set_default_env: |
set -e
[% FOREACH env = c('ENV') -%]
export [% env.key %]="[% env.value %]"
[% END -%]
rootdir=$(pwd)
export SHELL=/bin/bash
export HOME=$rootdir
umask 0022
[% IF c("var/container/global_disable") -%]
rm -Rf /var/tmp/build /var/tmp/dist
[% END -%]
DOCSDIR_project: '[% project %]'
set_PTDIR_DOCSDIR: |
PTDIR="$distdir/TorBrowser/Tor/PluggableTransports"
DOCSDIR="$distdir/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
targets:
notarget: linux-x86_64
noint:
debug: 0
release:
var:
release: 1
channel: release
nightly:
fetch: 1
var:
nightly: 1
channel: nightly
# The common-buster target is used to build components that are common to all
# platforms, using Debian Buster.
common-buster:
var:
common: 1
container:
suite: buster
arch: amd64
pre_pkginst: ''
deps:
- build-essential
- python
- automake
- libtool
- zip
- unzip
tego-linux-x86_64:
- linux-x86_64
- linux
tego-linux-i686:
- linux-i686
- linux
linux-x86_64:
arch: x86_64
var:
linux-x86_64: 1
osname: linux-x86_64
CFLAGS: -fPIC
CXXFLAGS: -fPIC
LDFLAGS:
configure_opt: 'CFLAGS="[% c("var/CFLAGS") %]" CXXFLAGS="[% c("var/CXXFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]" [% c("var/configure_opt_project") %]'
linux-i686:
arch: i686
var:
linux-i686: 1
osname: linux-i686
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
configure_opt: '--host=i686-linux-gnu CFLAGS="[% c("var/CFLAGS") %]" CXXFLAGS="[% c("var/CXXFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]" [% c("var/configure_opt_project") %]'
linux:
var:
linux: 1
compiler: gcc
configure_opt: '[% c("var/configure_opt_project") %]'
container:
suite: buster
arch: amd64
pre_pkginst: dpkg --add-architecture i386
deps:
- libc6-dev-i386
- lib32stdc++6
- build-essential
- python
- bison
- automake
- libtool
- zip
- unzip
tego-windows-i686:
- windows-i686
- windows
tego-windows-x86_64:
- windows-x86_64
- windows
windows-x86_64:
arch: x86_64
var:
windows-x86_64: 1
windows-i686: 0
osname: windows-x86_64
# HEASLR is 64 bit only (see bug 12968)
flag_HEASLR: '-Wl,--high-entropy-va'
windows-i686:
arch: i686
var:
windows-i686: 1
windows-x86_64: 0
osname: windows-i686
# mingw-w64 does not support SEH on 32bit systems. Be explicit about that.
flag_noSEH: '-Wl,--no-seh'
windows:
var:
windows: 1
container:
suite: buster
arch: amd64
configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]" [% c("var/configure_opt_project") %]'
# CFLAGS: '-fstack-protector-strong -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security [% c("var/flag_mwindows") %]'
# LDFLAGS: '-Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -Wl,--no-insert-timestamp -lssp -L$gcclibs [% c("var/flag_HEASLR") %] [% c("var/flag_mwindows") %]
CFLAGS: ''
LDFLAGS: '-Wl,-allow-multiple-definition'
flag_mwindows: '-mwindows'
compiler: mingw-w64
faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
deps:
- build-essential
- python
- bison
- automake
- libtool
- zip
- unzip
tego-osx-x86_64:
- osx-x86_64
osx-x86_64:
arch: x86_64
var:
osx: 1
osname: osx-x86_64
container:
suite: buster
arch: amd64
compiler: 'macosx-toolchain'
# need to specify paths to clang and clang++ directly or else the ln -s versions can't find their headers?
configure_opt: '--host=x86_64-apple-darwin CC="$clangdir/bin/clang [% c("var/FLAGS") %]" CXX="$clangdir/bin/clang++ [% c("var/FLAGS") %]" [% c("var/configure_opt_project") %]'
FLAGS: "-target x86_64-apple-darwin -B $cctoolsdir -isysroot $sysrootdir"
CFLAGS: "-B $cctoolsdir -isysroot $sysrootdir"
CXXFLAGS: "-B $cctoolsdir -isysroot $sysrootdir"
LDFLAGS: "-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie"
macosx_deployment_target: '10.13'
deps:
- build-essential
- python
- automake
- libtool
- zip
- unzip
faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
set_PTDIR_DOCSDIR: |
PTDIR="$distdir/Contents/MacOS/Tor/PluggableTransports"
DOCSDIR="$distdir/Contents/Resources/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
# The no_build_id target can be useful if you want to quickly display
# a build template or other option but don't want to spend time to
# compute the various build ids
no_build_id:
# The defaut timestamp value will use the commit time of the
# selected commit for the project, which will require cloning the
# git repository if it is not present. When we use the no_build_id
# target to display a script, we usually don't care about such
# details, so we set timestamp to 0 to avoid unnecessary cloning.
timestamp: 0
var:
build_id: 1
no_containers:
var:
container:
global_disable: 1
# change the default gpg_wrapper to allow git tag signed using an
# expired key.
# https://bugs.torproject.org/19737
gpg_wrapper: |
#!/bin/bash
export LC_ALL=C
[%
IF c('gpg_keyring');
SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
END;
-%]
gpg_verify=0
for opt in "$@"
do
test "$opt" = '--verify' && gpg_verify=1
done
if [ $gpg_verify = 1 ]
then
[% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
exit ${PIPESTATUS[0]}
else
exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
fi
remote_start: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_start") %][% END %]'
remote_exec: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_exec") %][% END %]'
remote_put: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_put") %][% END %]'
remote_get: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_get") %][% END %]'
remote_finish: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_finish") %][% END %]'
runc:
remote_start: |
#!/bin/sh
set -e
if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
then
echo "Can't find container image in input files" >&2
ls -l '[% c("remote_srcdir") %]' >&2
exit 1
fi
mkdir -p '[% c("var/container/dir") %]'/rootfs/rbm
sudo tar -C '[% c("var/container/dir") %]'/rootfs -xf $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'*)
[% SET user = c("var/container/user") -%]
[% c("remote_exec", { exec_as_root => 1, exec_cmd => 'id ' _ user
_ ' >/dev/null 2>&1 || adduser -m ' _ user _ ' || useradd -m ' _ user }) %]
remote_exec: |
#!/bin/sh
set -e
[% IF c("interactive") -%]
echo Container directory: [% shell_quote(c("var/container/dir")) %]
[% END -%]
mkdir -p '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/rbm
echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/cmd
echo [% shell_quote(c('exec_cmd')) %] >> '[% c("var/container/dir") %]'/rootfs/rbm/cmd
echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/run
[% IF c('exec_as_root'); SET user = 'root'; ELSE; SET user = c("var/container/user", { error_if_undef => 1 }); END; %]
echo 'su - [% user %] -c /rbm/cmd' >> '[% c("var/container/dir") %]'/rootfs/rbm/run
chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/cmd
chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/run
cat > '[% c("var/container/dir") %]'/config.json << EOF
[% INCLUDE 'runc-config.json' %]
EOF
[% IF c("var/container/disable_network/" _ c("exec_name")) -%]
sudo ip netns add 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
# make sure the lo interface is up (see bug 31293)
sudo ip netns exec 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]' ip link set lo up
[% END -%]
sudo runc [% IF c("var_p/runc100") %]run[% ELSE %]start[% END %] -b '[% c("var/container/dir") %]' rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %] [% IF c("runc_hide_stderr") %]2>/dev/null[% END %]
[% IF c("var/container/disable_network/" _ c("exec_name")) -%]
sudo ip netns delete 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
[% END -%]
remote_put: |
#!/bin/sh
set -e
[%
SET src = shell_quote(c('put_src', { error_if_undef => 1 }));
SET dst = shell_quote(c('put_dst', { error_if_undef => 1 }));
-%]
sudo mkdir -p '[% c("var/container/dir") %]'/rootfs/[% dst %]
sudo cp -aP [% src %] '[% c("var/container/dir") %]'/rootfs/[% dst %]
# On Ubuntu, the /root/.profile file contains a `mesg n` line which is
# producing some `stdin: is not a tty` messages. To hide them, we hide
# stderr from this part by setting runc_hide_stderr.
[% c("remote_exec", { exec_as_root => 1, exec_cmd => 'chown -R ' _ c("var/container/user") _ ' ' _ dst, runc_hide_stderr => 1 }) %]
remote_get: |
#!/bin/sh
set -e
[%
SET src = shell_quote(c('get_src', { error_if_undef => 1 }));
SET dst = shell_quote(c('get_dst', { error_if_undef => 1 }));
-%]
mkdir -p [% dst %]
srcdir='[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/[% src %]
sudo chown -R $(whoami) "$srcdir"
if [ $(ls -1 "$srcdir"/* 2> /dev/null | wc -l) -gt 0 ]
then
for file in "$srcdir"/*
do
bname="$(basename "$file")"
test -e [% dst %]/"$bname" && rm -Rf [% dst %]/"$bname"
mv -f "$file" [% dst %]/
done
fi
remote_finish: |
#!/bin/sh
set -e
sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
rmdir '[% c("var/container/dir") %]'
ENV:
TZ: UTC
LC_ALL: C
--- |
# This part of the file contains options written in perl
use IO::CaptureOutput qw(capture_exec);
(
var_p => {
# runc100 is true if we are using runc >= 1.0.0
# we assume that any version that is not 0.1.1 is >= 1.0.0
runc100 => sub {
my ($out) = capture_exec('sudo', 'runc', '--version');
return !($out =~ m/^runc version 0.1.1/);
},
# runc_spec100 is true if runc spec is at least 1.0.0
# We will need to update this when there is a new spec version available
runc_spec100 => sub {
my ($out) = capture_exec('sudo', 'runc', '--version');
return $out =~ m/^.*spec: 1\.[0-9]+\.[0-9]+(?:-dev)?$/m;
},
nightly_torbrowser_version => sub {
state $version = '';
return $version if $version;
my (undef, undef, undef, $day, $mon, $year) = gmtime;
$version = sprintf("tbb-nightly.%u.%02u.%02u", $year + 1900, $mon + 1, $day);
return $version;
},
nightly_torbrowser_incremental_from => sub {
my ($project, $options) = @_;
my $nightly_dir = project_config($project, 'basedir', $options) . '/nightly';
my $current_version = project_config($project, 'var/torbrowser_version', $options);
use Path::Tiny;
return [] unless -d $nightly_dir;
my @dirs = sort map { $_->basename } path($nightly_dir)->children(qr/^tbb-nightly\./);
my $nb_incr = project_config($project, ['var', 'max_torbrowser_incremental_from'], $options);
my @res;
while ($nb_incr > 0) {
my $dir = pop @dirs;
last unless $dir;
next if $dir eq $current_version;
$nb_incr--;
push @res, $dir;
}
return [@res];
},
},
)