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

pkgname=reflector
pkgver=2021.4
pkgrel=1
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.archlinux.ca/projects/reflector"
replaces=(${pkgname}-parabola)
conflicts=(${pkgname}-parabola)
depends=(python3)
optdepends=('rsync: rate rsync mirrors')
backup=(etc/xdg/reflector/reflector.conf)
source=(
  https://xyne.archlinux.ca/projects/reflector/src/reflector-${pkgver}.tar.xz{,.sig}
  rebranding.patch
)
sha512sums=('4bae2191710a6321128a817cf98f8e2fa4a01e8437ef707488e07dec3f22efa84734766252b53fb0b2ab4fcf72600bd866e9c7a9caae68adaa3f485e5cc066ef'
            'SKIP'
            '839aa6012ca8b3fad82e0f7480e055a23fda11af2ca9f890e9c2919ecd50869888992169045ae9ddee30271cb6fd7cf864ce1bb090a5c4be4f382051bc9fddd7')

validpgpkeys=('EC3CBE7F607D11E663149E811D1F0DC78F173680')

prepare ()
{
  cd "$pkgname-$pkgver"
  # Rebranding for Parabola
  gunzip "man/${pkgname}.1.gz"
  patch -Np1 -i ../rebranding.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"
}
