# Maintainer: Lex Black <autumn-wind at web dot de>
# Contributor: Rich Li <rich at dranek com>
# Contributor: Sam Stuewe <halosghost at archlinux dot org>
# Contributor: David Lo Re <boyska@gmail.com>
# Contributor: nignux <nignux@freaknet.org>

_name=tomb
pkgbase="${_name}-git"
pkgname=("${_name}-git" "${_name}-kdf-git" "${_name}-cloak-git")
pkgver=2.13.r17.g648b008
pkgrel=1
pkgdesc="simple tool to manage encrypted storage"
arch=('i686' 'x86_64')
url="https://www.dyne.org/software/tomb/"
license=('GPL-3.0-only')
makedepends=('git' 'libgcrypt')
conflicts=("${_name}")
provides=("${_name}")
source=("${_name}::git+https://github.com/dyne/${_name//t/T}.git"
  "_${_name}")
sha256sums=('SKIP'
  '69cf2daa7971f1cac76574e3988ebf285f8a900c46b0f1493066f037917a4d38')

pkgver() {
  cd "${_name}"
  git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/-/./g;s/v//'
}

build() {
  cd "${_name}/extras/kdf-keys"
  make
}

package_tomb-git() {
  arch=('any')
  depends=('cryptsetup' 'gnupg' 'inetutils' 'sudo' 'zsh' 'e2fsprogs')
  optdepends=('lsof: allows the operation slam'
    'steghide: steganography'
    'dcfldd: show nice progress during massive I/O'
    'qrencode: for paper backups of keys'
    'plocate: fast search file names'
    'recoll: fast search file contents'
    'argon2: support for argon2 KDF'
    'acl: own mountpoint in /run/media/$USER')

  cd "${_name}"
  make DESTDIR="${pkgdir}" PREFIX=/usr install

  cd "extras/translations"
  make DESTDIR="${pkgdir}" PREFIX=/usr install

  install -Dm644 "${srcdir}/_${_name}" "${pkgdir}/usr/share/zsh/site-functions/_${_name}"
}

package_tomb-kdf-git() {
  pkgdesc="Crypto Undertaker extensions to improve password security"
  depends=('libgcrypt')
  conflicts=("${_name}-kdf")
  provides=("${_name}-kdf")

  cd "${_name}/extras/kdf-keys"
  make DESTDIR="${pkgdir}" PREFIX=/usr install
}

package_tomb-cloak-git() {
  pkgdesc="Crypto Undertaker extension for steganography"
  arch=('any')
  depends=('python')
  conflicts=("${_name}-cloak")
  provides=("${_name}-cloak")

  cd "${_name}/extras/cloak"
  make DESTDIR="${pkgdir}" PREFIX=/usr install

  # Install cipher files
  install -dm644 "${pkgdir}/usr/share/${_name}/ciphers"
  for cipher in ciphers/*; do
    install -m644 ${cipher} "${pkgdir}/usr/share/${_name}/ciphers"
  done
}
