rbm.conf 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. deb_native_arch: arm64
  23. var:
  24. torbrowser_version: '10.0'
  25. torbrowser_build: 'build3'
  26. torbrowser_incremental_from:
  27. - 9.5.4
  28. project_name: tor-browser
  29. multi_lingual: 0
  30. build_mar: 1
  31. # By default, we sort the list of installed packages. This allows sharing
  32. # containers with identical list of packages, even if they are not listed
  33. # in the same order. In the cases where the installation order is
  34. # important, sort_deps should be set to 0.
  35. sort_deps: 1
  36. build_id: '[% sha256(c("var/build_id_txt", { buildconf => { num_procs => 4 } })).substr(0, 6) %]'
  37. build_id_txt: |
  38. [% c("version") %]
  39. [% IF c("git_hash") || c("hg_hash"); GET c("abbrev"); END; %]
  40. [% IF c("var/container/use_container") && ! c("var/container/global_disable") -%]
  41. [% c("var/container/suite") %]
  42. [% c("var/container/arch") %]
  43. [% END -%]
  44. input_files: [% c("input_files_id") %]
  45. build:
  46. [% SET step = c("step") -%]
  47. [% c(step, { filename => 'f', output_dir => '/out', norec => {} }) %]
  48. container:
  49. dir: '[% c("rbm_tmp_dir") %]/rbm-containers/[% sha256(c("build_id")) %]'
  50. user: rbm
  51. disable_network:
  52. # disable network in the build scripts
  53. build: 1
  54. input_files_list: |
  55. [% FOREACH file IN c("input_files_by_name").keys.sort -%]
  56. [% c("input_files_by_name/" _ file) %]
  57. [% END -%]
  58. faketime: "faketime -f \"[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]\""
  59. touch: "[% USE date %]touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %]"
  60. locale_ja: ja
  61. locales:
  62. - ar
  63. - ca
  64. - cs
  65. - da
  66. - de
  67. - el
  68. - es-AR
  69. - es-ES
  70. - fa
  71. - fr
  72. - ga-IE
  73. - he
  74. - hu
  75. - id
  76. - is
  77. - it
  78. - '[% c("var/locale_ja") %]'
  79. - ka
  80. - ko
  81. - lt
  82. - mk
  83. - ms
  84. - nb-NO
  85. - nl
  86. - pl
  87. - pt-BR
  88. - ro
  89. - ru
  90. - sv-SE
  91. - th
  92. - tr
  93. - vi
  94. - zh-CN
  95. - zh-TW
  96. sign_build: '[% ENV.RBM_SIGN_BUILD %]'
  97. sign_build_gpg_opts: '[% ENV.RBM_GPG_OPTS %]'
  98. rezip: |
  99. rezip_tmpdir=$(mktemp -d)
  100. mkdir -p "$rezip_tmpdir/z"
  101. unzip -d "$rezip_tmpdir/z" -- [% c("rezip_file") %] || [ $? -lt 3 ]
  102. pushd "$rezip_tmpdir/z"
  103. [% c("zip", {
  104. zip_src => [ '.' ],
  105. zip_args => '$rezip_tmpdir/new.zip',
  106. }) %]
  107. popd
  108. mv -f -- "$rezip_tmpdir/new.zip" [% c("rezip_file") %]
  109. rm -Rf "$rezip_tmpdir"
  110. set_default_env: |
  111. set -e
  112. [% FOREACH env = c('ENV') -%]
  113. export [% env.key %]="[% env.value %]"
  114. [% END -%]
  115. rootdir=$(pwd)
  116. export SHELL=/bin/bash
  117. export HOME=$rootdir
  118. umask 0022
  119. [% IF c("var/container/global_disable") -%]
  120. rm -Rf /var/tmp/build /var/tmp/dist
  121. [% END -%]
  122. DOCSDIR_project: '[% project %]'
  123. set_PTDIR_DOCSDIR: |
  124. PTDIR="$distdir/TorBrowser/Tor/PluggableTransports"
  125. DOCSDIR="$distdir/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  126. targets:
  127. notarget: linux-x86_64
  128. noint:
  129. debug: 0
  130. release:
  131. var:
  132. release: 1
  133. channel: release
  134. alpha:
  135. var:
  136. alpha: 1
  137. channel: alpha
  138. nightly:
  139. fetch: 1
  140. var:
  141. nightly: 1
  142. channel: nightly
  143. torbrowser_version: |
  144. [%
  145. IF ENV.TORBROWSER_NIGHTLY_VERSION;
  146. GET ENV.TORBROWSER_NIGHTLY_VERSION;
  147. ELSIF c("var/testbuild");
  148. GET "testbuild";
  149. ELSE;
  150. GET c("var_p/nightly_torbrowser_version");
  151. END;
  152. -%]
  153. # For nightly builds, we support updates for a limited set of locales
  154. mar_locales:
  155. - de
  156. - es-ES
  157. - fr
  158. - ru
  159. max_torbrowser_incremental_from: 2
  160. build_infos_json: 1
  161. torbrowser-testbuild:
  162. - testbuild
  163. - alpha
  164. testbuild:
  165. var:
  166. testbuild: 1
  167. # Don't create mar files to save time
  168. build_mar: 0
  169. # The common-buster target is used to build components that are common to all
  170. # platforms, using Debian Buster.
  171. common-buster:
  172. var:
  173. common: 1
  174. container:
  175. suite: buster
  176. arch: '[% c("buildconf/deb_native_arch") %]'
  177. pre_pkginst: ''
  178. deps:
  179. - build-essential
  180. - python
  181. - automake
  182. - libtool
  183. - zip
  184. - unzip
  185. torbrowser-android-all:
  186. - android-all
  187. - android
  188. android-all:
  189. arch: all
  190. var:
  191. android-all: 1
  192. osname: android-all
  193. torbrowser-android-armv7:
  194. - android-armv7
  195. - android
  196. android-armv7:
  197. arch: armv7
  198. var:
  199. android-armv7: 1
  200. osname: android-armv7
  201. toolchain_arch: arm
  202. abi: armeabi-v7a
  203. cross_prefix: armv7a-linux-androideabi
  204. torbrowser-android-x86:
  205. - android-x86
  206. - android
  207. android-x86:
  208. arch: x86
  209. var:
  210. android-x86: 1
  211. osname: android-x86
  212. toolchain_arch: x86
  213. abi: x86
  214. cross_prefix: i686-linux-android
  215. torbrowser-android-x86_64:
  216. - android-x86_64
  217. - android
  218. android-x86_64:
  219. arch: x86_64
  220. var:
  221. android-x86_64: 1
  222. osname: android-x86_64
  223. toolchain_arch: x86_64
  224. abi: x86_64
  225. cross_prefix: x86_64-linux-android
  226. torbrowser-android-aarch64:
  227. - android-aarch64
  228. - android
  229. android-aarch64:
  230. arch: aarch64
  231. var:
  232. android-aarch64: 1
  233. osname: android-aarch64
  234. toolchain_arch: arm64
  235. abi: arm64-v8a
  236. cross_prefix: aarch64-linux-android
  237. android:
  238. var:
  239. android: 1
  240. compiler: android-toolchain
  241. android_min_api: '[% GET c("var/android_min_api_" _ c("arch")) %]'
  242. CC: '[% c("var/cross_prefix") %][% c("var/android_min_api") %]-clang'
  243. CXX: '[% c("var/cross_prefix") %][% c("var/android_min_api") %]-clang'
  244. # API 16 is the minimum we currently support for 32 bit on Android
  245. android_min_api_armv7: 16
  246. android_min_api_x86: 16
  247. # API 21 is the minimum we currently support for 64 bit on Android
  248. android_min_api_x86_64: 21
  249. android_min_api_aarch64: 21
  250. # This is needed to get the offline build part for Glean right.
  251. glean_parser: 1.28.1
  252. # We only build snowflake on the alpha and nightly
  253. # channels for now.
  254. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  255. container:
  256. suite: buster
  257. arch: amd64
  258. disable_network:
  259. # Disable network in the script for merging GeckoView .aar files
  260. merge_aars: 1
  261. deps:
  262. - build-essential
  263. - python
  264. - automake
  265. - libtool
  266. - zip
  267. - unzip
  268. - libtinfo5
  269. configure_opt: '--host=[% c("var/cross_prefix") %] CC=[% c("var/CC") %] [% c("var/configure_opt_project") %]'
  270. pre_pkginst: |
  271. SNAPSHOT_VERSION=20191201T212855Z
  272. OPENJDK_URL=https://snapshot.debian.org/archive/debian/$SNAPSHOT_VERSION/pool/main/o/openjdk-8
  273. JDK_VERSION=8u232-b09-1~deb9u1_amd64
  274. apt-get install -y -q wget ca-certificates-java
  275. wget $OPENJDK_URL/openjdk-8-jdk-headless_$JDK_VERSION.deb
  276. wget $OPENJDK_URL/openjdk-8-jre-headless_$JDK_VERSION.deb
  277. echo 92b4f8fb77d793a86e0b03b3b0750592b40a26a5d75956d10dd984a7b3aad4c9 openjdk-8-jdk-headless_$JDK_VERSION.deb | sha256sum -c
  278. echo 84bf52b6cce20ead08b0d5b9fd9b81b4aa3da385ca951b313fe11d5cb1aa4d17 openjdk-8-jre-headless_$JDK_VERSION.deb | sha256sum -c
  279. dpkg -i ./openjdk-8-jre-headless_$JDK_VERSION.deb ./openjdk-8-jdk-headless_$JDK_VERSION.deb
  280. torbrowser-linux-x86_64:
  281. - linux-x86_64
  282. - linux
  283. torbrowser-linux-x86_64-asan:
  284. - linux-asan
  285. - linux-x86_64
  286. - linux
  287. torbrowser-linux-i686:
  288. - linux-i686
  289. - linux
  290. torbrowser-linux-armhf:
  291. - linux-armhf
  292. - linux
  293. torbrowser-linux-arm64:
  294. - linux-arm64
  295. - linux
  296. linux-x86_64:
  297. arch: x86_64
  298. var:
  299. linux-x86_64: 1
  300. osname: linux-x86_64
  301. gnu-build-triplet: x86_64-unknown-linux-gnu
  302. gnu-host-triplet: x86_64-unknown-linux-gnu
  303. # We only support RLBox on the nightly channel and x86_64 for now
  304. rlbox: '[% c("var/nightly") %]'
  305. linux-i686:
  306. arch: i686
  307. var:
  308. linux-i686: 1
  309. osname: linux-i686
  310. gnu-build-triplet: i686-unknown-linux-gnu
  311. gnu-host-triplet: i686-unknown-linux-gnu
  312. configure_opt: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 [% c("var/configure_opt_project") %]'
  313. linux-armhf:
  314. arch: arm
  315. var:
  316. linux-armhf: 1
  317. osname: linux-armhf
  318. gnu-build-triplet: armv7-unknown-linux-gnueabihf
  319. gnu-host-triplet: armv7-unknown-linux-gnueabihf
  320. container:
  321. arch: armhf
  322. # needs to be jessie for rust: rustc stage0 binary depends
  323. # on newer than wheezy glibc
  324. suite: jessie
  325. pre_pkginst: ''
  326. deps:
  327. - build-essential
  328. - python
  329. - bison
  330. - hardening-wrapper
  331. - automake
  332. - libtool
  333. - zip
  334. - unzip
  335. linux-arm64:
  336. arch: aarch64
  337. var:
  338. linux-arm64: 1
  339. osname: linux-arm64
  340. gnu-build-triplet: aarch64-unknown-linux-gnu
  341. gnu-host-triplet: aarch64-unknown-linux-gnu
  342. container:
  343. arch: arm64
  344. # jessie is the first 64-bit arm release...and has a bug
  345. # in glibc which fails firefox build (dlopen: cannot load any more object with static TLS)
  346. suite: stretch
  347. pre_pkginst: ''
  348. deps:
  349. - build-essential
  350. - python
  351. - bison
  352. - automake
  353. - libtool
  354. - zip
  355. - unzip
  356. linux:
  357. var:
  358. linux: 1
  359. compiler: gcc
  360. configure_opt: '[% c("var/configure_opt_project") %]'
  361. # We only build snowflake on the alpha and nightly
  362. # channels for now.
  363. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  364. # Only build Namecoin for linux on nightly
  365. namecoin: '[% c("var/nightly") %]'
  366. container:
  367. suite: wheezy
  368. arch: amd64
  369. pre_pkginst: dpkg --add-architecture i386
  370. deps:
  371. - libc6-dev-i386
  372. - lib32stdc++6
  373. - build-essential
  374. - python
  375. - bison
  376. - hardening-wrapper
  377. - automake
  378. - libtool
  379. - zip
  380. - unzip
  381. linux-asan:
  382. var:
  383. asan: 1
  384. # RLBox needs clang to create .wasm files but we use mostly GCC for our
  385. # ASan builds. Thus, the compilation currently breaks with RLBox enabled.
  386. # See: tor-browser-build#40063.
  387. rlbox: 0
  388. torbrowser-windows-i686:
  389. - windows-i686
  390. - windows
  391. torbrowser-windows-x86_64:
  392. - windows-x86_64
  393. - windows
  394. windows-x86_64:
  395. arch: x86_64
  396. var:
  397. windows-x86_64: 1
  398. windows-i686: 0
  399. osname: windows-x86_64
  400. gnu-build-triplet: x86_64-unknown-linux-gnu
  401. gnu-host-triplet: x86_64-pc-windows-gnu
  402. # HEASLR is 64 bit only (see bug 12968)
  403. flag_HEASLR: '-Wl,--high-entropy-va'
  404. windows-i686:
  405. arch: i686
  406. var:
  407. windows-i686: 1
  408. windows-x86_64: 0
  409. osname: windows-i686
  410. gnu-build-triplet: i686-unknown-linux-gnu
  411. gnu-host-triplet: i686-pc-windows-gnu
  412. # mingw-w64 does not support SEH on 32bit systems. Be explicit about that.
  413. flag_noSEH: '-Wl,--no-seh'
  414. windows:
  415. var:
  416. windows: 1
  417. container:
  418. suite: buster
  419. arch: amd64
  420. configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]" [% c("var/configure_opt_project") %]'
  421. CFLAGS: '-fstack-protector-strong -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security [% c("var/flag_mwindows") %]'
  422. LDFLAGS: '-Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -Wl,--no-insert-timestamp -lssp -L$gcclibs [% c("var/flag_HEASLR") %] [% c("var/flag_noSEH") %] [% c("var/flag_mwindows") %]'
  423. flag_mwindows: '-mwindows'
  424. compiler: mingw-w64
  425. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  426. # We only build snowflake on the alpha and nightly
  427. # channels for now.
  428. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  429. deps:
  430. - build-essential
  431. - python
  432. - bison
  433. - automake
  434. - libtool
  435. - zip
  436. - unzip
  437. torbrowser-osx-x86_64:
  438. - osx-x86_64
  439. osx-x86_64:
  440. arch: x86_64
  441. var:
  442. osx: 1
  443. osname: osx-x86_64
  444. gnu-build-triplet: x86_64-unknown-linux-gnu
  445. gnu-host-triplet: x86_64-apple-darwin11
  446. container:
  447. suite: buster
  448. arch: amd64
  449. compiler: 'macosx-toolchain'
  450. configure_opt: '--host=x86_64-apple-darwin CC="x86_64-apple-darwin-clang [% c("var/FLAGS") %]" CXX="x86_64-apple-darwin-clang++ [% c("var/FLAGS") %]" [% c("var/configure_opt_project") %]'
  451. FLAGS: "-target x86_64-apple-darwin -B $cctoolsdir -isysroot $sysrootdir"
  452. LDFLAGS: "-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie"
  453. macosx_deployment_target: '10.9'
  454. locale_ja: ja-JP-mac
  455. # We only support RLBox on the nightly channel for now
  456. rlbox: '[% c("var/nightly") %]'
  457. # We only build snowflake on the alpha and nightly
  458. # channels for now.
  459. snowflake: '[% c("var/alpha") || c("var/nightly") %]'
  460. deps:
  461. - build-essential
  462. - python
  463. - automake
  464. - libtool
  465. - zip
  466. - unzip
  467. faketime_path: /usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
  468. set_PTDIR_DOCSDIR: |
  469. PTDIR="$distdir/Contents/MacOS/Tor/PluggableTransports"
  470. DOCSDIR="$distdir/Contents/Resources/TorBrowser/Docs/[% c("var/DOCSDIR_project") %]"
  471. # The no_build_id target can be useful if you want to quickly display
  472. # a build template or other option but don't want to spend time to
  473. # compute the various build ids
  474. no_build_id:
  475. # The defaut timestamp value will use the commit time of the
  476. # selected commit for the project, which will require cloning the
  477. # git repository if it is not present. When we use the no_build_id
  478. # target to display a script, we usually don't care about such
  479. # details, so we set timestamp to 0 to avoid unnecessary cloning.
  480. timestamp: 0
  481. var:
  482. build_id: 1
  483. no_containers:
  484. var:
  485. container:
  486. global_disable: 1
  487. # change the default gpg_wrapper to allow git tag signed using an
  488. # expired key.
  489. # https://bugs.torproject.org/19737
  490. gpg_wrapper: |
  491. #!/bin/bash
  492. export LC_ALL=C
  493. [%
  494. IF c('gpg_keyring');
  495. SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
  496. END;
  497. -%]
  498. gpg_verify=0
  499. for opt in "$@"
  500. do
  501. test "$opt" = '--verify' && gpg_verify=1
  502. done
  503. if [ $gpg_verify = 1 ]
  504. then
  505. [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
  506. exit ${PIPESTATUS[0]}
  507. else
  508. exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
  509. fi
  510. remote_start: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_start") %][% END %]'
  511. remote_exec: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_exec") %][% END %]'
  512. remote_put: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_put") %][% END %]'
  513. remote_get: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_get") %][% END %]'
  514. remote_finish: '[% IF c("var/container/use_container") && ! c("var/container/global_disable") %][% c("runc/remote_finish") %][% END %]'
  515. runc:
  516. remote_start: |
  517. #!/bin/sh
  518. set -e
  519. if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
  520. then
  521. echo "Can't find container image in input files" >&2
  522. ls -l '[% c("remote_srcdir") %]' >&2
  523. exit 1
  524. fi
  525. mkdir -p '[% c("var/container/dir") %]'/rootfs/rbm
  526. sudo tar -C '[% c("var/container/dir") %]'/rootfs -xf $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'*)
  527. [% SET user = c("var/container/user") -%]
  528. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'id ' _ user
  529. _ ' >/dev/null 2>&1 || adduser -m ' _ user _ ' || useradd -m ' _ user }) %]
  530. remote_exec: |
  531. #!/bin/sh
  532. set -e
  533. [% IF c("interactive") -%]
  534. echo Container directory: [% shell_quote(c("var/container/dir")) %]
  535. [% END -%]
  536. mkdir -p '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/rbm
  537. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  538. echo [% shell_quote(c('exec_cmd')) %] >> '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  539. echo '#!/bin/sh' > '[% c("var/container/dir") %]'/rootfs/rbm/run
  540. [% IF c('exec_as_root'); SET user = 'root'; ELSE; SET user = c("var/container/user", { error_if_undef => 1 }); END; %]
  541. echo 'su - [% user %] -c /rbm/cmd' >> '[% c("var/container/dir") %]'/rootfs/rbm/run
  542. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/cmd
  543. chmod +x '[% c("var/container/dir") %]'/rootfs/rbm/run
  544. cat > '[% c("var/container/dir") %]'/config.json << EOF
  545. [% INCLUDE 'runc-config.json' %]
  546. EOF
  547. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  548. sudo ip netns add 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  549. # make sure the lo interface is up (see bug 31293)
  550. sudo ip netns exec 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]' ip link set lo up
  551. [% END -%]
  552. 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 %]
  553. [% IF c("var/container/disable_network/" _ c("exec_name")) -%]
  554. sudo ip netns delete 'rbm-[% sha256(c("build_id", { error_if_undef => 1 })) %]'
  555. [% END -%]
  556. remote_put: |
  557. #!/bin/sh
  558. set -e
  559. [%
  560. SET src = shell_quote(c('put_src', { error_if_undef => 1 }));
  561. SET dst = shell_quote(c('put_dst', { error_if_undef => 1 }));
  562. -%]
  563. sudo mkdir -p '[% c("var/container/dir") %]'/rootfs/[% dst %]
  564. sudo cp -aP [% src %] '[% c("var/container/dir") %]'/rootfs/[% dst %]
  565. # On Ubuntu, the /root/.profile file contains a `mesg n` line which is
  566. # producing some `stdin: is not a tty` messages. To hide them, we hide
  567. # stderr from this part by setting runc_hide_stderr.
  568. [% c("remote_exec", { exec_as_root => 1, exec_cmd => 'chown -R ' _ c("var/container/user") _ ' ' _ dst, runc_hide_stderr => 1 }) %]
  569. remote_get: |
  570. #!/bin/sh
  571. set -e
  572. [%
  573. SET src = shell_quote(c('get_src', { error_if_undef => 1 }));
  574. SET dst = shell_quote(c('get_dst', { error_if_undef => 1 }));
  575. -%]
  576. mkdir -p [% dst %]
  577. srcdir='[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs/[% src %]
  578. sudo chown -R $(whoami) "$srcdir"
  579. if [ $(ls -1 "$srcdir"/* 2> /dev/null | wc -l) -gt 0 ]
  580. then
  581. for file in "$srcdir"/*
  582. do
  583. bname="$(basename "$file")"
  584. test -e [% dst %]/"$bname" && rm -Rf [% dst %]/"$bname"
  585. mv -f "$file" [% dst %]/
  586. done
  587. fi
  588. remote_finish: |
  589. #!/bin/sh
  590. set -e
  591. sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
  592. rmdir '[% c("var/container/dir") %]'
  593. ENV:
  594. TZ: UTC
  595. LC_ALL: C
  596. --- |
  597. # This part of the file contains options written in perl
  598. use IO::CaptureOutput qw(capture_exec);
  599. (
  600. var_p => {
  601. # runc100 is true if we are using runc >= 1.0.0
  602. # we assume that any version that is not 0.1.1 is >= 1.0.0
  603. runc100 => sub {
  604. my ($out) = capture_exec('sudo', 'runc', '--version');
  605. return !($out =~ m/^runc version 0.1.1/);
  606. },
  607. # runc_spec100 is true if runc spec is at least 1.0.0
  608. # We will need to update this when there is a new spec version available
  609. runc_spec100 => sub {
  610. my ($out) = capture_exec('sudo', 'runc', '--version');
  611. return $out =~ m/^.*spec: 1\.[0-9]+\.[0-9]+(?:-dev)?$/m;
  612. },
  613. nightly_torbrowser_version => sub {
  614. state $version = '';
  615. return $version if $version;
  616. my (undef, undef, undef, $day, $mon, $year) = gmtime;
  617. $version = sprintf("tbb-nightly.%u.%02u.%02u", $year + 1900, $mon + 1, $day);
  618. return $version;
  619. },
  620. nightly_torbrowser_incremental_from => sub {
  621. my ($project, $options) = @_;
  622. my $nightly_dir = project_config($project, 'basedir', $options) . '/nightly';
  623. my $current_version = project_config($project, 'var/torbrowser_version', $options);
  624. use Path::Tiny;
  625. return [] unless -d $nightly_dir;
  626. my @dirs = sort map { $_->basename } path($nightly_dir)->children(qr/^tbb-nightly\./);
  627. my $nb_incr = project_config($project, ['var', 'max_torbrowser_incremental_from'], $options);
  628. my @res;
  629. while ($nb_incr > 0) {
  630. my $dir = pop @dirs;
  631. last unless $dir;
  632. next if $dir eq $current_version;
  633. $nb_incr--;
  634. push @res, $dir;
  635. }
  636. return [@res];
  637. },
  638. },
  639. )