# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Sébastien "Seblu" Luttringer
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: judd <jvinet@zeroflux.org>

pkgname=coreutils
pkgver=9.5
pkgrel=2
pkgdesc='The basic file, shell and text manipulation utilities of the GNU operating system'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(
  GPL-3.0-or-later
  GFDL-1.3-or-later
)
url='https://www.gnu.org/software/coreutils/'
depends=( 
  acl  
  attr
  glibc
  gmp
  libcap
  openssl
)
makedepends=(
  git
  gperf
  # python enable for upcoming 9.6
  wget
)
source=(
  git+https://git.savannah.gnu.org/git/coreutils.git?signed#tag=v${pkgver}
  gcc14-gnulib-lto.patch
)
validpgpkeys=(
 6C37DC12121A5006BC1DB804DF6FD971306037D9 # Pádraig Brady
)
b2sums=('7b48eaa372037f1162335dacbc6460a1455e7b6c73badefd631b1a47cfab6072db938a25ce9bdba68c2b3ac13e9c64df06fef6f135d2979199cb09f41f83454a'
        '1264b815101ebf98ce846ac96a649cc7964624ae0c140f23d41f2d2e8292f67b0c0cad3d66f6329a2d21c530b1cfbff65ef378abd8e49f3a1ac972a1cf88366d')

prepare() {
  cd "${pkgname}"
  ./bootstrap
  # apply patch from the source array (should be a pacman feature)
  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    echo "Applying patch $src..."
    patch -Np1 < "../$src"
  done
}

build() {
  cd "${pkgname}"
  ./configure \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --with-openssl \
    --enable-no-install-program=groups,hostname,kill,uptime
  make
}

check() {
  cd "${pkgname}"
  make check
}

package() {
  cd "${pkgname}"
  make DESTDIR="${pkgdir}" install
}

