# 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=1.1
pkgdesc='The basic file, shell and text manipulation utilities of the GNU operating system'
license=('GPL-3.0-or-later' 'GFDL-1.3-or-later')
url='https://www.gnu.org/software/coreutils/'
ncxfat_makedepends=('binutils' 'glibc' 'acl' 'attr' 'gmp' 'libcap' 'openssl' 'gcc')
ncxfab_makedepends=('base-devel' 'make' 'sh' 'crosspacman' 'coreutils')
source=("https://ftp.gnu.org/gnu/coreutils/coreutils-$pkgver.tar.xz"{,.sig})
validpgpkeys=('6C37DC12121A5006BC1DB804DF6FD971306037D9') # Pádraig Brady
sha256sums=('cd328edeac92f6a665de9f323c93b712af1858bc2e0d88f3f7100469470a1b8a'
            'SKIP')

prepare() {
  cd coreutils-$pkgver
  # 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 coreutils-$pkgver
  ./configure \
      --prefix=$MPKG_USRPATH \
      --libexecdir=$MPKG_USRPATH/lib \
      --host=$MPKG_TARGETMACHINE \
      --with-openssl \
      --enable-no-install-program=groups,hostname,kill,uptime
  make
}

check() {
  cd coreutils-$pkgver
  make check
}

package() {
  ncxfat_depends=('glibc' 'acl' 'attr' 'gmp' 'libcap' 'openssl')
  cd coreutils-$pkgver
  make DESTDIR="$pkgdir" install
  rm "${pkgdir}"$MPKG_USRPATH/share/info/dir
}

# vim:set ts=2 sw=2 et:
