# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=nvi
pkgver=1.81.6
pkgrel=1
pkgdesc="Re-implementation of the vi editor"
url="http://www.bostic.com/vi"
arch="all"
license="BSD"
depends=""
depends_dev=""
makedepends="db-dev ncurses-dev"
install=""
subpackages="$pkgname-doc $pkgname-catalog"
source="http://ftp.debian.org/debian/pool/main/n/$pkgname/${pkgname}_${pkgver}.orig.tar.gz
	01additional_upstream_data.patch
	03db4.patch
	04confdefs.patch
	06default_value_escapetime.patch
	07flush_cache.patch
	08lfs.patch
	08safe_printf.patch
	08tempfile_umask.patch
	09casting.patch
	10no_one_line_visual.patch
	11backward_sentence_moving.patch
	12horiz_scroll_count.patch
	13widechar_horrors.patch
	14private_regex_fixes.patch
	15search_word.patch
	16manpage_errors.patch
	17tutorial_typos.patch
	18dbpagesize_binpower.patch
	19include_term_h.patch
	21exrc_writability_check.patch
	24fallback_to_dumb_term.patch
	25manpage_note_dropped_F.patch
	26trailing_tab_segv.patch
	27support_C_locale.patch
	29file_backup.patch"

_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd "$_builddir"
	update_config_sub || return 1

	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"/dist
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--program-prefix=n \
		--enable-widechar \
		--disable-threads \
		|| return 1
	make || return 1
}

package() {
	mkdir -p "$pkgdir"/usr/bin || return 1
	make -j1 PREFIX=/usr DESTDIR="$pkgdir" \
		install -C "$_builddir"/dist || return 1

	# Remove tcl and perl scripts.
	rm -rf "$pkgdir"/usr/share/vi/tcl
	rm -rf "$pkgdir"/usr/share/vi/perl

	# Remove cat man pages.
	rm -rf "$pkgdir"/usr/share/man/cat1

	# Remove library.
	rm -f "$pkgdir"/usr/lib/libvi.a
}

catalog() {
	pkgdesc="$pkgdesc (catalog files)"
	depends=""
	arch="noarch"

	mkdir -p "$subpkgdir"/usr/share/vi/
	mv "$pkgdir"/usr/share/vi/catalog/ \
		"$subpkgdir"/usr/share/vi/ || return 1
}

