# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=fuse2
pkgver=%version%
pkgrel=%release%
pkgdesc='Interface for userspace programs to export a filesystem to the Linux kernel'
url='https://github.com/libfuse/libfuse'
arch=('x86_64')
license=('GPL2')
depends=('glibc' 'fuse-common')
makedepends=('pkg-config')
provides=(fuse=$pkgver) # TODO: remove it once all packages start to use 'fuse2' name
replaces=('fuse')
conflicts=('fuse')
options=('!emptydirs')
source=(https://github.com/libfuse/libfuse/releases/download/fuse-$pkgver/fuse-$pkgver.tar.gz{,.asc}
	conditionally-define-closefrom.patch)
sha1sums=('943ba651b14bc4a3c6fd959ed4b8c04f4a59032d'
          'SKIP'
          '90750cd0839c1ee427314241f9ea5f054c3335d8')
sha512sums=('3d82fafd04f2924299bb09d2bb144935fa004a43fb9a6568e2e1cc5a60fded2efa1711029a0d7f12b3e6e4501f7217f2ee3545646d89da8dece083cb390f23e2'
            'SKIP'
            '0836d1693bea203b562a86c992107ee48766f41bb05a31e9af41009d2270ac84d7881aa5bc2a11ed478cd03985876aca5080341ddea701a12a630a36e1b1a80b')
validpgpkeys=(ED31791B2C5C1613AF388B8AD113FCAC3C4E599F) # Nikolaus Rath <Nikolaus@rath.org>

prepare() {
  cd fuse-$pkgver
  patch -Np1 -i ${srcdir}/conditionally-define-closefrom.patch
  autoreconf -i
}

build() {
  cd fuse-$pkgver

  UDEV_RULES_PATH=/usr/lib/udev/rules.d MOUNT_FUSE_PATH=/usr/bin ./configure --prefix=/usr --libdir=/usr/lib --enable-lib --enable-util --disable-example
  make
}

package() {
  cd fuse-$pkgver

  make DESTDIR="${pkgdir}" install

  # Remove init script in wrong path
  # Don't add our own for now, as fusectl fs oopses on 2.6.18
  rm -r "${pkgdir}"/etc/init.d

  # static device nodes are handled by udev
  rm -r "${pkgdir}"/dev
}
