# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
filename: 'firefox-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %]'
git_hash: 'tor-browser-[% c("var/firefox_version") %]-[% c("var/torbrowser_branch") %]-1-build2'
tag_gpg_id: 1
git_url: https://git.torproject.org/tor-browser.git
git_submodule: 1
gpg_keyring: torbutton.gpg

var:
  firefox_platform_version: 91.8.0
  firefox_version: '[% c("var/firefox_platform_version") %]esr'
  torbrowser_branch: 11.5
  branding_directory: 'browser/branding/alpha'
  copyright_year: '[% exec("git show -s --format=%ci").remove("-.*") %]'
  deps:
    - build-essential
    - unzip
    - zip
    - autoconf2.13
    - yasm
    - pkg-config
  container:
    use_container: 1

steps:
  src-tarballs:
    filename: 'src-[% project %]-[% c("version") %].tar.xz'
    version: '[% c("git_hash") %]'
    input_files: []
    var:
      container:
        use_container: 0
    targets:
      nightly:
        version: '[% c("abbrev") %]'

  list_toolchain_updates:
    git_url: https://github.com/mozilla/gecko-dev.git
    git_hash: esr91
    tag_gpg_id: 0
    input_files: []
    var:
      container:
        use_container: 0

targets:
  release:
    var:
      branding_directory: 'browser/branding/official'

  nightly:
    git_hash: 'tor-browser-[% c("var/firefox_version") %]-[% c("var/torbrowser_branch") %]-1'
    tag_gpg_id: 0
    var:
      branding_directory: 'browser/branding/nightly'

  linux-x86_64:
    var:
      martools_filename: mar-tools-linux64.zip
      arch_deps:
        - libgtk2.0-dev
        - libgtk-3-dev
        - libdbus-glib-1-dev
        - libxt-dev
        - hardening-wrapper
        # To pass configure since ESR 31.
        - libpulse-dev
        # To pass configure since ESR 52
        - libx11-xcb-dev
        # To support Wayland mode
        - libdrm-dev

  linux-i686:
    var:
      martools_filename: mar-tools-linux32.zip
      sort_deps: 0
      arch_deps:
        - libgtk2.0-dev:i386
        - libgtk-3-dev:i386
        - libdbus-glib-1-dev:i386
        - libxt-dev:i386
        - hardening-wrapper
        # To pass configure since ESR 31.
        - libpulse-dev:i386
        # To pass configure since ESR 52
        - libx11-xcb-dev:i386
        # To support Wayland mode
        - libdrm-dev:i386

  linux-arm:
    var:
      martools_filename: mar-tools-linuxarm.zip

  linux-ppc64le:
    var:
      martools_filename: mar-tools-linuxppc64le.zip

  linux-ppc64:
    var:
      martools_filename: mar-tools-linuxppc64.zip
      post_pkginst: |
        export DEBIAN_FRONTEND=noninteractive
        # Host arch package required by Firefox configure script
        apt-get -y install --no-install-suggests --no-install-recommends libsqlite3-0
        # We need the ports keyring to download ppc64 packages.
        # Faketime is needed on gpgv since we use an old ports snapshot with an expired key.
        # Faketime on apt-get itself produces "invalid signature" errors.
        # The old ports snapshot is to minimize our glibc requirement (glibc 2.28).
        apt-get install -y debian-ports-archive-keyring faketime
        echo "deb http://snapshot.debian.org/archive/debian-ports/20190905/ sid main" > /etc/apt/sources.list.d/ports.list
        mv /usr/bin/gpgv /usr/bin/gpgv.orig
        echo 'faketime 2019-09-05 gpgv.orig $*' > /usr/bin/gpgv
        chmod +x /usr/bin/gpgv
        apt-get update -y -q
        # debian-ports is sid, which conflicts with our buster container.  We
        # work around it by using apt-download to only download a subset of the
        # packages, and then install them with dpkg --force-depends to ignore
        # the conflicting package dependencies.  Yes, this is stupid.
        PACKAGES='libgtk2.0-dev:[% c("var/arch_debian") %] libgtk-3-dev:[% c("var/arch_debian") %] libdbus-glib-1-dev:[% c("var/arch_debian") %] libxt-dev:[% c("var/arch_debian") %] libpulse-dev:[% c("var/arch_debian") %] libx11-xcb-dev:[% c("var/arch_debian") %] libgcc-8-dev:[% c("var/arch_debian") %] libstdc++-8-dev:[% c("var/arch_debian") %]'
        apt-get -y download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends ${PACKAGES} | grep "^\w" | grep -E "^(lib|uuid|wayland|x11|zlib)" | grep -E '(x11|wayland|:[% c("var/arch_debian") %])' | grep -v -E '(sqlite|systemd)')
        mv /usr/bin/gpgv.orig /usr/bin/gpgv
        dpkg --abort-after=500 --force-depends -i *.deb || true

  linux-cross:
    var:
      container:
        use_container: 1
        suite: buster
        arch: amd64
      post_pkginst: |
        export DEBIAN_FRONTEND=noninteractive
        # The recommended packages produce a package conflict.
        apt-get -y install --no-install-suggests --no-install-recommends libgtk2.0-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libgtk-3-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libdbus-glib-1-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libxt-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libpulse-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libx11-xcb-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libgcc-8-dev:[% c("var/arch_debian") %]
        apt-get -y install --no-install-suggests --no-install-recommends libstdc++-8-dev:[% c("var/arch_debian") %]
        # TODO: Build gcc+stdlib from source.
      arch_deps:
        - yasm

  osx-x86_64:
    var:
      martools_filename: mar-tools-mac64.zip
      arch_deps:
        - python3
        - python3-distutils
        - rsync

  windows:
    var:
      arch_deps:
        - python3
        - python3-distutils
        - wine
      compiler: mingw-w64-clang

  windows-i686:
    var:
      martools_filename: mar-tools-win32.zip

  windows-x86_64:
    var:
      martools_filename: mar-tools-win64.zip

