# Maintainer (arch): Florian Pritz <bluewind@xinu.at>
# Contributor: Dan McGee <dan@archlinux.org>
# Contributor: Isaac David <isacdaavid@at@isacdaavid@dot@info>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Esteban Carnevale <alfplayer@mailoo.org>
# Maintainer: Parabola Hackers <dev@lists.parabola.nu>
# Contributor: bill-auger <bill-auger@programmer.net>


# NOTE: to build and publish this package properly:
#       * modify '/mirrorlist.txt' on the tier-0 repo server:
#         1) update the list of mirrors
#         2) update "Last Updated:" to the current date in the form: YYYY-MM-DD
#       * modify this PKGBUILD:
#         1) set 'pkgver' to the same date, but in the form: YYYYMMDD
#         2) update 'sha256sums' (`makepkg -g`, `sha256sums`, `upgpkg`, or equivalent)
#       This is necessary in order that the repo mirrorlist, the packaged mirrorlist,
#       and the $pkgver will all reflect the same date.


pkgname=pacman-mirrorlist
pkgver=20250825
pkgrel=1.parabola2
pkgdesc="Parabola GNU/Linux-libre mirror list for use by pacman"
arch=(any)
url=https://wiki.parabola.nu/Repositories
license=(GPL)

backup=(etc/pacman.d/mirrorlist)
source=(mirrorlist-${pkgver}.txt::https://repo.parabola.nu/mirrorlist.txt)

sha256sums=('4e2cdfbf4bc6b5389f290293f045791490a09a4cc23d7f9b67b24b94a5a4eec9')


prepare()
{
  local dt="$(sed 's|.*Last Updated:||p ; /^/d ;' mirrorlist-${pkgver}.txt | tr -d ' -')"

  if   [[ "${pkgver}" != "${dt}" ]]
  then echo "ERROR: \$pkgver: '${pkgver}' differs from the repo mirrorlist date: '${dt}'."
       echo "       \$pkgver should be as the form: YYYYYMMDD."
       echo "       The mirrorlist date may be as either of the forms: YYYYYMMDD or YYYYY-MM-DD."
       echo "       Please change one of them such that the Ys, Ms, and Ds match."
       return 1
  fi
}

package()
{
  install -Dm644 mirrorlist-${pkgver}.txt "${pkgdir}"/etc/pacman.d/mirrorlist
}
