rbm.conf 16 KB

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