# Maintainer (arch): Xyne <ac xunilhcra enyx, backwards>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: grizzlyuser <grizzlyuser@protonmail.com>

pkgname=reflector
pkgver=2021.11
pkgrel=3
pkgrel+=.parabola1
pkgdesc='A Python 3 module and script to retrieve and filter the latest Pacman mirror list (Parabola rebranded)'
arch=(any)
license=(GPL)
url="https://xyne.dev/projects/reflector"
depends=(python3)
optdepends=('rsync: rate rsync mirrors')
backup=(etc/xdg/reflector/reflector.conf)
source=(
  https://xyne.dev/projects/reflector/src/reflector-2021.11.tar.xz
  https://xyne.dev/projects/reflector/src/reflector-2021.11.tar.xz.sig
)
source+=(9001-branding.patch)
sha512sums=(
  8b7f3cebce9d1f18ecda55d3fe3440eaca51733826c764b2f6ee52edc1e8a31a4b4ae3aa415688c975425888eb30ff8791c8525a629928b064502ddbde93da3e
  fa4e1371fdc91639350200d0e0ac7ca5159d544a53949f93caf2a9636b25c04930f5058b12d42fae9d1776148cb02081f83e6fc19a594eb6e2b8167e29865763
)
md5sums=(
  b3c5051d6aa5d80de77d9e3905953e39
  4e715de9dc7f7f935621cf10a3d63a24
)
sha512sums+=(dacacd6f8ae9a0b919c3560cf3f52812695a96cf24c4b12725a76e11bcdd4d7ad0c74481e49ef6f43fe0e5d46f4ad4aacc38c4ddaf58dd05539de5c27f0c1b23)
md5sums+=(44bbdacd5aa999d85ec2b849af167bb4)
validpgpkeys=('EC3CBE7F607D11E663149E811D1F0DC78F173680')

prepare ()
{
  cd "$pkgname-$pkgver"

  # Rebranding for Parabola
  gunzip "man/${pkgname}.1.gz"
  patch -Np1 -i ../9001-branding.patch
  gzip "man/${pkgname}.1"
}

package ()
{
  cd "$srcdir/$pkgname-$pkgver"
  python3 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1
  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"
}
