# Maintainer (Arch): Xyne <ac xunilhcra enyx, backwards>
# Maintainer (Hyperbola): André Silva <emulatorman@parabola.nu>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: grizzlyuser <grizzlyuser@protonmail.com>

pkgname=reflector
pkgver=2020.9
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
  https://xyne.archlinux.ca/projects/reflector/src/reflector-${pkgver}.tar.xz.sig
  rebranding.patch
)
sha512sums=('2cfad4919cd7cd0c3e4be2d99f2ef7d2df3b39254fc5494b2f858fb8f07f22278688a4b3708aecd109f0602d4b93a335ef15e08c3b48f61c2f2090bbaa58fc4e'
            'SKIP'
            '555b7d455ffc29e8d20c938632c0c278959bc4946427680f462e56fb7aa7681780c0f7b0ecf5ff89a9cfca7524d441304fc08feeb4ad167c206003921a09a9ca')

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 -Dm755 "$srcdir/$pkgname-$pkgver/$pkgname" "$pkgdir/usr/bin/$pkgname"
  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"
}
