# Maintainer: Jonathan Steel <jsteel at archlinux.org>
# Contrinutor: Dan Serban
# Contributor: Franz Burgmann
# Contributor: Todd Partridge (Gen2ly)
# Contributor: Ivan Sichmann Freitas

pkgname=partclone
pkgver=0.3.38
pkgrel=2
pkgdesc="Utilities to save and restore used blocks on a partition"
arch=('x86_64')
url="https://partclone.org"
license=('GPL')
depends=('ntfs-3g' 'nilfs-utils')
source=($pkgname-$pkgver.tar.gz::https://github.com/Thomas-Tsai/partclone/archive/$pkgver.tar.gz)
sha256sums=('5afd6f558e83026e9270396394bc95308fbe1543f8b963a4fb5331bc7b0ed9d9')

build() {
  cd $pkgname-$pkgver
  ./autogen
  ./configure \
    bashcompletiondir='/usr/share/bash-completion/completions' \
    --prefix=/usr \
    --enable-extfs \
    --enable-fat \
    --enable-hfsp \
    --enable-btrfs \
    --enable-ncursesw \
    --enable-ntfs \
    --enable-exfat \
    --enable-f2fs \
    --enable-minix \
    --enable-nilfs2 \
    --enable-xfs \
    --sbindir=/usr/bin
  make
}

package() {
  cd $pkgname-$pkgver
  make PREFIX=/usr DESTDIR="$pkgdir" install

  # Allow bash completions to dynamically load completions for each commands.
  for binfile in "$pkgdir/usr/bin/"*; do
    ln -s 'partclone-prompt' "$pkgdir/usr/share/bash-completion/completions/$(basename "$binfile")"
  done
}
