# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
# Contributor: Eric BĂ©langer <eric@archlinux.org>

pkgname=vi
pkgver=070224
pkgrel=3
epoch=1
pkgdesc="The original ex/vi text editor"
arch=('x86_64' 'ppc64le')
url="http://ex-vi.sourceforge.net/"
license=('custom:ex')
groups=('base')
depends=('ncurses')
optdepends=('s-nail: used by the preserve command for notification')
source=(https://sources.archlinux.org/other/$pkgname/ex-$pkgver.tar.xz{,.sig}
        fix-tubesize-short-overflow.patch
        navkeys.patch
        preserve-dir.patch)
sha256sums=('c3e52dd44edd1f6bf0b52207f717c56149dc50aac0d131fff3851d589727f52f'
            'SKIP'
            '42167fabebe30a13d594346b1d254db82090ba41742a9f35b8895d37092053f0'
            '0e9e2d381f1d8cb86daae68462b3849825b003c08007725c0db9939d3d5bf58d'
            'f0ef9ed2ccea98bf47b08dd3faa2abb911b4e6c0579f5294e9d0e8742282ff65')
validpgpkeys=('86CFFCA918CF3AF47147588051E8B148A9999C34')

prepare() {
  cd ex-$pkgver

  patch -Np1 -i ../fix-tubesize-short-overflow.patch
  patch -Np1 -i ../navkeys.patch

  # https://bugs.archlinux.org/task/20653
  patch -Np1 -i ../preserve-dir.patch
}

build() {
  cd ex-$pkgver

  make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex \
    TERMLIB=ncurses FEATURES="-DCHDIR -DFASTTAG -DUCVISUAL -DMB -DBIT8"
}

package() {
  cd ex-$pkgver

  make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex \
    INSTALL=/usr/bin/install DESTDIR="$pkgdir" install
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et: