# Maintainer: Andy Weidenbaum <archbaum@gmail.com>

pkgname=with-includes
pkgver=0.0.1
pkgrel=1
pkgdesc="Sample transactions with include directives"
arch=('any')
makedepends=('mktxn')
optdepends=('nightscape: double-entry bookkeeping TXN reporting and analysis')
groups=('nightscape' 'txn')
source=("jrnl.tar.gz"{,.asc})
sha256sums=('8070ef2fd6b2f47bd42b7fdf403d0b778518eea13862f9e1e853fdaac194eaee'
            'SKIP')
validpgpkeys=('DA996E276B1F51FBC492E9873DBB92CDB1B08DAB')

prepare() {
  cd "$srcdir/jrnl"

  msg2 'Fixing include paths...'
  sed -i 's@t/data/with-includes/jrnl/@@g' with-includes.txn
}

build() {
  cd "$srcdir/jrnl"

  msg2 'Building...'
  mktxn \
    --name="$pkgname" \
    --version="$pkgver" \
    --release=$pkgrel \
    --description="$pkgdesc" \
    with-includes.txn
}

package() {
  cd "$srcdir/jrnl"

  msg2 'Installing...'
  install -Dm 644 $pkgname-$pkgver-$pkgrel.txn.tar.xz \
          -t "$pkgdir/$HOME/.nightscape/db/"

  find "$pkgdir" -mindepth 1 -maxdepth 1 -exec chown -R $USER:users '{}' \;
}
