vsftpd: Allow for setting FTP_HOME through USE flag
[oe-lite:esbens-base.git] / recipes / vsftpd / vsftpd.inc
1 # -*- mode:python; -*-
2 DESCRIPTION = "Secure ftp daemon"
3
4 inherit c make sysvinit passwd
5
6 SRC_URI = "https://security.appspot.com/downloads/vsftpd-${PV}.tar.gz"
7 SRC_URI += "file://init file://vsftpd.conf file://passwd file://group"
8
9 DEPENDS_LIBC = "libcrypt libnsl libresolv"
10 DEPENDS_LIBC:HOST_LIBC_mingw = ""
11 DEPENDS = "${DEPENDS_LIBC}"
12
13 do_configure() {
14     # Fix hardcoded /usr, /etc, /var mess.
15     cat tunables.c \
16         | sed s:\"/usr:\"${prefix}:g \
17         | sed s:\"/var:\"${localstatedir}:g \
18         | sed s:\"${prefix}/share/empty:\"${localstatedir}/share/empty:g \
19         | sed s:\"/etc:\"${sysconfdir}:g \
20         > tunables.c.new
21     mv tunables.c.new tunables.c
22     cat Makefile \
23         | sed 's: /usr/local/sbin: \$\(DESTDIR\)${sbindir}:g' \
24         | sed 's: /usr/sbin: \$\(DESTDIR\)${sbindir}:g' \
25         | sed 's: /usr/local/man: \$\(DESTDIR\)${mandir}:g' \
26         | sed 's: /usr/share/man: \$\(DESTDIR\)${mandir}:g' \
27         | sed 's: /usr/man: \$\(DESTDIR\)${mandir}:g' \
28         | sed 's: /etc: \$\(DESTDIR\)${sysconfdir}:g' \
29         | sed 's: /etc: \$\(DESTDIR\)${sysconfdir}:g' \
30         > Makefile.new
31
32     # Configure CFLAGS and hardcode LIBS
33     mv Makefile.new Makefile
34     cat Makefile \
35         | sed -e 's:^\(CC\s*=\).*:\1 ${CC}:g' \
36         | sed -e 's:^\(CFLAGS\s*=\)\(.*\):\1 ${CFLAGS} \2:g' \
37         | sed -e 's:^\(LIBS\s*=\).*:\1 -lnsl -lresolv -lcrypt:g' \
38         > Makefile.new
39     mv Makefile.new Makefile
40 }
41
42 do_compile() {
43     oe_runmake
44 }
45
46 do_install() {
47     install -d ${D}${sbindir}
48     install -d ${D}${mandir}/man8
49     install -d ${D}${mandir}/man5
50     oe_runmake 'DESTDIR=${D}' install
51     install -d ${D}/var/share/empty
52     install -d ${D}${sysconfdir}
53     install -m 0755 ${SRCDIR}/vsftpd.conf ${D}${sysconfdir}/vsftpd.conf
54     install -d ${D}${sysconfdir}/init.d/
55     install -m 755 ${SRCDIR}/init ${D}${sysconfdir}/init.d/vsftpd
56 }
57
58 RECIPE_FLAGS += "ftp_home"
59 DEFAULT_USE_ftp_home = "/home/ftp"
60 do_install[postfuncs] += "do_install_set_ftp_home"
61 do_install_set_ftp_home() {
62         sed -i -e "s|PLACEHOLDER_FTP_HOME|${USE_ftp_home}|" \
63                 ${D}${sysconfdir}/passwd.d/${PN}.1
64 }
65
66 RECIPE_FLAGS += "vsftpd_sysvinit_start vsftpd_sysvinit_stop"
67 DEFAULT_USE_vsftpd_sysvinit_start       = "20"
68 DEFAULT_USE_vsftpd_sysvinit_stop        = "20"
69
70 RDEPENDS_${PN} = "libcrypt libnsl libresolv libc"
71 FILES_${PN} += "/var/share/empty"
72
73 RECIPE_FLAGS += "vsftpd_config"
74 DEFAULT_USE_vsftpd_config = "${PN}-config"
75
76 PACKAGES =+ "${PN}-config"
77 RDEPENDS_${PN} += "${USE_vsftpd_config}"
78 FILES_${PN}-config = "${sysconfdir}/vsftpd.conf"
79
80 PACKAGES =+ "${PN}-init"
81 RDEPENDS_${PN}:>USE_sysvinit += "${PN}-init"
82 FILES_${PN}-init = "${sysconfdir}/init.d ${sysconfdir}/rc?.d"
83
84 # FIXME: do something else!
85 #pkg_postinst() {
86 #    if [ "x$D" != "x" ]; then
87 #        exit 1
88 #    fi
89 #    addgroup ftp
90 #    adduser --system --home /var/lib/ftp --no-create-home --ingroup ftp --disabled-password -s /bin/false ftp
91 #    mkdir -p ${localstatedir}/share/empty
92 #}