# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=newsbeuter
pkgver=2.9
pkgrel=4
pkgdesc="Configurable text-based feed reader"
url="http://newsbeuter.org/"
arch="all"
license="MIT"
depends=""
depends_dev=""
makedepends="$depends_dev json-c-dev curl-dev ncurses-dev sqlite-dev
	stfl-dev libxml2-dev gettext-dev perl libressl-dev"
install=""
subpackages="$pkgname-doc $pkgname-lang"
source="http://newsbeuter.org/downloads/newsbeuter-$pkgver.tar.gz
	0001-Remove-iconv-translit-references.patch
	newsbeuter-2.9-ncurses6.patch
	fix-segfault.patch
	musl_const.patch
	CVE-2017-12904.patch
	"

# secfixes:
#   2.9-r4:
#   - CVE-2017-12904

_builddir="$srcdir"/newsbeuter-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./config.sh || return 1
	echo "LDFLAGS+=-lintl" >> config.mk

	make prefix=/usr || return 1

}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" prefix=/usr install || return 1
}

sha512sums="b173008c8c8d3729f8ccef3ce62645a05c1803fb842d5c0afdf9ffd4ed3726030f9c359c20bc817402a6a0ea12af742d0ae7faf9b92d52c11f420f62b430b0aa  newsbeuter-2.9.tar.gz
1cfbe93cd8ca5785b1c26ccfdf1ed467700046c8ca564f33752b0f04f91d37765f83bf82ad593eae41532edf79a8f6992283255f9a2aa8293d14728b175c9dd7  0001-Remove-iconv-translit-references.patch
08f7125fd8f2b33fa5e36cbd947ec90bcd8b08be2df7961aced20ce031788b3970c1adeb027b1527ba06f18ddbc38518f2c22da6b5fdbc4b1cd5b0edda22ba0b  newsbeuter-2.9-ncurses6.patch
da986beb12b0ba473fea55c067abcdcdae6c073bf4d66bc8913696a4da99c4072edaf3910769d8e4bcef3a0411875eb23fbc840e0e7572aa0e16e922cc3d2947  fix-segfault.patch
f5be61b58aa1470090f0bbd519d00a8dae9ef78214787664fd05a8274877b1a20fb38e88058ab6dd8fb61f7fa433683fbecbc16d03bc625cef0cfc0cccf5e246  musl_const.patch
cef1a625781081430bcaa7fbec74a58ce656a22cd94d5ff1a6983165e053fdfbd869aebd8041fb34a7325a312f15c84b2a1093d237e2680b9244f0917baa1c4c  CVE-2017-12904.patch"