rbm.conf 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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.5a3'
  24. torbrowser_build: 'build1'
  25. torbrowser_incremental_from:
  26. - 9.5a2
  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', norec => {} }) %]
  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. - lt
  80. - mk
  81. - ms
  82. - nb-NO
  83. - nl
  84. - pl
  85. - pt-BR
  86. - ro
  87. - ru
  88. - sv-SE
  89. - th
  90. - tr
  91. - vi
  92. - zh-CN
  93. - zh-TW
  94. sign_build: '[% ENV.RBM_SIGN_BUILD %]'
  95. sign_build_gpg_opts: '[% ENV.RBM_GPG_OPTS %]'
  96. rezip: |
  97. rezip_tmpdir=$(mktemp -d)
  98. mkdir -p "$rezip_tmpdir/z"
  99. unzip -d "$rezip_tmpdir/z" -- [% c("rezip_file") %] || [ $? -lt 3 ]
  100. pushd "$rezip_tmpdir/z"
  101. [% c("zip", {
  102. zip_src => [ '.' ],
  103. zip_args => '$rezip_tmpdir/new.zip',
  104. }) %]
  105. popd
  106. mv -f -- "$rezip_tmpdir/new.zip" [% c("rezip_file") %]
  107. rm -Rf "$rezip_tmpdir"
  108. set_default_env: |
  109. set -e
  110. [% FOREACH env = c('ENV') -%]
  111. export [% env.key %]="[% env.value %]"
  112. [% END -%]
  113. rootdir=$(pwd)
  114. export SHELL=/bin/bash
  115. export HOME=$rootdir
  116. umask 0022
  117. [% IF c("var/container/global_disable") -%]
  118. rm -Rf /var/tmp/build /var/tmp/dist
  119. [% END -%]
  120. DOCSDIR_project: '[% project %]'
  121. set_PTDIR_DOCSDIR: |
  122. PTDIR="$distdir/TorBrowser/Tor/PluggableTransports"
  123. DOCSDIR="$distdir/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  124. targets:
  125. notarget: linux-x86_64
  126. noint:
  127. debug: 0
  128. release:
  129. var:
  130. release: 1
  131. channel: release
  132. alpha:
  133. var:
  134. alpha: 1
  135. channel: alpha
  136. nightly:
  137. fetch: 1
  138. var:
  139. nightly: 1
  140. channel: nightly
  141. torbrowser_version: '[% ENV.TORBROWSER_NIGHTLY_VERSION ? ENV.TORBROWSER_NIGHTLY_VERSION : c("var_p/nightly_torbrowser_version") %]'
  142. # For nightly builds, we support updates for a limited set of locales
  143. mar_locales:
  144. - de
  145. - es-ES
  146. - fr
  147. - ru
  148. max_torbrowser_incremental_from: 2
  149. torbrowser-testbuild:
  150. - testbuild
  151. - alpha
  152. testbuild:
  153. var:
  154. testbuild: 1
  155. # Don't create mar files to save time
  156. build_mar: 0
  157. # The common-stretch target is used to build components that are common to all
  158. # platforms, using Debian stretch.
  159. common-stretch:
  160. var:
  161. common: 1
  162. container:
  163. suite: stretch
  164. arch: amd64
  165. pre_pkginst: ''
  166. deps:
  167. - build-essential
  168. - python
  169. - automake
  170. - libtool
  171. - zip
  172. - unzip
  173. torbrowser-android-armv7:
  174. - android-armv7
  175. - android
  176. android-armv7:
  177. arch: armv7
  178. var:
  179. android-armv7: 1
  180. osname: android-armv7
  181. toolchain_arch: arm
  182. torbrowser-android-x86:
  183. - android-x86
  184. - android
  185. android-x86:
  186. arch: x86
  187. var:
  188. android-x86: 1
  189. osname: android-x86
  190. toolchain_arch: x86
  191. torbrowser-android-x86_64:
  192. - android-x86_64
  193. - android
  194. android-x86_64:
  195. arch: x86_64
  196. var:
  197. android-x86_64: 1
  198. osname: android-x86_64
  199. toolchain_arch: x86_64
  200. torbrowser-android-aarch64:
  201. - android-aarch64
  202. - android
  203. android-aarch64:
  204. arch: aarch64
  205. var:
  206. android-aarch64: 1
  207. osname: android-aarch64
  208. toolchain_arch: arm64
  209. android:
  210. var:
  211. android: 1
  212. compiler: android-toolchain
  213. # API 16 is the minimum we currently support for Tor Browser on Android
  214. android_min_api: '[% GET c("var/android_min_api_" _ c("arch")) %]'
  215. # API 21 is the minimum we currently support for arm64 on Android
  216. android_min_api_aarch64: 21
  217. android_min_api_armv7: 16
  218. android_min_api_x86: 16
  219. android_min_api_x86_64: 21
  220. snowflake: 0
  221. CC: '$ANDROID_NDK_HOME/[% c("var/toolchain_arch") %]/bin/clang'
  222. CXX: '$ANDROID_NDK_HOME/[% c("var/toolchain_arch") %]/bin/clang++'
  223. container:
  224. suite: stretch
  225. arch: amd64
  226. deps:
  227. - build-essential
  228. - python
  229. - automake
  230. - libtool
  231. - zip
  232. - unzip
  233. torbrowser-linux-x86_64:
  234. - linux-x86_64
  235. - linux
  236. torbrowser-linux-x86_64-debug:
  237. - linux-debug
  238. - linux-x86_64
  239. - linux
  240. torbrowser-linux-i686:
  241. - linux-i686
  242. - linux
  243. linux-x86_64:
  244. arch: x86_64
  245. var:
  246. linux-x86_64: 1
  247. osname: linux-x86_64
  248. linux-i686:
  249. arch: i686
  250. var:
  251. linux-i686: 1
  252. osname: linux-i686
  253. configure_opt_i686: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32'
  254. configure_opt: '[% c("var/configure_opt_i686") %]'
  255. linux:
  256. var:
  257. linux: 1
  258. compiler: gcc
  259. # We only build snowflake 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. # HEASLR is 64 bit only (see bug 12968)
  292. flag_HEASLR: '-Wl,--high-entropy-va'
  293. windows-i686:
  294. arch: i686
  295. var:
  296. windows-i686: 1
  297. osname: windows-i686
  298. windows:
  299. var:
  300. windows: 1
  301. container:
  302. suite: stretch
  303. arch: amd64
  304. configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
  305. CFLAGS: '-fstack-protector-strong -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security [% c("var/flag_mwindows") %]'
  306. LDFLAGS: '-Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -Wl,--no-insert-timestamp -lssp -L$gcclibs [% c("var/flag_HEASLR") %] [% c("var/flag_mwindows") %]'
  307. flag_mwindows: '-mwindows'
  308. compiler: mingw-w64
  309. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  310. # We only build snowflake on the alpha and nightly
  311. # channels for now.
  312. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  313. deps:
  314. - build-essential
  315. - python
  316. - bison
  317. - automake
  318. - libtool
  319. - zip
  320. - unzip
  321. torbrowser-osx-x86_64:
  322. - osx-x86_64
  323. osx-x86_64:
  324. arch: x86_64
  325. var:
  326. osx: 1
  327. osname: osx-x86_64
  328. container:
  329. suite: stretch
  330. arch: amd64
  331. compiler: 'macosx-toolchain'
  332. 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") %]"'
  333. FLAGS: "-target x86_64-apple-darwin11 -B $cctoolsdir -isysroot $sysrootdir"
  334. LDFLAGS: "-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie"
  335. macosx_deployment_target: '10.9'
  336. locale_ja: ja-JP-mac
  337. # We only build snowflake on the alpha and nightly
  338. # channels for now.
  339. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  340. deps:
  341. - build-essential
  342. - python
  343. - automake
  344. - libtool
  345. - zip
  346. - unzip
  347. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  348. set_PTDIR_DOCSDIR: |
  349. PTDIR="$distdir/Contents/MacOS/Tor/PluggableTransports"
  350. DOCSDIR="$distdir/Contents/Resources/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  351. # The no_build_id target can be useful if you want to quickly display
  352. # a build template or other option but don't want to spend time to
  353. # compute the various build ids
  354. no_build_id:
  355. # The defaut timestamp value will use the commit time of the
  356. # selected commit for the project, which will require cloning the
  357. # git repository if it is not present. When we use the no_build_id
  358. # target to display a script, we usually don't care about such
  359. # details, so we set timestamp to 0 to avoid unnecessary cloning.
  360. timestamp: 0
  361. var:
  362. build_id: 1
  363. no_containers:
  364. var:
  365. container:
  366. global_disable: 1
  367. # change the default gpg_wrapper to allow git tag signed using an
  368. # expired key.
  369. # https://bugs.torproject.org/19737
  370. gpg_wrapper: |
  371. #!/bin/bash
  372. export LC_ALL=C
  373. [%
  374. IF c('gpg_keyring');
  375. SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
  376. END;
  377. -%]
  378. gpg_verify=0
  379. for opt in "$@"
  380. do
  381. test "$opt" = '--verify' && gpg_verify=1
  382. done
  383. if [ $gpg_verify = 1 ]
  384. then
  385. [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
  386. exit ${PIPESTATUS[0]}
  387. else
  388. exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
  389. fi
  390. remote_start: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_start") %][% END %]'
  391. remote_exec: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_exec") %][% END %]'
  392. remote_put: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_put") %][% END %]'
  393. remote_get: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_get") %][% END %]'
  394. remote_finish: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_finish") %][% END %]'
  395. runc:
  396. remote_start: |
  397. #!/bin/sh
  398. set -e
  399. if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
  400. then
  401. echo "Can't find container image in input files" >&2
  402. ls -l '[% c("remote_srcdir") %]' >&2
  403. exit 1
  404. fi
  405. mkdir -p '[% c("var/container/dir") %]'/rootfs/rbm
  406. sudo tar -C '[% c("var/container/dir") %]'/rootfs -xf $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'*)
  407. [% SET user = c("var/container/user") -%]
  408. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'id ' _ user
  409. _ ' >/dev/null 2>&1 || adduser -m ' _ user _ ' || useradd -m ' _ user }) %]
  410. remote_exec: |
  411. #!/bin/sh
  412. set -e
  413. [% IF c("interactive") -%]
  414. echo Container directory: [% shell_quote(c("var/container/dir")) %]
  415. [% END -%]
  416. mkdir -p '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/rbm
  417. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  418. echo [% shell_quote(c('exec_cmd')) %] >> '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  419. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/run
  420. [% IF c('exec_as_root'); SET user = 'root'; ELSE; SET user = c("var/container/user", { error_if_undef => 1 }); END; %]
  421. echo 'su - [% user %] -c /rbm/cmd' >> '[% c("var/container/dir") %]'/rootfs/rbm/run
  422. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  423. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/run
  424. cat > '[% c("var/container/dir") %]'/config.json << EOF
  425. [% INCLUDE 'runc-config.json' %]
  426. EOF
  427. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  428. sudo ip netns add 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  429. # make sure the lo interface is up (see bug 31293)
  430. sudo ip netns exec 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]' ip link set lo up
  431. [% END -%]
  432. 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 %]
  433. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  434. sudo ip netns delete 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  435. [% END -%]
  436. remote_put: |
  437. #!/bin/sh
  438. set -e
  439. [%
  440. SET src = shell_quote(c('put_src', { error_if_undef => 1 }));
  441. SET dst = shell_quote(c('put_dst', { error_if_undef => 1 }));
  442. -%]
  443. sudo mkdir -p '[% c("var/container/dir") %]'/rootfs/[% dst %]
  444. sudo cp -aP [% src %] '[% c("var/container/dir") %]'/rootfs/[% dst %]
  445. # On Ubuntu, the /root/.profile file contains a `mesg n` line which is
  446. # producing some `stdin: is not a tty` messages. To hide them, we hide
  447. # stderr from this part by setting runc_hide_stderr.
  448. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'chown -R ' _ c("var/container/user") _ ' ' _ dst, runc_hide_stderr => 1 }) %]
  449. remote_get: |
  450. #!/bin/sh
  451. set -e
  452. [%
  453. SET src = shell_quote(c('get_src', { error_if_undef => 1 }));
  454. SET dst = shell_quote(c('get_dst', { error_if_undef => 1 }));
  455. -%]
  456. mkdir -p [% dst %]
  457. srcdir='[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/[% src %]
  458. sudo chown -R $(whoami) "$srcdir"
  459. if [ $(ls -1 "$srcdir"/* 2> /dev/null | wc -l) -gt 0 ]
  460. then
  461. for file in "$srcdir"/*
  462. do
  463. bname="$(basename "$file")"
  464. test -e [% dst %]/"$bname" && rm -Rf [% dst %]/"$bname"
  465. mv -f "$file" [% dst %]/
  466. done
  467. fi
  468. remote_finish: |
  469. #!/bin/sh
  470. set -e
  471. sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
  472. rmdir '[% c("var/container/dir") %]'
  473. ENV:
  474. TZ: UTC
  475. LC_ALL: C
  476. --- |
  477. # This part of the file contains options written in perl
  478. use IO::CaptureOutput qw(capture_exec);
  479. (
  480. var_p => {
  481. # runc100 is true if we are using runc >= 1.0.0
  482. # we assume that any version that is not 0.1.1 is >= 1.0.0
  483. runc100 => sub {
  484. my ($out) = capture_exec('sudo', 'runc', '--version');
  485. return !($out =~ m/^runc version 0.1.1/);
  486. },
  487. # runc_spec100 is true if runc spec is at least 1.0.0
  488. # We will need to update this when there is a new spec version available
  489. runc_spec100 => sub {
  490. my ($out) = capture_exec('sudo', 'runc', '--version');
  491. return $out =~ m/^.*spec: 1\.[0-9]+\.[0-9]+(?:-dev)?$/m;
  492. },
  493. nightly_torbrowser_version => sub {
  494. state $version = '';
  495. return $version if $version;
  496. my (undef, undef, undef, $day, $mon, $year) = gmtime;
  497. $version = sprintf("tbb-nightly.%u.%02u.%02u", $year + 1900, $mon + 1, $day);
  498. return $version;
  499. },
  500. nightly_torbrowser_incremental_from => sub {
  501. my ($project, $options) = @_;
  502. my $nightly_dir = project_config($project, 'basedir', $options) . '/nightly';
  503. my $current_version = project_config($project, 'var/torbrowser_version', $options);
  504. use Path::Tiny;
  505. return [] unless -d $nightly_dir;
  506. my @dirs = sort map { $_->basename } path($nightly_dir)->children(qr/^tbb-nightly\./);
  507. my $nb_incr = project_config($project, ['var', 'max_torbrowser_incremental_from'], $options);
  508. my @res;
  509. while ($nb_incr > 0) {
  510. my $dir = pop @dirs;
  511. last unless $dir;
  512. next if $dir eq $current_version;
  513. $nb_incr--;
  514. push @res, $dir;
  515. }
  516. return [@res];
  517. },
  518. },
  519. )