md5sums="f7e65a969045dafd53aea7e3e80b8cf2  nvi_1.81.6.orig.tar.gz
7b54dcc34076857127e4a555db7987f5  01additional_upstream_data.patch
b4a2947050cf3c3bba907dce1fe92b94  03db4.patch
936f99d503b1b9ccd12bd90ab2cf9bf4  04confdefs.patch
15c8eb6006a0ae554c79a95eab68e6d3  06default_value_escapetime.patch
a26c89008d6a739e1325abf27067353b  07flush_cache.patch
90d7e4004327473cb9caec998e45b1f7  08lfs.patch
48b1c7b5c7e92389b5def6c41af9faa5  08safe_printf.patch
f69d0024e73e924184157db83cf21151  08tempfile_umask.patch
f1e3574b9249d6559b8b07014c713388  09casting.patch
2995a5dadb8dea7201bf7a732037ae81  10no_one_line_visual.patch
1adde09ecc00e5aedbe1bba9e89867c7  11backward_sentence_moving.patch
9bcaa4dcc6b6605e1b81804aa59a1714  12horiz_scroll_count.patch
d8985b75ddc1e6bbdb95b15e8af75885  13widechar_horrors.patch
de4a3d239fb0bce60c40473d342398a4  14private_regex_fixes.patch
441fbe26900747892cfd0680b0265e58  15search_word.patch
ce43f59a26fc445586b00bd53b8b81c8  16manpage_errors.patch
8ba107264cc9dbfe83d1ec72ff2c3ec0  17tutorial_typos.patch
7646959e48fdf3a91f0f06d4305de6fa  18dbpagesize_binpower.patch
b0066d3cf7f9689cecc487bfbdc976d5  19include_term_h.patch
33a5d7f1ec10a688c429b78ccd82d044  21exrc_writability_check.patch
bf9b5d890869069963e0233129debf79  24fallback_to_dumb_term.patch
25c66adcfe779a5deaa7636f9076f2e3  25manpage_note_dropped_F.patch
724d2369993aadd1388f9ede54d0e28f  26trailing_tab_segv.patch
ad5cd0869a18e8f027435b9c0643a039  27support_C_locale.patch
77d8610f0a37e5575d5ae73173e7b449  29file_backup.patch"
sha256sums="8bc348889159a34cf268f80720b26f459dbd723b5616107d36739d007e4c978d  nvi_1.81.6.orig.tar.gz
a7a3fb399359f492943d6e72e5c1233023184f0ae96ab1bebec64c0d08641f4f  01additional_upstream_data.patch
0affc8e156ab1666edec12254d87d427fd45dbebb51da184b47ab82bc9334ea1  03db4.patch
bb3e29a84602f8477e6bf6e2756057cf0164fddf7dc80863e15858dbdbe8dbf4  04confdefs.patch
3b15340e9bb51da467bcbea1ad97589fa084bed68a2ee4ce7fd9797a4279e2cf  06default_value_escapetime.patch
c26a36151ee4f839724a70e22d9b5fdac9ed3686a10842ecc807c5a9d8d63c10  07flush_cache.patch
26f39687f25de32a5c448b71c820a72cfc9310686842d291160cd830e44c673b  08lfs.patch
c5ea81a9e8da852c846d004603df49829342048e8b3959c7e1f074c9195ec866  08safe_printf.patch
56e82712e8df73b1c64dd28da6ea503555ec6b65286e42519fe023f28382064c  08tempfile_umask.patch
c06373abfd4054fb86edcb8b3844bfc773b4badd313d452d775029beb2ce25da  09casting.patch
8ed25a56255c5cf68464d8b6958be7f48aefd19a77a6eec13556505cb8f49843  10no_one_line_visual.patch
7649b5e154377a1eea7e4882eb333c51d2395b4042bc7e67c59b58d0df496995  11backward_sentence_moving.patch
c7266a713911a7b8d7d178311f089e587a8e5dfd89e3e926c68b10158bb809ea  12horiz_scroll_count.patch
ebf75d78a72bf12f812b734bcea9893c8499dfc3e7080b1552ca9f0d748ca337  13widechar_horrors.patch
b0c8209cb4f96e2843ba58a266ad6a52339b2d6cf9b9fd877692d78c5e2608cd  14private_regex_fixes.patch
05d1398e3c6611a2a62af73f55590d9a2e43ef17ac75522eff46f156a8135161  15search_word.patch
130285cfce4e4a4c726570da61ec270cba9a27eddac6efffa3fd45070b6d86d0  16manpage_errors.patch
15f2f46652e48513e272cd07cb6208cde83643db554a76eda77d84c66ea5ae35  17tutorial_typos.patch
0a9e321b571bddabd502b7f58fa365dd2095f2e344cdb3cb87888f4027b78e28  18dbpagesize_binpower.patch
31d51075014635fd3cad77f4e6bebfa192ee2c2ee0bba2b6c331a20eaca3b04c  19include_term_h.patch
ba47cf3e453d20cb584c68b5da898a79d3263efb3b95b50598f0d269ff4ecc0f  21exrc_writability_check.patch
e77f879c208d45e77c1d86558aef42bdfa4aa534f8f46c0e3dfe5de58272b003  24fallback_to_dumb_term.patch
7bcecd8a722582d2888d92a6d99849332ef27539cc09dce258ea97c1ca3867c0  25manpage_note_dropped_F.patch
8c59c97350ea8641eb86c330bf95dc2da3c6d7d61c205a8dbb3dc1f1ace63ac6  26trailing_tab_segv.patch
9bd2a5070858143dd4cde5a292890b50d209da9726883e1fb1809439c5a568fd  27support_C_locale.patch
2ef8ba25a45f264f8c63f115e7e922bc4b838f8c5d324640087be6387e4610dc  29file_backup.patch"
sha512sums="1be798daf0cd05010ddaf0aa0510dc799708fd79d4b243e2700adff18e931ddd9d11621796fa8086088c3e93ba20f15ab86783732665169c52b73eaf587ff0b3  nvi_1.81.6.orig.tar.gz
ec998baba23d15c957dbdb121a4ba7eddf0aac15503e381a1318a7e7127b0c06f3bd05ebd474175f39a6fb050ed6fd3a1f4bd348d92770355e8bc3d8d37277c9  01additional_upstream_data.patch
d635c86c52cf16ccc947ee8a4593160adf183b236ae7c2eb03ff2ea628f493e484f906b762eb1d90ec1febc48119cac955382af3ebc223e29622123500a45f97  03db4.patch
9b45e0639a30b81204e1c9b43877a6a83df2a5bba3b85a410427ead1e639cc9882f0ca162721074782870742af449c5a3f00b5051d459491bf9afb7cd718450d  04confdefs.patch
4820b584614d321b6528b9400429440b126c5c8ccc502f9e61ec7ff9cd7769e7c53e04f83ffcd4804c6baed5ac55953834644444c11e9cf42841e8fb371196ca  06default_value_escapetime.patch
df74b0977e7d864e7ea9833404f818cfb644c9fa188024b6174c7a2360350cc63f8cd8cd7fc19e54dbc5db8e2b6310be9807bb7bd108ab56dbc2d3d9cf8bff14  07flush_cache.patch
0a432a0823d0d0b2bba2dba6ee24f1b173b4552245c1bba1727804dfa8eff09dfd88129fb615eae5846aa6ef929c08a0a23a505b000dc77ecc6de578d3dc8026  08lfs.patch
2c1afb271f60031a15d4e2093b4e04c02462cc1d1815ce557049364bcdc81f83d3c6e25766a7a7efa8d04cc1c8284e9684df12ab161aba16bb479c9ee4660012  08safe_printf.patch
af723124cef36966c57785f9066cc924d155a0d495375849db36a1bf1ef1b166afd8f057d258ada9367fbf82cd30694efeeeb246d0fb14ff07fcdb807230e109  08tempfile_umask.patch
e70ee763a5c54424f75143ce892b93d8046618935bdc50bc3e646848b9b0f3d4bacf0a362b4203984527dbd98ea321a12b81b69eee7aa340e745b5d77492aca0  09casting.patch
65776b87d86cde21ef8034a1c1fe88daaac03a960223a05fdb2e1005b7e44348dc4571abe0addeef65f08fbeef72fb376486b3dccaaff4cc7d4c39bdc206026d  10no_one_line_visual.patch
f99afc8f83ea84ce059dbd5dc7b1bf726dbb2c64de8b12a7de21ca42a76e0a3b9f19d0c8c73bd046d7e0ad5ae81afed7f8e472232bcc55eb221b479ab4671f48  11backward_sentence_moving.patch
3f77c69d08d8c807eb62332eca84af898849214660e238915cadf60e46014295889bb4c66fc116846d1d9cdc2cd4d3b89b4c9c4c6a5e908ebd530f6b9fee00f0  12horiz_scroll_count.patch
97e403723934bf634120e53b7d629ca87dbae73ed0a736cf2c15d4d3f7432792535a106fbf5eb959d3b1706a868d79bf24f450e24c9b2fe295df9443ef017504  13widechar_horrors.patch
e5b1c0d7d7f96a2066f637f848564877920f163c715a1b2c4248298ed0b6a420fd3fe4e61c3925c48bd96168352cb3935b713abff8cb33d069362192f99047d7  14private_regex_fixes.patch
eadc89e64b93043dfcf8493ff8a36bc7c2f147c313a958a68edbea577cef92d10f9f2262dbb464016e4008e232a6efdb83cc0b3469cdc75b49eab7419a9ef01e  15search_word.patch
21ab846548101d58d1d9d2a93c6f309729dfdc3df33a0dd73bf55d30fc42314e4dabdeb605178a6bd256ecdab4f4331e3c156b1071c0bbf82046acb40434b7ce  16manpage_errors.patch
2dfc294f98302afad67095c8376de4de3bd582f890151ba495d1c4212964c360a9fc2afc7d988be0715b4e5d498c99f228f01d516ad57435baf07993c21c13a1  17tutorial_typos.patch
4d8999b235634fc040d45036624d880ed3c6be614cd52c7f642f8144d24726ad764a71e385445c6346f101f65febe3e609e9c9452744ee4cef5774f9048f0029  18dbpagesize_binpower.patch
27be473dc1628c407963eb4c828caa8c41ad57abb75ddf9adefe7a065ce9f8cfe16536aabeb1f078f859fa7a8817ea8d5d2ca1cb36c47be27436a9789faeb504  19include_term_h.patch
4065b814649cbbc57535941b4f20ceacc925b0ef6decfbaa5a60c6c4b943f2a5b6c68371fa87f8dce5b6c219740a10339948ffdce226c88509a807580e19864d  21exrc_writability_check.patch
b0a4c9ba713d8fb8fa8559b6038bcb70d0fb6e411a3a73cf677c38d8288f28a2febfa92f387aef899ac3959fb7bdf5220334e025b71260157f935b0f79f01e66  24fallback_to_dumb_term.patch
9a6a71574c3fb6073d3fdd0abf783f0053fbfb1ee8408e208c9368a72c3b25a5f56156da50bdd06ebf381210278c91036cca29333b48a0d5f432bbaa1d82bbd5  25manpage_note_dropped_F.patch
89ae70a8a2dd4fbb51e1f6e570f958e7dc63e4f60076446f5f0ce063f4dac19d2d1c8da241b4a709ef028459e4b43c682f1a3021ef4f04a72be98b7e2c7b9fd1  26trailing_tab_segv.patch
c091a870efc7181b3480998b8b8427cdec4b37ef66358ae8bfd2c79d6037c9b64fd6e004e39400680d1d67f608c35d56e7e36d91810ded04f984fe89a052925a  27support_C_locale.patch
4c050c5d8ee298f88bc59fd7282739dfe9202610285ca64c59b579698667ac6c8940ecf91b2b3df34d31a8ee818b9c18b1a4f9a0b47894dd4c6f8bd20c9f1c75  29file_backup.patch"
