# Maintainer: Vasiliy Stelmachenok <ventureo@cachyos.org>
pkgname=cachyos-kdump-tools
pkgver=1.1.1
pkgrel=1
pkgdesc="Utility for easy creation of kernel dumps after panics"
url="https://github.com/CachyOS/cachyos-kdump-tools"
license=(GPL-3.0-or-later)
arch=('any')
depends=('kexec-tools' 'makedumpfile' 'systemd')
makedepends=('git')
optdepends=(
    'linux-cachyos-dbg: For analyzing dumps'
    'crash: For analyzing dumps'
    'drgn: For analyzing dumps'
)
source=("git+https://github.com/CachyOS/$pkgname#tag=$pkgver")
sha256sums=('3481e0f7458b2f488ab82db9d1a4fb27e5475cea6e81b0226895398b88a23ae3')
install="${pkgname}.install"

package() {
    cd "$pkgname"
    install -Dm644 disable-hardened-kexec.conf "${pkgdir}/usr/lib/sysctl.d/disable-hardened-kexec.conf"
    install -Dm644 kdump.service "${pkgdir}/usr/lib/systemd/system/kdump.service"
    install -Dm644 kdump-collect.service "${pkgdir}/usr/lib/systemd/system/kdump-collect.service"
    install -Dm755 kdump "${pkgdir}/usr/bin/kdump"
    install -Dm755 trigger-kernel-panic "${pkgdir}/usr/bin/trigger-kernel-panic"
    install -m755 -d "${pkgdir}/usr/lib/systemd/system/emergency.target.wants"
    ln -s "../kdump-collect.service" "${pkgdir}/usr/lib/systemd/system/emergency.target.wants/kdump-collect.service"
}
