#!/bin/bash

set -ex

if echo $CIP_TAG | grep -q -- -alpine ; then
  echo alpine
  cip sudo apk add cmake
  cip sudo apk add pkgconf-dev
  cip sudo apk add libffi-dev
elif  echo $CIP_TAG | grep -q -- -centos ; then
  echo CentOS
  cip sudo yum install libffi-devel wget -y
elif echo $CIP_TAG | grep -q -- -fedora ; then
  echo Fedora
  cip sudo yum install cmake libffi-devel wget -y
else
  echo Debian or Ubuntu
  cip sudo apt-get update
  cip sudo apt-get -y install pkg-config cmake libffi-dev wget
fi

if [ "x$ALIEN_BUILD_INSTALL_EXTRA" == "x1" ]; then

  if echo $CIP_TAG | grep -q -- -centos ; then
    echo 'skipping cmake3 on CentOS 7'
    # CentOS 7 comes with a 2.x cmake, which doesn't fools Alt::Alien::cmake3::System
    # and doesn't work with our test suite
  else
    cip exec env PERL_ALT_INSTALL=OVERWRITE cpanm -n Alt::Alien::cmake3::System
  fi

  cip exec cpanm -n \
    Test2::Harness \
    File::Listing \
    File::Listing::Ftpcopy \
    HTML::LinkExtor \
    HTTP::Tiny \
    LWP \
    PkgConfig \
    PkgConfig::LibPkgConf \
    Sort::Versions \
    URI \
    YAML \
    Env::ShellWords \
    Archive::Tar \
    Archive::Zip \
    Devel::Hide \
    Readonly \
    Alien::Base::ModuleBuild \
    FFI::Platypus \
    Mojo::DOM58 \
    Mojolicious \
    Win32::Vcpkg \
    Plack \
    Proc::Daemon \
    AnyEvent::FTP \
    Digest::SHA::PurePerl

fi

