# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=tar
pkgver=1.30
pkgrel=0
pkgdesc="Utility used to store, backup, and transport files"
url="https://www.gnu.org"
arch="all"
license="GPL"
depends=""
install=""
makedepends=""
subpackages="$pkgname-doc"
source="ftp://ftp.gnu.org/gnu/tar/$pkgname-$pkgver.tar.xz
	ignore-apk-tools-checksums.patch"

# secfixes:
#   1.29-r1:
#     - CVE-2016-6321

_builddir="$srcdir/$pkgname-$pkgver"
prepare() {
	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 \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir/" install

	rm -rf "$pkgdir"/usr/lib/charset.alias
	rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true

	mkdir "$pkgdir"/bin
	mv "$pkgdir"/usr/bin/tar "$pkgdir"/bin/
	ln -s /bin/tar "$pkgdir"/usr/bin/tar
}

sha512sums="9c8b2cacf8f6ca1b19f788d4ec0410127c4d71e54b9c9cac99ee5af6c002189ccc521302955510bb22a54a069ffd00fc2de12ac776985cbbeb3f1ecf38a4f8d9  tar-1.30.tar.xz
9cde0f1509328bc5fe2cb46642b53c7681c548cf28a2fb83eda7e9374c9c0ad27a0cd55b9c0cc93951def58dafa55ee71cace5493ddcb7966ee94dc5f1099739  ignore-apk-tools-checksums.patch"
