# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
filename: 'firefox-[% c("var/project-name") %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %]'
git_hash: '[% c("var/project-name") %]-[% c("var/firefox_version") %]-[% c("var/browser_branch") %]-build[% c("var/browser_build") %]'
tag_gpg_id: 1
git_url: https://gitlab.torproject.org/tpo/applications/tor-browser.git
gpg_keyring:
  - boklm.gpg
  - brizental.gpg
  - clairehurst.gpg
  - dan_b.gpg
  - ma1.gpg
  - morgan.gpg
  - pierov.gpg
container:
  use_container: 1

var:
  firefox_platform_version: '128.10.0'
  firefox_version: '[% c("var/firefox_platform_version") %]esr'
  browser_series: '14.5'
  browser_rebase: 1
  browser_branch: '[% c("var/browser_series") %]-[% c("var/browser_rebase") %]'
  browser_build: 1
  copyright_year: '[% exec("git show -s --format=%ci " _ c("git_hash") _ "^{commit}", { exec_noco => 1 }).remove("-.*") %]'
  nightly_updates_publish_dir: '[% c("var/nightly_updates_publish_dir_prefix") %]nightly-[% c("var/osname") %]'
  gitlab_project: https://gitlab.torproject.org/tpo/applications/tor-browser
  git_commit: '[% exec("git rev-parse " _ c("git_hash") _ "^{commit}", { exec_noco => 1 }) %]'
  deps:
    - build-essential
    - autoconf
    - yasm
    - pkg-config
  has_l10n: '[% !c("var/testbuild") && c("var/locales").size %]'
  # For testing purposes use override_updater_url, as it will also override the
  # certificate.
  updater_url: 'https://aus1.torproject.org/torbrowser/update_3/'

  # Uncomment this if you want to test the updater. You will need to provide a
  # marsigner.der in this directory, too. It will replace either the release
  # key, or the nightly key, depending on the channel you are building.
  # override_updater_url: 'https://tb-build-05.torproject.org/~you/update_3/'

  rezip: |
    rezip_tmpdir=$(mktemp -d)
    mkdir -p "$rezip_tmpdir/z"
    unzip -q -d "$rezip_tmpdir/z" -- [% c("rezip_file") %] || [ $? -lt 3 ]
    pushd "$rezip_tmpdir/z"
    [% c("zip", {
      zip_src => [ '.' ],
      zip_args => '$rezip_tmpdir/new.zip',
    }) %]
    popd
    mv -f -- "$rezip_tmpdir/new.zip" [% c("rezip_file") %]
    rm -Rf "$rezip_tmpdir"

  l10n-changesets: '[% exec("git --no-pager show " _ c("git_hash") _ ":browser/locales/l10n-changesets.json", { exec_noco => 1 }) %]'

steps:
  src-tarballs:
    filename: 'src-[% project %]-[% c("version") %].tar.xz'
    version: '[% c("git_hash") %]'
    input_files:
      - project: container-image
        pkg_type: build
    compress_tar: ''
    container:
      use_container: 1
    var:
      # single-thread and multi-thread xz will generate a different result,
      # se we use at least 2 threads
      xz_threads: '[% c("num_procs") == "1" ? "2" : c("num_procs") %]'
    src-tarballs: |
      #!/bin/bash
      set -e
      mkdir -p '[% dest_dir %]'
      # Files copied to the container are owned by group root (rbm#40074),
      # and it seems xz doesn't like that and exits with an error
      chgrp rbm '[% project %]-[% c("version") %].tar'
      xz --threads=[% c("var/xz_threads") %] -f '[% project %]-[% c("version") %].tar'
      mv -vf '[% project %]-[% c("version") %].tar.xz' '[% dest_dir %]/[% c("filename") %]'
    targets:
      nightly:
        version: '[% c("abbrev") %]'

  list_toolchain_updates:
    git_hash: tor-browser-128.0b1-14.0-1
    tag_gpg_id: 0
    input_files: []
    container:
      use_container: 0

