# You may notice that this bottle named "mamba-org" refers to conda-forge github repo
# This is intentional and not an error

# cask: https://github.com/Homebrew/homebrew-cask/blob/c6e8fd99bdfd5ec217ff3b53505f42214f5cba58/Casks/mambaforge.rb

distributable:
  url: https://github.com/conda-forge/miniforge/archive/refs/tags/22.11.1-4.tar.gz #FIXME UGLY HACK, NEED TO MOVE '-4' TO versions.anytext 
  strip-components: 1

versions:
  - "22.11.1.4"

build:
  dependencies:
    aria2.github.io: '1.36' #FIXME aria2 has heavier dependencies than curl,
                            # ^ when this package is more stable and we no longer need fast local iteration,
                            # ^ look into swapping it for curl
  script: |
    #FIXME mamba provides sha256 signatures, should we check against them before building?
    #      ^ https://github.com/conda-forge/miniforge/releases

    # download mamba installation script
    aria2c -c -o mamba.sh "https://github.com/conda-forge/miniforge/releases/download/22.11.1-4/Mambaforge-22.11.1-4-$PLATFORM.sh"

    # install mamba
    chmod +x mamba.sh
    ./mamba.sh $ARGS

    fix-shebangs.ts {{prefix}}/bin/*

    #FIXME: add caveats
    # Please run the following to setup your shell:
    # mamba init "$(basename "${SHELL}")"   # updates your .zshrc or .bashrc to make mamba & conda usable

  env:
    # env-dependent vars
    darwin/aarch64: {PLATFORM: MacOSX-arm64}
    darwin/x86-64:  {PLATFORM: MacOSX-x86_64}
    linux/aarch64:  {PLATFORM: Linux-aarch64}
    linux/x86-64:   {PLATFORM: Linux-x86_64}
    # mamba install args 
    ARGS:
      - -b                 # skip interactive - accept all licence agreements
      - -s                 # skip running pre/post-link/install scripts
      - -u                 # update if already installed 
      - -p {{prefix}}      # prefix - where to install

test: |
  mamba --version
  conda --version

provides:
  - condabin/conda
  - bin/mamba
