# Maintainer (Arch:extra): Bert Peters <bertptrs@archlinux.org>
# Contributor (Arch:extra): Xyne <gro xunilhcra enyx, backwards>
#
# Maintainer: Luke T. Shumaker <lukeshu@parabola.nu>
# Contributor: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: grizzlyuser <grizzlyuser@protonmail.com>
#
# Rationale for inclusion in [libre]: extra/reflector, but point at Parabola URLs.

pkgname=reflector
pkgver=2023
pkgrel=5
pkgdesc='A Python 3 module and script to retrieve and filter the latest Pacman mirror list.'
arch=(any)
license=(GPL-2.0-only)
url="https://xyne.dev/projects/reflector"
depends=(python)
makedepends=(python-build python-installer python-setuptools python-wheel)
optdepends=('rsync: rate rsync mirrors')
backup=(etc/xdg/reflector/reflector.conf)
source=(https://xyne.dev/projects/reflector/src/reflector-2023.tar.xz{,.sig}
        mp-fork.patch)

sha512sums=('11aec550c15080695525409f11eae6d4b545df8b37a8e0727de939eefec2b2fa6aa95c5c3500a6c8a940b6060cdaf2526430ed47e01a3c6f098e1b77189eb479'
            'SKIP'
            '6bbb85a7e829b18ebc7451c38e7ef8ebb9c2d05dac7ab981fc8712b365867faa264eae177a0536a3ad72ffedbf5a6251fed4c6c834879b7e8ada9035ffbdb28e'
            '3ee387ccd1fbd36ce4b9499a602981cae2f30335671b6d27376b3c179e7108dd3ae21121e1a59310720e458dcd9e73d949603a5abc7e16b5c6ab8e5b9b6dc625')
b2sums=('24ee3610eb94e4412bceba40f4763def380028683358cb1016546a4d0bb12eaa69aba4e83b7998ebb74ee6f025f9f342901d076e44302da47d0ed14b727fb9c1'
        'SKIP'
        '37d9980afa27eaf80796d090327c0ce0f78772d4ea8a651bd2fe37af29f002dcff434d9839f930317c4d441cf4236d60ad95676489ae0a22dbe0c37bbae765ef'
        'dcb6d5f38b13b1b7bd783cc3f43bb6f4663dd7d88c693588c68583fed9e6ba375810caa819e84defb68c6c1249efcb5ab4f0eeb5d14168fffc3230af9f0a65a9')
validpgpkeys=('D89FAAEB4CECAFD199A2F5E612C6F735F7A9A519') # "Xyne. (Replaces EC3CBE7F607D11E663149E811D1F0DC78F173680.) <xyne@archlinux.org>"

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
}

package ()
{
  # Parabola: pin the python version
  _python_version=$(pacman -S --print-format='%v' python|cut -d- -f1|cut -d. -f1,2)
  depends+=("python>=${_python_version}" "python<${_python_version%.*}.$(( ${_python_version##*.} + 1 ))")

  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 "man/${pkgname}.1.gz" "${pkgdir}/usr/share/man/man1/${pkgname}.1.gz"
  install -Dm644 'reflector.service' "$pkgdir/usr/lib/systemd/system/reflector.service"
  install -Dm644 'reflector.timer' "$pkgdir/usr/lib/systemd/system/reflector.timer"
  install -Dm644 'reflector.conf' "$pkgdir/etc/xdg/reflector/reflector.conf"
}


# vim: set ts=2 sw=2 et:

# Parabola: rebranding
pkgrel+=.parabola1
source+=(9001-branding.patch)
prepare() {
  cd $pkgname-$pkgver
  gunzip "man/${pkgname}.1.gz"
  patch -Np1 -i ../9001-branding.patch
  gzip "man/${pkgname}.1"
}
