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

pkgname=pacman-mirrors
pkgver=20251022
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=('d0b8c8f2ddaf61260f5c57d652c27dd91ffc3ba45cd1484c29cf384e9cda3bcc'
            'd8f9f5309c648c5fc9328c0e1c6a0f82bb4bca6de695eaf02bc319ba187c9dae')
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'
)
msys2_references=(
  'internal'
)

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
}
