1SUMMARY = "Secure and configurable FTP server"
2SECTION = "net"
3HOMEPAGE = "http://www.proftpd.org"
4LICENSE = "GPL-2.0-or-later"
5LIC_FILES_CHKSUM = "file://COPYING;md5=fb0d1484d11915fa88a6a7702f1dc184"
6
7SRCREV = "75aa739805a6e05eeb31189934a3d324e7862962"
8BRANCH = "1.3.7"
9
10SRC_URI = "git://github.com/proftpd/proftpd.git;branch=${BRANCH};protocol=https \
11           file://basic.conf.patch \
12           file://proftpd-basic.init \
13           file://default \
14           file://close-RequireValidShell-check.patch \
15           file://contrib.patch  \
16           file://build_fixup.patch \
17           file://proftpd.service \
18           "
19
20S = "${WORKDIR}/git"
21
22inherit autotools-brokensep useradd update-rc.d systemd multilib_script
23
24EXTRA_OECONF += "--enable-largefile"
25
26PACKAGECONFIG ??= "shadow \
27                   ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} \
28                   static \
29                  "
30
31PACKAGECONFIG[curses] = "--enable-curses --enable-ncurses, --disable-curses --disable-ncurses, ncurses"
32PACKAGECONFIG[openssl] = "--enable-openssl, --disable-openssl, openssl, openssl"
33PACKAGECONFIG[pam] = "--enable-auth-pam, --disable-auth-pam, libpam, libpam"
34PACKAGECONFIG[ipv6] = "--enable-ipv6, --disable-ipv6"
35PACKAGECONFIG[shadow] = "--enable-shadow, --disable-shadow"
36PACKAGECONFIG[pcre] = "--enable-pcre, --disable-pcre, libpcre "
37PACKAGECONFIG[static] = "--enable-static=yes, --enable-static=no"
38
39# enable POSIX.1e capabilities
40PACKAGECONFIG[cap] = "--enable-cap, --disable-cap, libcap, libcap"
41
42#enable support for POSIX ACLs
43PACKAGECONFIG[acl] = "--enable-facl, --disable-facl"
44
45#enable proftpd controls via ftpdct
46PACKAGECONFIG[ctrls] = "--enable-ctrls, --disable-crtls"
47
48#prevent proftpd from using its bundled getopt implementation.
49PACKAGECONFIG[getopt] = "--with-getopt, --without-getopt"
50
51#do not strip debugging symbols from installed code
52PACKAGECONFIG[strip] = "--enable-strip, --disable-strip"
53
54#enable SIA authentication support (Tru64)
55PACKAGECONFIG[sia] = "--enable-sia, --disable-sia"
56PACKAGECONFIG[sendfile] = "-enable-sendfile, --disable-sendfile"
57
58#enable Native Language Support (NLS)
59PACKAGECONFIG[nls] = "--enable-nls, --disable-nls"
60
61#add mod_dso to core modules
62PACKAGECONFIG[dso] = "--enable-dso, --disable-dso"
63
64#omit mod_auth_file from core modules
65PACKAGECONFIG[auth] = "--enable-auth-file, --disable-auth-file"
66
67# proftpd uses libltdl which currently makes configuring using
68# autotools.bbclass a pain...
69do_configure () {
70    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess ${S}
71    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
72    oe_runconf
73}
74
75FTPUSER = "ftp"
76FTPGROUP = "ftp"
77
78do_install () {
79    oe_runmake DESTDIR=${D} install
80    rmdir ${D}${libdir}/proftpd ${D}${datadir}/locale
81    [ -d ${D}${libexecdir} ] && rmdir ${D}${libexecdir}
82    sed -i '/ *User[ \t]*/s/ftp/${FTPUSER}/' ${D}${sysconfdir}/proftpd.conf
83    sed -i '/ *Group[ \t]*/s/ftp/${FTPGROUP}/' ${D}${sysconfdir}/proftpd.conf
84    install -d ${D}${sysconfdir}/init.d
85    install -m 0755 ${WORKDIR}/proftpd-basic.init ${D}${sysconfdir}/init.d/proftpd
86    sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/proftpd
87    sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/proftpd
88    sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/proftpd
89    sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/proftpd
90
91    install -d ${D}${sysconfdir}/default
92    install -m 0755 ${WORKDIR}/default ${D}${sysconfdir}/default/proftpd
93
94    # create the pub directory
95    mkdir -p ${D}/home/${FTPUSER}/pub/
96    chown -R ${FTPUSER}:${FTPGROUP} ${D}/home/${FTPUSER}/pub
97    if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
98        # install proftpd pam configuration
99        install -d ${D}${sysconfdir}/pam.d
100        install -m 644 ${S}/contrib/dist/rpm/ftp.pamd ${D}${sysconfdir}/pam.d/proftpd
101        sed -i '/ftpusers/d' ${D}${sysconfdir}/pam.d/proftpd
102        # specify the user Authentication config
103        sed -i '/^MaxInstances/a\AuthPAM                         on\nAuthPAMConfig                   proftpd' \
104            ${D}${sysconfdir}/proftpd.conf
105    fi
106
107    install -d ${D}/${systemd_unitdir}/system
108    install -m 644 ${WORKDIR}/proftpd.service ${D}/${systemd_unitdir}/system
109    sed -e 's,@BASE_SBINDIR@,${base_sbindir},g' \
110        -e 's,@SYSCONFDIR@,${sysconfdir},g' \
111        -e 's,@SBINDIR@,${sbindir},g' \
112        -i ${D}${systemd_unitdir}/system/*.service
113
114    sed -e 's|--sysroot=${STAGING_DIR_HOST}||g' \
115        -e 's|${STAGING_DIR_NATIVE}||g' \
116        -e 's|-ffile-prefix-map=[^ ]*||g' \
117        -e 's|-fdebug-prefix-map=[^ ]*||g' \
118        -e 's|-fmacro-prefix-map=[^ ]*||g' \
119        -i ${D}/${bindir}/prxs
120
121    # ftpmail perl script, which reads the proftpd log file and sends
122    # automatic email notifications once an upload finishs,
123    # depends on an old perl Mail::Sendmail
124    # The Mail::Sendmail has not been maintained for almost 10 years
125    # Other distribution not ship with ftpmail, so do the same to
126    # avoid confusion about having it fails to run
127    rm -rf ${D}${bindir}/ftpmail
128    rm -rf ${D}${mandir}/man1/ftpmail.1
129}
130
131INITSCRIPT_NAME = "proftpd"
132INITSCRIPT_PARAM = "defaults 85 15"
133
134SYSTEMD_PACKAGES = "${PN}"
135SYSTEMD_SERVICE:${PN} = "proftpd.service"
136
137USERADD_PACKAGES = "${PN}"
138GROUPADD_PARAM:${PN} = "--system ${FTPGROUP}"
139USERADD_PARAM:${PN} = "--system -g ${FTPGROUP} --home-dir /var/lib/${FTPUSER} --no-create-home \
140                       --shell /bin/false ${FTPUSER}"
141
142MULTILIB_SCRIPTS = "${PN}:${bindir}/prxs"
143
144FILES:${PN} += "/home/${FTPUSER}"
145
146RDEPENDS:${PN} += "perl"
147