# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=vsftpd
pkgver=3.0.5
pkgrel=2
pkgdesc="Very secure ftpd"
url="http://vsftpd.beasts.org"
arch="all"
license="GPL-2.0-only"
makedepends="openssl-dev>3 libcap-dev linux-pam-dev linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
install="$pkgname.pre-install"
source="https://security.appspot.com/downloads/vsftpd-$pkgver.tar.gz
	vsftpd.initd
	vsftpd.confd
	vsftpd-enable-ssl.patch
	vsftpd-clearenv.patch
	CVE-2015-1419.patch
	wtmpx_file.patch
	findlibs.patch
	strip.patch
	"

build() {
	# ptracesandbox.c partially uses the LFS64 interfaces.
	case "$CARCH" in
	x86) CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" ;;
	esac

	make CFLAGS="$CFLAGS -D_GNU_SOURCE"
}

package() {
	install -m755 -D vsftpd "$pkgdir"/usr/sbin/vsftpd
	install -m644 -D vsftpd.8 "$pkgdir"/usr/share/man/man8/vsftpd.8
	install -m644 -D vsftpd.conf.5 "$pkgdir"/usr/share/man/man5/vsftpd.conf.5
	install -m644 -D vsftpd.conf "$pkgdir"/etc/vsftpd/vsftpd.conf
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	mkdir -p "$pkgdir"/usr/share/empty
	mkdir -p "$pkgdir"/var/lib/ftp
	chown root:ftp "$pkgdir"/var/lib/ftp
}

sha512sums="
9e9f9bde8c460fbc6b1d29ca531327fb2e40e336358f1cc19e1da205ef81b553719a148ad4613ceead25499d1ac3f03301a0ecd3776e5c228acccb7f9461a7ee  vsftpd-3.0.5.tar.gz
99d02ed2a91ea967d6e907c07bbe89e2ced3f919e659be3e8ab90d95d87648cb9fc7224e1c8879b94b6d364810624165db1333020b602f7c42afd2bcc7a2d8e3  vsftpd.initd
7bd138cf66356db55d00796f99b327e9aedf45a48b6fc9b464801fd17a69949ca1296131513c289b0293d27b29c1add08e601068501591108ed7fb13efeeacf3  vsftpd.confd
842c1bd972f710e4ba15e1d62a4c8ebf133dc279607b844710ad6484834b6f3a43f9f3296a53e3176df2cec129b0d96b30f0610042ee66b3263d821e1efda398  vsftpd-enable-ssl.patch
13a3949695ad904c5389513206b9db71b6a4f5d35cd0c37484d9a8d8db1cd7a10c023b005661241a2e6b993fdd9c93eb7b3faaaf2542bf68a1520cf869abd710  vsftpd-clearenv.patch
73023176872a60a60ea72dc370c13617b5113ff9eb8df8f56c4efc709ca9f7752aed4c7e19530927ea6fe9ccb52dbd8ec128ec898cc8177c6d62ad41c4f281f1  CVE-2015-1419.patch
bb1bcb97df769d658e3d99a1ed1b585250a84ecfb7371adc17dff85732eee0bdc53442725c91e7563dda250d3c0b1cea1f3a5e805f3abc36aa7d27a7ba237742  wtmpx_file.patch
d3c8943a23a3c6a36642c8f9e133637bf27a3c5dd70f05d8a2d0bdf62cb0584a42fcfd67831bc2c89286b634cce529ec83ca3253d2eb4d79e15b9f6e98a46d5b  findlibs.patch
c7d1a188abd3136d973b8f6381512152ddbbfd1d86218b46b1707b7df23ce7a0ad37b6e29c8b6ec940aa0dfe959b31cecf1dbc34f55a220e85d255e0671cb291  strip.patch
"
