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

# source: BLFS 11.3
TARBALL=vsftpd-$PKGVER.tar.gz
MD5SUM=efbf362a65bec771bc15ad311f5a982e
SRC_URL=https://security.appspot.com/downloads/$TARBALL
BUNDLE=

SLACKREQ='libnsl libcap2' # 
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*

<< "NOT_USED"
	> 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
NOT_USED

	# BLFS: gcc-10 fix
	sed -e "s/kVSFSysStrOpenUnknown;/(enum EVSFSysUtilOpenMode)&/" -i sysstr.c	&&

	# 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" &&
	make $MAKEFLAGS
	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
seccomp_sandbox=NO
EOF

	pkg_build_slackdesc
}
