# Maintainer: Joey Yakimowich-Payne <jyapayne@pm.me>
#
# Which Arch Linux a BlueRune system updates to (PLAN.md, Phase 13): bluerune-updates writes
# /etc/pacman.d/bluerune-arch, the servers of pacman's [core], [extra] and [multilib] on an
# installed BlueRune: the snapshot of the date BlueRune's channel is tested with
# (https://pkgs.bluerune.dev/arch/<date>/), or, following Arch directly, the system's own
# mirrors. /etc/bluerune/updates.conf says which; a pacman hook and a timer keep the date
# current, and a second hook warns before an untested Hyprland comes. The files here are
# links to dist/updates; release/publish.sh resolves them. pkgver counts changes to them.

pkgname=bluerune-mirrorlist
pkgver=1
pkgrel=1
pkgdesc="BlueRune's tested Arch date as pacman's mirror list, and a warning before an untested Hyprland"
arch=('any')
url='https://bluerune.dev'
license=('Apache-2.0 OR MIT')
depends=('bash' 'curl' 'pacman' 'systemd')
install=bluerune-mirrorlist.install
source=('bluerune-updates' 'bluerune-mirrorlist.hook' 'bluerune-hyprland.hook' 'bluerune-mirrorlist.service' 'bluerune-mirrorlist.timer')
sha256sums=('90b02a022b21d621bf84ec89467b7c3990894e0d9fb022383abad98572d3063e'
            'dd69519a10cadafc08b64c6ec6da9a890050450444f0b1e36a1ceb5c93e3423b'
            '48ce5ebf5b01008a4329b176f3ade8779e255b4db96de0158b80dfe4bb9d436e'
            'f98891e39d834595feaf62062ede592071990d788840475bf514b77c81ea716c'
            '4ca17fc1ce06fd10326017c59c57f43022ed0df686f6f0bb0a0940004c1dbf81')

package() {
  install -Dm755 bluerune-updates -t "$pkgdir/usr/bin"
  install -Dm644 bluerune-mirrorlist.hook bluerune-hyprland.hook -t "$pkgdir/usr/share/libalpm/hooks"
  install -Dm644 bluerune-mirrorlist.service bluerune-mirrorlist.timer -t "$pkgdir/usr/lib/systemd/system"
  # Enabled by being installed, as archlinux-keyring's timer is.
  install -dm755 "$pkgdir/usr/lib/systemd/system/timers.target.wants"
  ln -s ../bluerune-mirrorlist.timer "$pkgdir/usr/lib/systemd/system/timers.target.wants/bluerune-mirrorlist.timer"
}
