# vim: filetype=yaml sw=2
debug: '[% GET ! ENV.RBM_NO_DEBUG %]'
compress_tar: gz
output_dir: "out/[% project %]"
build_log: 'logs/[% project %]-[% c("var/osname") %].log'

pkg_type: build

var:
  torbrowser_version: '6.5n'
  project_name: tor-browser
  multi_lingual: 0
  build_mar: 1
  # By default, we sort the list of installed packages. This allows sharing
  # containers with identical list of packages, even if they are not listed
  # in the same order. In the cases where the installation order is
  # important, sort_deps should be set to 0.
  sort_deps: 1
  build_id: '[% sha256(c("var/build_id_txt")).substr(0, 6) %]'
  build_id_txt: |
    [% c("version") %]
    [% IF c("git_hash") || c("hg_hash"); GET c("abbrev"); END; %]
    [% IF c("remote_docker") -%]
    [% c("distribution") %]
    [% END -%]
    input_files: [% c("input_files_id") %]
    build:
    [% c("build", { filename => 'f', output_dir => '/out' }) %]
  input_files_list: |
    [% FOREACH file IN c("input_files_by_name").keys.sort -%]
    [% c("input_files_by_name/" _ file) %]
    [% END -%]

  touch: "[% USE date %]touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %]"

  locale_ja: ja
  locales:
    - ar
    - de
    - es-ES
    - fa
    - fr
    - it
    - '[% c("var/locale_ja") %]'
    - ko
    - nl
    - pl
    - pt-BR
    - ru
    - tr
    - vi
    - zh-CN

  sign_build: '[% ENV.RBM_SIGN_BUILD %]'
  sign_build_gpg_opts: '[% ENV.RBM_GPG_OPTS %]'


targets:
  notarget: linux-x86_64
  noint:
    debug: 0

  nightly:
    var:
      multi_lingual: 1

  torbrowser-testbuild:
    - testbuild
    - alpha
  testbuild:
    var:
      # To make build faster, don't build any locale
      locales: []
      # Don't create mar files to save time
      build_mar: 0

  torbrowser-linux-x86_64:
    - linux-x86_64
    - linux
  torbrowser-linux-i686:
    - linux-i686
    - linux
  linux-x86_64:
    arch: x86_64
    var:
      osname: linux-x86_64
      deps:
        - build-essential
        - python
        - bison
        - hardening-wrapper
        - automake
        - libtool
        - zip
        - unzip
  linux-i686:
    arch: i686
    var:
      osname: linux-i686
      configure_opt: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32'
      pre_pkginst: dpkg --add-architecture i386
      deps:
        - libc6-dev-i386
        - build-essential
        - python
        - bison
        - hardening-wrapper
        - automake
        - libtool
        - zip
        - unzip
  linux:
    distribution: Debian-7.11
    var:
      linux: 1
      compiler: gcc

  torbrowser-windows-i686:
    - windows-i686
  windows-i686:
    distribution: Ubuntu-12.04
    arch: i686
    var:
      windows: 1
      osname: windows-i686
      configure_opt: '--host=i686-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
      CFLAGS: '-specs=/var/tmp/dist/mingw-w64/msvcr100.spec [% c("var/flag_mwindows") %] -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security'
      LDFLAGS: '-specs=/var/tmp/dist/mingw-w64/msvcr100.spec [% c("var/flag_mwindows") %] -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$gcclibs'
      flag_mwindows: '-mwindows'
      compiler: mingw-w64
      deps:
        - build-essential
        - python
        - bison
        - automake
        - libtool
        - zip
        - unzip

  torbrowser-osx-x86_64:
    - osx-x86_64
  osx-x86_64:
    distribution: Debian-7.11
    arch: x86_64
    var:
      osx: 1
      osname: osx-x86_64
      compiler: 'macosx-toolchain'
      configure_opt: '--host=x86_64-apple-darwin10 CC="x86_64-apple-darwin10-clang [% c("var/FLAGS") %]" CXX="x86_64-apple-darwin10-clang++ [% c("var/FLAGS") %]"'
      FLAGS: "-target x86_64-apple-darwin10 -mlinker-version=136 -B $cctoolsdir -isysroot $sysrootdir"
      locale_ja: ja-JP-mac
      deps:
        - build-essential
        - python
        - bison
        - automake
        - libtool
        - zip
        - unzip

  # The no_build_id target can be useful if you want to quickly display
  # a build template or other option but don't want to spend time to
  # compute the various build ids
  no_build_id:
    var:
      build_id: 1


docker_image: '[% pc("docker-image", "docker_save_image") %]'
docker_image_prefix: '[% GET c("var/project_name") ? c("var/project_name") : "rbm-build" %]_[% GET ENV.RBM_BUILDNAME ? ENV.RBM_BUILDNAME : ENV.USER ? ENV.USER : c("uid") %]'

# change the default gpg_wrapper to allow git tag signed using an
# expired key.
# https://bugs.torproject.org/19737
gpg_wrapper: |
  #!/bin/bash
  export LC_ALL=C
  [%
      IF c('gpg_keyring');
          SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) _ ' --no-default-keyring';
      END;
  -%]
  if [ $# -eq 4 ] && [ "$1" = '--status-fd=1' ] \
      && [ "$2" = '--verify' ]
  then
        [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@" | sed 's/^\[GNUPG:\] EXPKEYSIG /\[GNUPG:\] GOODSIG /'
        exit ${PIPESTATUS[0]}
  else
        exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "$@"
  fi
