# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=unzip
pkgver=6.0
_pkgver=${pkgver//./}
pkgrel=2
pkgdesc="Extract PKZIP-compatible .zip files"
url="http://www.info-zip.org/UnZip.html"
arch="all"
license="custom"
subpackages="$pkgname-doc"
options="!check"
# normally 	ftp://ftp.info-zip.org/pub/infozip/src/$pkgname$_pkgver.zip
source="https://dev.alpinelinux.org/archive/unzip/$pkgname$_pkgver.tgz
	10-unzip-handle-pkware-verify.patch
	20-unzip-uidgid-fix.patch
	unzip-6.0-heap-overflow-infloop.patch
	"
builddir="$srcdir/$pkgname$_pkgver"

build() {
	cd "$builddir"

	make -f unix/Makefile \
		CC="${CHOST}-gcc" \
		LOCAL_ZIP="${CFLAGS} ${CPPFLAGS}" \
		prefix=/usr generic
}

package() {
	cd "$builddir"

	make -f unix/Makefile \
		MANDIR=${pkgdir}/usr/share/man/man1/ \
		prefix=${pkgdir}/usr install
	install -Dm644 LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="0694e403ebc57b37218e00ec1a406cae5cc9c5b52b6798e0d4590840b6cdbf9ddc0d9471f67af783e960f8fa2e620394d51384257dca23d06bcd90224a80ce5d  unzip60.tgz
9d2914f22fb0075a2b6f72825c235f46eafd8d47b6fb6fcc8303fc69336e256b15923c002d2615bb6af733344c2315e4a8504d77bae301e10c11d4736faa2c81  10-unzip-handle-pkware-verify.patch
57699582e9056af0817dcb67f8db67e6a1ff8208c137fbebcf559429e5f12b471b75d7e1ef938e5bbb5416074a51ac7342e4ce8057f4bbdcb0bf079b8d7832af  20-unzip-uidgid-fix.patch
b1e3fac6a787828efaaef8ec7cc52e1573aea27a6f29830af37ec4ba8bcd2a6488c953ab10eee0561c78e82c7401833ef172bebee793405d93632ce788756301  unzip-6.0-heap-overflow-infloop.patch"
