# Maintainer (arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Christian Hesse <eworm@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>
# Maintainer: Parabola Hackers <dev@lists.parabola.nu>
# Contributor: bill-auger <bill-auger@programmer.net>


# parabola changes and rationale:
# - require nonsystemd providers of 'systemd' 'libsystemd'


pkgname=procps-ng
pkgver=4.0.4
pkgrel=3
pkgrel+=.nonsystemd1
pkgdesc='Utilities for monitoring your system and its processes'
url='https://gitlab.com/procps-ng/procps'
license=(GPL LGPL)
arch=(x86_64)
arch+=(armv7h i686 ppc64le)
depends=(glibc ncurses libncursesw.so systemd-libs)
depends=( ${depends[*]/systemd-libs/libsystemd} )
makedepends=(systemd)
conflicts=(procps sysvinit-tools)
provides=(procps sysvinit-tools libproc2.so)
replaces=(procps sysvinit-tools)
options=('!emptydirs')
validpgpkeys=('5D2FB320B825D93904D205193938F96BDF50FEA5') # Craig Small <csmall@debian.org>
source=(https://downloads.sourceforge.net/project/$pkgname/Production/${pkgname}-${pkgver}.tar.xz{,.asc}
        0001-build-sys-Add-systemd-elogind-to-w.patch
        0002-ps-Don-t-crash-when-using-short-option.patch)
sha256sums=('22870d6feb2478adb617ce4f09a787addaf2d260c5a8aa7b17d889a962c5e42e'
            'SKIP'
            '77ed82ad684c71319704080a09c7d65efa1b06db4f35b240de7c30fef4caafc5'
            '2331953f1c859b4973b2f99fbc84495b03a2d5e584370da66adbd45cbbf7825a')
b2sums=('63b972666ef9e92042be96739ffa15c787d0346b2d3ffcb0d240b0a4e999dc90024b2c5b058df683dd9d2c436ceb812abd0b115cc877a6ca1023988b86de443f'
        'SKIP'
        '021b64fac3b48175ec67d180fc294c674088ece483f0ab358c2cfbdbd519ac6dea13274a66624beda79b00c0c770441e7f8369f3a75a90f7cafd469508a81e16'
        '74a40306c3a1c09d1ad26ae34157803e48e95906febcd4730ac27221e5c6184b9fe1eb7ade77e2da193d4c3491d719b1a1b01f75424722a63602f914aa9db9a8')

prepare() {
  cd procps-ng-$pkgver
  sed 's:<ncursesw/:<:g' -i src/watch.c
  patch -Np1 < ../0001-build-sys-Add-systemd-elogind-to-w.patch
  patch -Np1 < ../0002-ps-Don-t-crash-when-using-short-option.patch
  autoreconf -fi
}

build() {
  cd procps-ng-$pkgver
  ./configure \
    --prefix=/usr \
    --exec-prefix=/ \
    --sysconfdir=/etc \
    --libdir=/usr/lib \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --enable-watch8bit \
    --with-elogind \
    --disable-modern-top \
    --disable-kill

  make
}

package() {
  cd procps-ng-$pkgver
  make DESTDIR="$pkgdir" install
}
