rbm.conf 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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.0a4'
  24. torbrowser_build: 'build2'
  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. linux-x86_64:
  219. arch: x86_64
  220. var:
  221. linux-x86_64: 1
  222. osname: linux-x86_64
  223. linux-i686:
  224. arch: i686
  225. var:
  226. linux-i686: 1
  227. osname: linux-i686
  228. configure_opt_i686: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32'
  229. configure_opt: '[% c("var/configure_opt_i686") %]'
  230. linux:
  231. var:
  232. linux: 1
  233. compiler: gcc
  234. # We only build snowflake for linux and macOS on the alpha and nightly
  235. # channels for now.
  236. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  237. container:
  238. suite: wheezy
  239. arch: amd64
  240. pre_pkginst: dpkg --add-architecture i386
  241. deps:
  242. - libc6-dev-i386
  243. - lib32stdc++6
  244. - build-essential
  245. - python
  246. - bison
  247. - hardening-wrapper
  248. - automake
  249. - libtool
  250. - zip
  251. - unzip
  252. linux-debug:
  253. var:
  254. asan: 1
  255. torbrowser-windows-i686:
  256. - windows-i686
  257. - windows
  258. torbrowser-windows-x86_64:
  259. - windows-x86_64
  260. - windows
  261. windows-x86_64:
  262. arch: x86_64
  263. var:
  264. windows-x86_64: 1
  265. osname: windows-x86_64
  266. container:
  267. arch: amd64
  268. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  269. # HEASLR is 64 bit only (see bug 12968)
  270. flag_HEASLR: '-Wl,--high-entropy-va'
  271. windows-i686:
  272. arch: i686
  273. var:
  274. windows-i686: 1
  275. osname: windows-i686
  276. container:
  277. arch: i386
  278. faketime_path: /usr/lib/i386-linux-gnu/faketime/libfaketime.so.1
  279. setarch: |
  280. if test -z "$RBM_SETARCH"
  281. then
  282. export RBM_SETARCH=1
  283. exec setarch i686 ./build
  284. fi
  285. windows:
  286. var:
  287. windows: 1
  288. container:
  289. suite: stretch
  290. configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
  291. CFLAGS: '-fstack-protector-strong -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security [% c("var/flag_mwindows") %]'
  292. LDFLAGS: '-Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -Wl,--no-insert-timestamp -lssp -L$gcclibs [% c("var/flag_HEASLR") %] [% c("var/flag_mwindows") %]'
  293. flag_mwindows: '-mwindows'
  294. compiler: mingw-w64
  295. deps:
  296. - build-essential
  297. - python
  298. - bison
  299. - automake
  300. - libtool
  301. - zip
  302. - unzip
  303. torbrowser-osx-x86_64:
  304. - osx-x86_64
  305. osx-x86_64:
  306. arch: x86_64
  307. var:
  308. osx: 1
  309. osname: osx-x86_64
  310. container:
  311. suite: stretch
  312. arch: amd64
  313. compiler: 'macosx-toolchain'
  314. 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") %]"'
  315. FLAGS: "-target x86_64-apple-darwin11 -B $cctoolsdir -isysroot $sysrootdir"
  316. LDFLAGS: "-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie"
  317. locale_ja: ja-JP-mac
  318. # We only build snowflake for linux and macOS on the alpha and nightly
  319. # channels for now.
  320. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  321. deps:
  322. - build-essential
  323. - python
  324. - automake
  325. - libtool
  326. - zip
  327. - unzip
  328. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  329. set_PTDIR_DOCSDIR: |
  330. PTDIR="$distdir/Contents/MacOS/Tor/PluggableTransports"
  331. DOCSDIR="$distdir/Contents/Resources/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  332. # The no_build_id target can be useful if you want to quickly display
  333. # a build template or other option but don't want to spend time to
  334. # compute the various build ids
  335. no_build_id:
  336. # The defaut timestamp value will use the commit time of the
  337. # selected commit for the project, which will require cloning the
  338. # git repository if it is not present. When we use the no_build_id
  339. # target to display a script, we usually don't care about such
  340. # details, so we set timestamp to 0 to avoid unnecessary cloning.
  341. timestamp: 0
  342. var:
  343. build_id: 1
  344. no_containers:
  345. var:
  346. container:
  347. global_disable: 1
  348. # change the default gpg_wrapper to allow git tag signed using an
  349. # expired key.
  350. # https://bugs.torproject.org/19737
  351. gpg_wrapper: |
  352. #!/bin/bash
  353. export LC_ALL=C
  354. [%
  355. IF c('gpg_keyring');
  356. SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
  357. END;
  358. -%]
  359. gpg_verify=0
  360. for opt in "$@"
  361. do
  362. test "$opt" = '--verify' && gpg_verify=1
  363. done
  364. if [ $gpg_verify = 1 ]
  365. then
  366. [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
  367. exit ${PIPESTATUS[0]}
  368. else
  369. exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
  370. fi
  371. remote_start: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_start") %][% END %]'
  372. remote_exec: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_exec") %][% END %]'
  373. remote_put: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_put") %][% END %]'
  374. remote_get: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_get") %][% END %]'
  375. remote_finish: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_finish") %][% END %]'
  376. runc:
  377. remote_start: |
  378. #!/bin/sh
  379. set -e
  380. if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
  381. then
  382. echo "Can't find container image in input files" >&2
  383. ls -l '[% c("remote_srcdir") %]' >&2
  384. exit 1
  385. fi
  386. mkdir -p '[% c("var/container/dir") %]'/rootfs/rbm
  387. sudo tar -C '[% c("var/container/dir") %]'/rootfs -xf $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'*)
  388. [% SET user = c("var/container/user") -%]
  389. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'id ' _ user
  390. _ ' >/dev/null 2>&1 || adduser -m ' _ user _ ' || useradd -m ' _ user }) %]
  391. remote_exec: |
  392. #!/bin/sh
  393. set -e
  394. [% IF c("interactive") -%]
  395. echo Container directory: [% shell_quote(c("var/container/dir")) %]
  396. [% END -%]
  397. mkdir -p '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/rbm
  398. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  399. echo [% shell_quote(c('exec_cmd')) %] >> '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  400. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/run
  401. [% IF c('exec_as_root'); SET user = 'root'; ELSE; SET user = c("var/container/user", { error_if_undef => 1 }); END; %]
  402. echo 'su - [% user %] -c /rbm/cmd' >> '[% c("var/container/dir") %]'/rootfs/rbm/run
  403. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  404. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/run
  405. cat > '[% c("var/container/dir") %]'/config.json << EOF
  406. [% INCLUDE 'runc-config.json' %]
  407. EOF
  408. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  409. sudo ip netns add 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  410. [% END -%]
  411. 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 %]
  412. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  413. sudo ip netns delete 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  414. [% END -%]
  415. remote_put: |
  416. #!/bin/sh
  417. set -e
  418. [%
  419. SET src = shell_quote(c('put_src', { error_if_undef => 1 }));
  420. SET dst = shell_quote(c('put_dst', { error_if_undef => 1 }));
  421. -%]
  422. sudo mkdir -p '[% c("var/container/dir") %]'/rootfs/[% dst %]
  423. sudo cp -aP [% src %] '[% c("var/container/dir") %]'/rootfs/[% dst %]
  424. # On Ubuntu, the /root/.profile file contains a `mesg n` line which is
  425. # producing some `stdin: is not a tty` messages. To hide them, we hide
  426. # stderr from this part by setting runc_hide_stderr.
  427. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'chown -R ' _ c("var/container/user") _ ' ' _ dst, runc_hide_stderr => 1 }) %]
  428. remote_get: |
  429. #!/bin/sh
  430. set -e
  431. [%
  432. SET src = shell_quote(c('get_src', { error_if_undef => 1 }));
  433. SET dst = shell_quote(c('get_dst', { error_if_undef => 1 }));
  434. -%]
  435. mkdir -p [% dst %]
  436. srcdir='[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/[% src %]
  437. sudo chown -R $(whoami) "$srcdir"
  438. if [ $(ls -1 "$srcdir"/* 2> /dev/null | wc -l) -gt 0 ]
  439. then
  440. for file in "$srcdir"/*
  441. do
  442. bname="$(basename "$file")"
  443. test -e [% dst %]/"$bname" && rm -Rf [% dst %]/"$bname"
  444. mv -f "$file" [% dst %]/
  445. done
  446. fi
  447. remote_finish: |
  448. #!/bin/sh
  449. set -e
  450. sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
  451. rmdir '[% c("var/container/dir") %]'
  452. ENV:
  453. TZ: UTC
  454. LC_ALL: C
  455. --- |
  456. # This part of the file contains options written in perl
  457. use IO::CaptureOutput qw(capture_exec);
  458. (
  459. var_p => {
  460. # runc100 is true if we are using runc >= 1.0.0
  461. # we assume that any version that is not 0.1.1 is >= 1.0.0
  462. runc100 => sub {
  463. my ($out) = capture_exec('sudo', 'runc', '--version');
  464. return !($out =~ m/^runc version 0.1.1/);
  465. },
  466. # runc_spec100 is true if runc spec is at least 1.0.0
  467. # We will need to update this when there is a new spec version available
  468. runc_spec100 => sub {
  469. my ($out) = capture_exec('sudo', 'runc', '--version');
  470. return $out =~ m/^.*spec: 1\.[0-9]+\.[0-9]+(?:-dev)?$/m;
  471. },
  472. },
  473. )