# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=f2fs-tools
pkgver=1.16.0
pkgrel=3
pkgdesc='Tools for Flash-Friendly File System (F2FS)'
arch=('x86_64')
url='https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/about/'
provides=('libf2fs.so' 'libf2fs_format.so')
depends=('util-linux')
makedepends=('git')
license=('GPL')
validpgpkeys=('D3452A79D8C2B4EAC656F4224014A87E824850D2') # Jaegeuk Kim <jaegeuk@kernel.org>
source=("git+https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git#tag=v${pkgver}")
sha256sums=('87d0ecee953f1c800c8c1869b5cdca8e37d5df1fe7e40a80e21b187425205c48')

_backports=(
  # f2fs-tools: fix build error on lz4-1.9.4
  '19f77c6f6277a274434d6d8883f50e7955c6a8db'
)

_reverts=(
)

prepare() {
  cd "${pkgname}"

  local _c
  for _c in "${_backports[@]}"; do
    if [[ $_c == *..* ]]; then
      git log --oneline --reverse "${_c}"
    else
      git log --oneline -1 "${_c}"
    fi
    git cherry-pick -n -m1 "${_c}"
  done
  for _c in "${_reverts[@]}"; do
    git log --oneline -1 "${_c}"
    git revert -n "${_c}"
  done

  autoreconf -fi
}

build() {
  cd "${pkgname}"

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin
  make
}

package() {
  cd "${pkgname}"

  make DESTDIR="${pkgdir}/" sbindir=/usr/bin install
}
