rbm.conf 16 KB

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