# Contributor: Camille Moncelier <pix@devlife.org>, simo <simo@archlinux.org>
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>

pkgname=kexec-tools
pkgver=2.0.28
pkgrel=2
pkgdesc="Load another kernel from the currently executing Linux kernel"
arch=('x86_64' 'aarch64')
url="https://kernel.org/pub/linux/utils/kernel/kexec/"
source=("git+https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git#tag=v${pkgver}"
         'binutils-2.41.patch')
makedepends=('git')
depends=('zlib' 'xz')
license=('GPL-2.0-or-later')
b2sums=('a11aaef9190cc2f4470a35085fcfc61609c356c42ded1b5269501f91bbde234401da5151f03d3fcfe9f39c8d02ff67d65549f2cdd5f2cbc551863a7d34788321'
        '57b9830fc3e522d04b8d0db091502d2b101103a68af7c3c1099ea18d8b8d8b7f4a5ccbafebda38e7c7dce43172658dff8a786a5ae4452ad40b57e0161015550e')

prepare() {
  cd $pkgname
  ./bootstrap
  patch -Np1 -i $srcdir/binutils-2.41.patch
}

build() {
  cd $pkgname
  CFLAGS+=' -fcommon' # https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common
  ./configure --prefix=/usr --sbindir=/usr/bin --without-lzma
  make
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -D -m644 kexec/kexec.8 "$pkgdir"/usr/share/man/man8/kexec.8
}

