### this file is sourced not run
PKGVER=3.0.3
PKGBUILD=1
PKGARCH=x86_64

# source: james - synced with post BLFS 8.3 2018-10-14
TARBALL=vsftpd-$PKGVER.tar.gz
MD5SUM=da119d084bd3f98664636ea05b5bb398
SRC_URL=https://security.appspot.com/downloads/$TARBALL
BUNDLE=

SLACKREQ='' # 
SLACKDESC="vsftpd: vsftpd $PKGVER (FTP server)  
vsftpd:  
vsftpd: vsftpd (very secure ftp daemon) is a small, fast, secure, yet 
vsftpd: versatible FTP server.  
vsftpd: 
vsftpd: https://security.appspot.com/vsftpd.html 
vsftpd: 
vsftpd: 
vsftpd: 
vsftpd: 
vsftpd: 
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/vsftpd*
	
	> builddefs.h cat << "EOF"
#ifndef VSF_BUILDDEFS_H
#define VSF_BUILDDEFS_H

#undef VSF_BUILD_TCPWRAPPERS
#undef VSF_BUILD_PAM
#define VSF_BUILD_SSL

#endif /* VSF_BUILDDEFS_H */
EOF

	# fix linking to openssl 1.1
	sed -e 's|SSL_library_init|SSL_CTX_new|' -i vsf_findlibs.sh &&

	# change default empty dir
	sed -e 's|/usr/share/empty|/usr/share/vsftpd/empty|g' -i tunables.c vsftpd.conf.5 INSTALL

	make $MAKEFLAGS LIBS="-lcap -lssl -lcrypto -lcrypt -ldl" &&
	install -m755 vsftpd /usr/sbin &&
	install -m644 vsftpd.conf.5 /usr/share/man/man5 &&
	install -m644 vsftpd.8 /usr/share/man/man8 &&
	install -m644 vsftpd.conf /etc/vsftpd.conf.sample &&

	# make the empty dir
	install -dm755 /usr/share/vsftpd/empty &&
	install -dm755 /home/ftp &&

	# install our startup script
	install -m644 /tmp/pkg/99-vsftpd /etc/init.d &&

	# BLFS conf file with both logins and anonymous
	cat >> /etc/vsftpd.conf << "EOF" &&
background=YES
listen=YES
nopriv_user=ftp
secure_chroot_dir=/usr/share/vsftpd/empty
local_enable=YES
anonymous_enable=YES
EOF

	pkg_build_slackdesc
}