input_files:
  - project: container-image
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% ! c("var/linux-cross") || c("var/linux-ppc64le") || c("var/linux-ppc64") %]'
  - filename: get-moz-build-date
  - filename: 'mozconfig-[% c("var/osname") %][% IF c("var/asan") %]-asan[% END %]'
    name: mozconfig
  - project: binutils
    name: binutils
    enable: '[% c("var/linux") %]'
  - filename: fix-info-plist.py
    enable: '[% c("var/osx") %]'
  - filename: linux-arm-neon.patch
    enable: '[% c("var/linux-arm") %]'
  - filename: nsis-uninstall.patch
    enable: '[% c("var/windows") %]'
  - project: rust
    name: rust
  - project: cbindgen
    name: cbindgen
  - project: wasi-sysroot
    name: wasi-sysroot
    enable: '[% c("var/rlbox") %]'
  - project: lucetc
    name: lucetc
    enable: '[% c("var/rlbox") %]'
  - project: node
    name: node
    enable: '[% ! c("var/linux-cross") %]'
  - project: node
    name: node
    enable: '[% c("var/linux-cross") %]'
    target:
      - '[% c("var/channel") %]'
      - 'torbrowser-linux-x86_64'
  - project: nasm
    name: nasm
    enable: '[% ! c("var/linux-cross") %]'
  - project: nasm
    name: nasm
    enable: '[% c("var/linux-cross") %]'
    target:
      - '[% c("var/channel") %]'
      - 'torbrowser-linux-x86_64'
  - project: python
    name: python
    enable: '[% c("var/linux") %]'
  - project: clang
    name: clang
    enable: '[% ! c("var/linux-cross") %]'
  - project: clang
    name: clang
    enable: '[% c("var/linux-cross") %]'
    target:
      - '[% c("var/channel") %]'
      - 'torbrowser-linux-x86_64'
  - project: gcc
    name: gcc-host
    enable: '[% c("var/linux-cross") %]'
    target:
      - '[% c("var/channel") %]'
      - 'torbrowser-linux-x86_64'
  - project: fxc2
    name: fxc2
    enable: '[% c("var/windows") %]'
    target_prepend:
      - torbrowser-windows-x86_64
  - name: mingw-w64
    project: mingw-w64
    enable: '[% c("var/windows") %]'
  - filename: abicheck.cc
    enable: '[% c("var/linux") %]'
  - filename: start-firefox
    enable: '[% c("var/linux") %]'
  - project: tor-launcher
    name: tor-launcher
  - filename: namecoin-torbutton.patch
    enable: '[% c("var/namecoin") %]'
    # TorButton patch authored by Arthur Edelstein, from https://github.com/arthuredelstein/torbutton/ branch 2.1.10-namecoin
  - filename: namecoin-etld.patch
    enable: '[% c("var/namecoin") %]'