targets:
  basebrowser:
    var:
      nightly_updates_publish_dir_prefix: basebrowser-

  nightly:
    git_hash: '[% c("var/project-name") %]-[% c("var/firefox_version") %]-[% c("var/browser_branch") %]'
    tag_gpg_id: 0
    var:
      updater_url: 'https://nightlies.tbb.torproject.org/nightly-updates/updates/[% c("var/nightly_updates_publish_dir") %]'

  mullvadbrowser:
    git_url: https://gitlab.torproject.org/tpo/applications/mullvad-browser.git
    var:
      gitlab_project: https://gitlab.torproject.org/tpo/applications/mullvad-browser
      updater_url: 'https://cdn.mullvad.net/browser/update_responses/update_1/'
      nightly_updates_publish_dir_prefix: mullvadbrowser-
  linux-x86_64:
    var:
      arch_deps:
        - libgtk2.0-dev
        - libgtk-3-dev
        - libdbus-glib-1-dev
        - libxt-dev
        # To pass configure since ESR 31
        - libpulse-dev
        # To pass configure since ESR 52
        - libx11-xcb-dev
        # To pass configure since ESR 102
        - libasound2-dev
        # To support Wayland mode
        - libdrm-dev
      libdir: lib64

  linux-i686:
    var:
      sort_deps: 0
      arch_deps:
        - libgtk2.0-dev:i386
        - libgtk-3-dev:i386
        - libdbus-glib-1-dev:i386
        - libxt-dev:i386
        # To pass configure since ESR 31
        - libpulse-dev:i386
        # To pass configure since ESR 52
        - libx11-xcb-dev:i386
        # To pass configure since ESR 102
        - libasound2-dev:i386
        # To support Wayland mode
        - libdrm-dev:i386
      libdir: lib32

  linux-aarch64:
    var:
      no_install_recommends: 1
      arch_deps:
        - libgtk2.0-dev:arm64
        - libgtk-3-dev:arm64
        - libdbus-glib-1-dev:arm64
        - libxt-dev:arm64
        # To pass configure since ESR 31
        - libpulse-dev:arm64
        # To pass configure since ESR 52
        - libx11-xcb-dev:arm64
        # To pass configure since ESR 102
        - libasound2-dev:arm64
        # To support Wayland mode
        - libdrm-dev:arm64
      libdir: lib64

  macos:
    var:
      nightly_updates_publish_dir: '[% c("var/nightly_updates_publish_dir_prefix") %]nightly-macos'
      arch_deps:
        - python3
        - python3-distutils
        - rsync

  windows:
    var:
      arch_deps:
        - python3
        - python3-distutils
        - wine

input_files:
  - project: container-image
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    # Cross-binutils are already included in the cross-compiler
  - project: binutils
    name: binutils
    enable: '[% c("var/linux") && ! c("var/linux-cross") %]'
  - filename: rename-branding-strings.py
    enable: '[% c("var/has_l10n") && c("var/tor-browser") %]'
  - filename: fix-info-plist.py
    enable: '[% c("var/macos") %]'
  - filename: nsis-uninstall.patch
    enable: '[% c("var/windows") %]'
  - project: rust
    name: rust
  - project: cbindgen
    name: cbindgen
  - project: firefox-l10n
    name: firefox-l10n
    enable: '[% c("var/has_l10n") %]'
  - project: wasi-sysroot
    name: wasi-sysroot
    enable: '[% c("var/rlbox") %]'
  - project: node
    name: node
  - project: nasm
    name: nasm
    enable: '[% ! c("var/linux-aarch64") %]'
  - project: python
    name: python
    enable: '[% c("var/linux") %]'
  - project: clang-linux
    name: clang
    enable: '[% c("var/linux") %]'
  - project: fxc2
    name: fxc2
    enable: '[% c("var/windows") %]'
    target_prepend:
      - torbrowser-windows-x86_64
  - project: windows-rs
    name: windows-rs
    enable: '[% c("var/windows") %]'
    norec:
      sha256sum: b26e710d553733cd1202bf932624d51a43d1f8679217c97bd05c0248e0c1c090
  - filename: abicheck.cc
    enable: '[% c("var/linux") %]'
  - project: translation
    name: translation-base-browser
    pkg_type: base-browser
    enable: '[% c("var/has_l10n") %]'
  - project: translation
    name: translation-tor-browser
    pkg_type: tor-browser
    enable: '[% c("var/tor-browser") && c("var/has_l10n") %]'
  - project: translation
    name: translation-mullvad-browser
    pkg_type: mullvad-browser
    enable: '[% c("var/mullvad-browser") && c("var/has_l10n") %]'
  - filename: marsigner.der
    enable: '[% c("var/override_updater_url") %]'
  - 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") %]'
