# Maintainer: Ray Donnelly <mingwandroid@gmail.com>

pkgname=pacman-mirrors
pkgver=20210902
pkgrel=1
pkgdesc="MSYS2 mirror list for use by pacman"
arch=('any')
url="https://www.msys2.org/dev/mirrors/"
license=('GPL')
source=(mirrorlist.msys
        mirrorlist.mingw)
sha256sums=('2b583115d62052f477d9df1d1b9a6b997e5c0e7fd01adecdd5e2b0f1467901d7'
            'b5447503f69905b8cef5d3f04e1a0b69c74a925da0326e4838f78bfea4b9725d')
backup=(
  'etc/pacman.d/mirrorlist.msys'
  'etc/pacman.d/mirrorlist.mingw'
  'etc/pacman.d/mirrorlist.mingw32'
  'etc/pacman.d/mirrorlist.mingw64'
  'etc/pacman.d/mirrorlist.ucrt64'
  'etc/pacman.d/mirrorlist.clang64'
  'etc/pacman.d/mirrorlist.clang32'
)
package() {
  mkdir -p ${pkgdir}/etc/pacman.d
  install -m644 ${srcdir}/mirrorlist.msys ${pkgdir}/etc/pacman.d/
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/

  # For backwards compatibility
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/mirrorlist.mingw32
  sed -s 's|$repo|i686|g' -i ${pkgdir}/etc/pacman.d/mirrorlist.mingw32
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/mirrorlist.mingw64
  sed -s 's|$repo|x86_64|g' -i ${pkgdir}/etc/pacman.d/mirrorlist.mingw64
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/mirrorlist.ucrt64
  sed -s 's|$repo|ucrt64|g' -i ${pkgdir}/etc/pacman.d/mirrorlist.ucrt64
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/mirrorlist.clang64
  sed -s 's|$repo|clang64|g' -i ${pkgdir}/etc/pacman.d/mirrorlist.clang64
  install -m644 ${srcdir}/mirrorlist.mingw ${pkgdir}/etc/pacman.d/mirrorlist.clang32
  sed -s 's|$repo|clang32|g' -i ${pkgdir}/etc/pacman.d/mirrorlist.clang32
}
