rbm.conf 18 KB

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