# $Id: PKGBUILD 86506 2010-08-02 14:22:19Z tpowa $
# Maintainer: judd <jvinet@zeroflux.org>
pkgname=util-linux-ng
pkgver=2.18
pkgrel=3
pkgdesc="Miscellaneous system utilities for Linux"
url="http://userweb.kernel.org/~kzak/util-linux-ng/"
arch=('i686' 'x86_64')
groups=('base')
depends=('bash' 'ncurses>=5.7' 'zlib' 'filesystem')
replaces=('linux32' 'util-linux')
conflicts=('linux32' 'util-linux' 'e2fsprogs<1.41.8-2')
provides=('linux32' 'util-linux')
license=('GPL2')
options=('!libtool')
source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v2.18/${pkgname}-${pkgver}.tar.bz2
        fix-findmnt.patch
        util-linux-ng-nilfs2.patch
        util-linux-ng-cfdisk.patch)
optdepends=('perl: for chkdupexe support')
install=util-linux-ng.install
md5sums=('2f5f71e6af969d041d73ab778c141a77'
         '7346673932b165faadde2fa2a9c1cd3a'
         'aa1f210aa22363605363b7b14b8f7a78'
         'e6d9309d44c258b25a7fb0b70f94f94e')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  # hardware clock
  sed -e 's%etc/adjtime%var/lib/hwclock/adjtime%' -i hwclock/hwclock.c || return 1
  mkdir -p "${pkgdir}/var/lib/hwclock" || return 1
  # fix findmnt
  patch -p1 -i "${srcdir}/fix-findmnt.patch"
  # add nilfs2 support, included in next upstream release
  patch -Np1 -i "${srcdir}/util-linux-ng-nilfs2.patch"
  # fix cfdisk partition changing, included in next upstream release
  patch -Np1 -i "${srcdir}/util-linux-ng-cfdisk.patch"

  autoreconf || return 1
  automake || return 1
  ./configure --enable-arch --enable-write --enable-raw --disable-wall --enable-rdev --enable-partx || return 1
  make HAVE_SLN=yes ADD_RAW=yes || return 1
  make HAVE_SLN=yes ADD_RAW=yes DESTDIR="${pkgdir}" install || return 1
  # remove files
  rm -f "${pkgdir}/bin/kill"
  rm -f "${pkgdir}/usr/share/man/man1/kill.1"
  rm -f "${pkgdir}/usr/share/man/man5/nfs.5"
  rm -f "${pkgdir}/usr/share/info/dir"
}