# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libmspack
pkgver=0.5_alpha
_ver=${pkgver/_/}
pkgrel=1
pkgdesc="Library for CAB and related files compression and decompression"
url="http://www.cabextract.org.uk/libmspack/"
arch="all"
license="LGPLv2"
depends=""
depends_dev=""
makedepends="$depends_dev"
install=""
subpackages="$pkgname-dev"
source="http://www.cabextract.org.uk/libmspack/libmspack-$_ver.tar.gz
	CVE-2017-6419.patch
	CVE-2017-11423.patch"

_builddir="$srcdir"/libmspack-$_ver

# secfixes:
#   0.5_alpha-r1:
#     - CVE-2017-6419
#     - CVE-2017-11423

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"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-static \
		|| return 1
	make || return 1
}

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

md5sums="3aa3f6b9ef101463270c085478fda1da  libmspack-0.5alpha.tar.gz
a88236b4e1b9bb265945a455123648ed  CVE-2017-6419.patch
e29cb11b947c191dbec80932f16b5d70  CVE-2017-11423.patch"
sha256sums="8967f275525f5067b364cee43b73e44d0433668c39f9376dfff19f653d1c8110  libmspack-0.5alpha.tar.gz
fed2f79b41b326ca0b5f1f968027ee320e9f3d14f14fc67a7b1bcf5650884dd8  CVE-2017-6419.patch
164b7bbbc08abce0e7f995938b3b74084dcc71cc8871c9ab1e14dcadc8df6a58  CVE-2017-11423.patch"
sha512sums="6d4efa0f43c43185ef91c97c1518aa70f09109d7332cda7e12019e146ec9cb0f2065fb1b57683b48bae9a7eaf8e82eb94096644c6d25c56d45878f630b719231  libmspack-0.5alpha.tar.gz
5b40a114c8449f0c9f38536cb148c684a94e51607ec806da1a4a4466550202d63edbcd26e4a6cdec7b20483f3384f732ba952945e752a975be2e9a6653e036e0  CVE-2017-6419.patch
b426584d967c53f61491f1d47205a8db0bab5ca0a9ba75868f0437d697f5c81df20652c6eedf7825d00851555ff10f4a388275024fdc41d638d1d6ee9387dad2  CVE-2017-11423.patch"