rbm.conf 17 KB

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