rbm.conf 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. # vim: filetype=yaml sw=2
  2. debug: '[% GET ! ENV.RBM_NO_DEBUG %]'
  3. compress_tar: gz
  4. output_dir: "out/[% project %]"
  5. tmp_dir: '[% c("basedir") %]/tmp'
  6. build_log: '[% GET ENV.RBM_LOGS_DIR ? ENV.RBM_LOGS_DIR : "logs" %]/[% project %][% IF c("var/osname") %]-[% c("var/osname") %][% END %].log'
  7. pkg_type: build
  8. steps:
  9. src-tarballs:
  10. compress_tar: xz
  11. src-tarballs: |
  12. #!/bin/bash
  13. set -e
  14. mkdir -p '[% dest_dir %]'
  15. mv -vf '[% project %]-[% c("version") %].tar.xz' '[% dest_dir %]/[% c("filename") %]'
  16. # buildconf contains build options that the user can change in rbm.local.conf
  17. # When adding a new option to buildconf, a default value should be defined
  18. # in var/build_id, so that changing this option does not affect the build_id.
  19. buildconf:
  20. num_procs: '[% GET ENV.RBM_NUM_PROCS ? ENV.RBM_NUM_PROCS : "4" %]'
  21. git_signtag_opt: '-s'
  22. var:
  23. torbrowser_version: '9.0a5'
  24. torbrowser_build: 'build1'
  25. torbrowser_incremental_from:
  26. - 9.0a3
  27. project_name: tor-browser
  28. multi_lingual: 0
  29. build_mar: 1
  30. # By default, we sort the list of installed packages. This allows sharing
  31. # containers with identical list of packages, even if they are not listed
  32. # in the same order. In the cases where the installation order is
  33. # important, sort_deps should be set to 0.
  34. sort_deps: 1
  35. build_id: '[% sha256(c("var/build_id_txt", { buildconf => { num_procs => 4 } })).substr(0, 6) %]'
  36. build_id_txt: |
  37. [% c("version") %]
  38. [% IF c("git_hash") || c("hg_hash"); GET c("abbrev"); END; %]
  39. [% IF c("var/container/use_container") && ! c("var/container/global_disable") -%]
  40. [% c("var/container/suite") %]
  41. [% c("var/container/arch") %]
  42. [% END -%]
  43. input_files: [% c("input_files_id") %]
  44. build:
  45. [% c("build", { filename => 'f', output_dir => '/out' }) %]
  46. container:
  47. dir: '[% c("rbm_tmp_dir") %]/rbm-containers/[% sha256(c("build_id")) %]'
  48. user: rbm
  49. disable_network:
  50. # disable network in the build scripts
  51. build: 1
  52. input_files_list: |
  53. [% FOREACH file IN c("input_files_by_name").keys.sort -%]
  54. [% c("input_files_by_name/" _ file) %]
  55. [% END -%]
  56. faketime: "faketime -f \"[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]\""
  57. touch: "[% USE date %]touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %]"
  58. locale_ja: ja
  59. locales:
  60. - ar
  61. - ca
  62. - cs
  63. - da
  64. - de
  65. - el
  66. - es-AR
  67. - es-ES
  68. - fa
  69. - fr
  70. - ga-IE
  71. - he
  72. - hu
  73. - id
  74. - is
  75. - it
  76. - '[% c("var/locale_ja") %]'
  77. - ka
  78. - ko
  79. - mk
  80. - nb-NO
  81. - nl
  82. - pl
  83. - pt-BR
  84. - ro
  85. - ru
  86. - sv-SE
  87. - tr
  88. - vi
  89. - zh-CN
  90. - zh-TW
  91. sign_build: '[% ENV.RBM_SIGN_BUILD %]'
  92. sign_build_gpg_opts: '[% ENV.RBM_GPG_OPTS %]'
  93. rezip: |
  94. rezip_tmpdir=$(mktemp -d)
  95. mkdir -p "$rezip_tmpdir/z"
  96. unzip -d "$rezip_tmpdir/z" -- [% c("rezip_file") %] || [ $? -lt 3 ]
  97. pushd "$rezip_tmpdir/z"
  98. [% c("zip", {
  99. zip_src => [ '.' ],
  100. zip_args => '$rezip_tmpdir/new.zip',
  101. }) %]
  102. popd
  103. mv -f -- "$rezip_tmpdir/new.zip" [% c("rezip_file") %]
  104. rm -Rf "$rezip_tmpdir"
  105. set_default_env: |
  106. set -e
  107. [% FOREACH env = c('ENV') -%]
  108. export [% env.key %]="[% env.value %]"
  109. [% END -%]
  110. rootdir=$(pwd)
  111. export SHELL=/bin/bash
  112. export HOME=$rootdir
  113. umask 0022
  114. [% IF c("var/container/global_disable") -%]
  115. rm -Rf /var/tmp/build /var/tmp/dist
  116. [% END -%]
  117. DOCSDIR_project: '[% project %]'
  118. set_PTDIR_DOCSDIR: |
  119. PTDIR="$distdir/TorBrowser/Tor/PluggableTransports"
  120. DOCSDIR="$distdir/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  121. targets:
  122. notarget: linux-x86_64
  123. noint:
  124. debug: 0
  125. release:
  126. var:
  127. release: 1
  128. channel: release
  129. alpha:
  130. var:
  131. alpha: 1
  132. channel: alpha
  133. nightly:
  134. fetch: 1
  135. var:
  136. nightly: 1
  137. channel: nightly
  138. torbrowser_version: tbb-nightly
  139. torbrowser-testbuild:
  140. - testbuild
  141. - alpha
  142. testbuild:
  143. var:
  144. testbuild: 1
  145. # Don't create mar files to save time
  146. build_mar: 0
  147. # The common-stretch target is used to build components that are common to all
  148. # platforms, using Debian stretch.
  149. common-stretch:
  150. var:
  151. common: 1
  152. container:
  153. suite: stretch
  154. arch: amd64
  155. pre_pkginst: ''
  156. deps:
  157. - build-essential
  158. - python
  159. - automake
  160. - libtool
  161. - zip
  162. - unzip
  163. torbrowser-android-armv7:
  164. - android-armv7
  165. - android
  166. android-armv7:
  167. arch: armv7
  168. var:
  169. android-armv7: 1
  170. osname: android-armv7
  171. torbrowser-android-x86:
  172. - android-x86
  173. - android
  174. android-x86:
  175. arch: x86
  176. var:
  177. android-x86: 1
  178. osname: android-x86
  179. torbrowser-android-aarch64:
  180. - android-aarch64
  181. - android
  182. android-aarch64:
  183. arch: aarch64
  184. var:
  185. android-aarch64: 1
  186. osname: android-aarch64
  187. android:
  188. var:
  189. android: 1
  190. compiler: android-toolchain
  191. # API 16 is the minimum we currently support for Tor Browser on Android
  192. android_min_api: '[% GET c("var/android_min_api_" _ c("arch")) %]'
  193. # API 21 is the minimum we currently support for arm64 on Android
  194. android_min_api_aarch64: 21
  195. android_min_api_armv7: 16
  196. android_min_api_x86: 16
  197. snowflake: 0
  198. container:
  199. suite: stretch
  200. arch: amd64
  201. deps:
  202. - build-essential
  203. - python
  204. - automake
  205. - libtool
  206. - zip
  207. - unzip
  208. torbrowser-linux-x86_64:
  209. - linux-x86_64
  210. - linux
  211. torbrowser-linux-x86_64-debug:
  212. - linux-debug
  213. - linux-x86_64
  214. - linux
  215. torbrowser-linux-i686:
  216. - linux-i686
  217. - linux
  218. torbrowser-linux-arm:
  219. - linux-arm
  220. - linux-cross
  221. - linux
  222. linux-x86_64:
  223. arch: x86_64
  224. var:
  225. linux-x86_64: 1
  226. osname: linux-x86_64
  227. linux-cross: 0
  228. arch_debian: amd64
  229. linux-i686:
  230. arch: i686
  231. var:
  232. linux-i686: 1
  233. osname: linux-i686
  234. linux-cross: 0
  235. configure_opt_i686: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32'
  236. configure_opt: '[% c("var/configure_opt_i686") %]'
  237. arch_debian: i386
  238. linux-arm:
  239. arch: arm
  240. var:
  241. linux-arm: 1
  242. osname: linux-arm
  243. crosstarget: arm-linux-gnueabihf
  244. configure_opt: '--host=arm-linux-gnueabihf'
  245. arch_debian: armhf
  246. linux-cross:
  247. var:
  248. linux-cross: 1
  249. container:
  250. arch: amd64
  251. # TODO: Maybe re-enable snowflake on linux-cross later?
  252. snowflake: 0
  253. # TODO: Maybe re-enable fteproxy on linux-cross later?
  254. fteproxy: 0
  255. linux:
  256. var:
  257. linux: 1
  258. compiler: gcc
  259. # We only build snowflake for linux and macOS on the alpha and nightly
  260. # channels for now.
  261. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  262. container:
  263. suite: wheezy
  264. arch: amd64
  265. pre_pkginst: dpkg --add-architecture i386
  266. deps:
  267. - libc6-dev-i386
  268. - lib32stdc++6
  269. - build-essential
  270. - python
  271. - bison
  272. - hardening-wrapper
  273. - automake
  274. - libtool
  275. - zip
  276. - unzip
  277. linux-debug:
  278. var:
  279. asan: 1
  280. torbrowser-windows-i686:
  281. - windows-i686
  282. - windows
  283. torbrowser-windows-x86_64:
  284. - windows-x86_64
  285. - windows
  286. windows-x86_64:
  287. arch: x86_64
  288. var:
  289. windows-x86_64: 1
  290. osname: windows-x86_64
  291. container:
  292. arch: amd64
  293. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  294. # HEASLR is 64 bit only (see bug 12968)
  295. flag_HEASLR: '-Wl,--high-entropy-va'
  296. windows-i686:
  297. arch: i686
  298. var:
  299. windows-i686: 1
  300. osname: windows-i686
  301. container:
  302. arch: i386
  303. faketime_path: /usr/lib/i386-linux-gnu/faketime/libfaketime.so.1
  304. setarch: |
  305. if test -z "$RBM_SETARCH"
  306. then
  307. export RBM_SETARCH=1
  308. exec setarch i686 ./build
  309. fi
  310. windows:
  311. var:
  312. windows: 1
  313. container:
  314. suite: stretch
  315. configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
  316. CFLAGS: '-fstack-protector-strong -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security [% c("var/flag_mwindows") %]'
  317. LDFLAGS: '-Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -Wl,--no-insert-timestamp -lssp -L$gcclibs [% c("var/flag_HEASLR") %] [% c("var/flag_mwindows") %]'
  318. flag_mwindows: '-mwindows'
  319. compiler: mingw-w64
  320. deps:
  321. - build-essential
  322. - python
  323. - bison
  324. - automake
  325. - libtool
  326. - zip
  327. - unzip
  328. torbrowser-osx-x86_64:
  329. - osx-x86_64
  330. osx-x86_64:
  331. arch: x86_64
  332. var:
  333. osx: 1
  334. osname: osx-x86_64
  335. container:
  336. suite: stretch
  337. arch: amd64
  338. compiler: 'macosx-toolchain'
  339. configure_opt: '--host=x86_64-apple-darwin11 CC="x86_64-apple-darwin11-clang [% c("var/FLAGS") %]" CXX="x86_64-apple-darwin11-clang++ [% c("var/FLAGS") %]"'
  340. FLAGS: "-target x86_64-apple-darwin11 -B $cctoolsdir -isysroot $sysrootdir"
  341. LDFLAGS: "-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie"
  342. locale_ja: ja-JP-mac
  343. # We only build snowflake for linux and macOS on the alpha and nightly
  344. # channels for now.
  345. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  346. deps:
  347. - build-essential
  348. - python
  349. - automake
  350. - libtool
  351. - zip
  352. - unzip
  353. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  354. set_PTDIR_DOCSDIR: |
  355. PTDIR="$distdir/Contents/MacOS/Tor/PluggableTransports"
  356. DOCSDIR="$distdir/Contents/Resources/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  357. # The no_build_id target can be useful if you want to quickly display
  358. # a build template or other option but don't want to spend time to
  359. # compute the various build ids
  360. no_build_id:
  361. # The defaut timestamp value will use the commit time of the
  362. # selected commit for the project, which will require cloning the
  363. # git repository if it is not present. When we use the no_build_id
  364. # target to display a script, we usually don't care about such
  365. # details, so we set timestamp to 0 to avoid unnecessary cloning.
  366. timestamp: 0
  367. var:
  368. build_id: 1
  369. no_containers:
  370. var:
  371. container:
  372. global_disable: 1
  373. # change the default gpg_wrapper to allow git tag signed using an
  374. # expired key.
  375. # https://bugs.torproject.org/19737
  376. gpg_wrapper: |
  377. #!/bin/bash
  378. export LC_ALL=C
  379. [%
  380. IF c('gpg_keyring');
  381. SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
  382. END;
  383. -%]
  384. gpg_verify=0
  385. for opt in "$@"
  386. do
  387. test "$opt" = '--verify' && gpg_verify=1
  388. done
  389. if [ $gpg_verify = 1 ]
  390. then
  391. [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
  392. exit ${PIPESTATUS[0]}
  393. else
  394. exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
  395. fi
  396. remote_start: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_start") %][% END %]'
  397. remote_exec: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_exec") %][% END %]'
  398. remote_put: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_put") %][% END %]'
  399. remote_get: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_get") %][% END %]'
  400. remote_finish: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_finish") %][% END %]'
  401. runc:
  402. remote_start: |
  403. #!/bin/sh
  404. set -e
  405. if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
  406. then
  407. echo "Can't find container image in input files" >&2
  408. ls -l '[% c("remote_srcdir") %]' >&2
  409. exit 1
  410. fi
  411. mkdir -p '[% c("var/container/dir") %]'/rootfs/rbm
  412. sudo tar -C '[% c("var/container/dir") %]'/rootfs -xf $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'*)
  413. [% SET user = c("var/container/user") -%]
  414. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'id ' _ user
  415. _ ' >/dev/null 2>&1 || adduser -m ' _ user _ ' || useradd -m ' _ user }) %]
  416. remote_exec: |
  417. #!/bin/sh
  418. set -e
  419. [% IF c("interactive") -%]
  420. echo Container directory: [% shell_quote(c("var/container/dir")) %]
  421. [% END -%]
  422. mkdir -p '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/rbm
  423. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  424. echo [% shell_quote(c('exec_cmd')) %] >> '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  425. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/run
  426. [% IF c('exec_as_root'); SET user = 'root'; ELSE; SET user = c("var/container/user", { error_if_undef => 1 }); END; %]
  427. echo 'su - [% user %] -c /rbm/cmd' >> '[% c("var/container/dir") %]'/rootfs/rbm/run
  428. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  429. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/run
  430. cat > '[% c("var/container/dir") %]'/config.json << EOF
  431. [% INCLUDE 'runc-config.json' %]
  432. EOF
  433. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  434. sudo ip netns add 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  435. [% END -%]
  436. 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 %]
  437. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  438. sudo ip netns delete 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  439. [% END -%]
  440. remote_put: |
  441. #!/bin/sh
  442. set -e
  443. [%
  444. SET src = shell_quote(c('put_src', { error_if_undef => 1 }));
  445. SET dst = shell_quote(c('put_dst', { error_if_undef => 1 }));
  446. -%]
  447. sudo mkdir -p '[% c("var/container/dir") %]'/rootfs/[% dst %]
  448. sudo cp -aP [% src %] '[% c("var/container/dir") %]'/rootfs/[% dst %]
  449. # On Ubuntu, the /root/.profile file contains a `mesg n` line which is
  450. # producing some `stdin: is not a tty` messages. To hide them, we hide
  451. # stderr from this part by setting runc_hide_stderr.
  452. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'chown -R ' _ c("var/container/user") _ ' ' _ dst, runc_hide_stderr => 1 }) %]
  453. remote_get: |
  454. #!/bin/sh
  455. set -e
  456. [%
  457. SET src = shell_quote(c('get_src', { error_if_undef => 1 }));
  458. SET dst = shell_quote(c('get_dst', { error_if_undef => 1 }));
  459. -%]
  460. mkdir -p [% dst %]
  461. srcdir='[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/[% src %]
  462. sudo chown -R $(whoami) "$srcdir"
  463. if [ $(ls -1 "$srcdir"/* 2> /dev/null | wc -l) -gt 0 ]
  464. then
  465. for file in "$srcdir"/*
  466. do
  467. bname="$(basename "$file")"
  468. test -e [% dst %]/"$bname" && rm -Rf [% dst %]/"$bname"
  469. mv -f "$file" [% dst %]/
  470. done
  471. fi
  472. remote_finish: |
  473. #!/bin/sh
  474. set -e
  475. sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
  476. rmdir '[% c("var/container/dir") %]'
  477. ENV:
  478. TZ: UTC
  479. LC_ALL: C
  480. --- |
  481. # This part of the file contains options written in perl
  482. use IO::CaptureOutput qw(capture_exec);
  483. (
  484. var_p => {
  485. # runc100 is true if we are using runc >= 1.0.0
  486. # we assume that any version that is not 0.1.1 is >= 1.0.0
  487. runc100 => sub {
  488. my ($out) = capture_exec('sudo', 'runc', '--version');
  489. return !($out =~ m/^runc version 0.1.1/);
  490. },
  491. # runc_spec100 is true if runc spec is at least 1.0.0
  492. # We will need to update this when there is a new spec version available
  493. runc_spec100 => sub {
  494. my ($out) = capture_exec('sudo', 'runc', '--version');
  495. return $out =~ m/^.*spec: 1\.[0-9]+\.[0-9]+(?:-dev)?$/m;
  496. },
  497. },
  498. )