blob: 3d4f1df439cc10e8c56235a5da8aa20e4ad8acfb [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001SUMMARY = "Postfix Mail Transport Agent"
2DESCRIPTION = "Postfix is Wietse Venema's mail server that started life at \
3IBM research as an alternative to the widely-used Sendmail program. \
4Postfix attempts to be fast, easy to administer, and secure. The outsidei \
5has a definite Sendmail-ish flavor, but the inside is completely different."
6
7HOMEPAGE= "http://www.postfix.org"
8SECTION = "mail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08009DEPENDS = "db icu libpcre libnsl2 openssl postfix-native \
Patrick Williamsddad1a12017-02-23 20:36:32 -060010 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', 'openldap', '', d)} \
11 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', 'cyrus-sasl', '', d)} \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050012"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050013
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014LICENSE = "IPL-1.0 | EPL-2.0"
15LIC_FILES_CHKSUM = "file://LICENSE;md5=b181651ad99a7dc4cc8c4ce2f491ed1a"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050016
17SRC_URI = "ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${PV}.tar.gz \
18 file://makedefs.patch \
19 file://install.patch \
Brad Bishop316dfdd2018-06-25 12:45:53 -040020 file://main.cf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050021 file://postfix \
22 file://internal_recipient \
23 file://postfix.service \
24 file://aliasesdb \
25 file://check_hostname.sh \
26"
27
28S = "${WORKDIR}/postfix-${PV}"
29
30CLEANBROKEN = "1"
31
32BBCLASSEXTEND = "native"
33
34inherit update-rc.d useradd update-alternatives systemd
35
36INITSCRIPT_NAME = "postfix"
37INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ."
38USERADD_PACKAGES = "${PN}"
39USERADD_PARAM_${PN} = \
40"-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \
41 -d /var/spool/vmail -r -g vmail --shell /bin/false vmail \
42"
43GROUPADD_PARAM_${PN} = "--system postfix;--system postdrop;--system vmail"
44
45export SYSLIBS = "${LDFLAGS}"
46
47# CCARGS specifies includes, defines
48# AUXLIBS specifies libraries
49# Linux2/Linux3 has HAS_DB defined
50# makedefs will make CC to be CC+CCARGS
51
52# ldap support
53export CCARGS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060054 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050055export AUXLIBS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060056 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050057
58# no native openldap
59export CCARGS-ldap_class-native = ""
60export AUXLIBS-ldap_class-native = ""
61
Brad Bishopd7bf8c12018-02-25 22:55:05 -050062export CCARGS-nonis_libc-musl = "-DNO_NIS"
63export CCARGS-nonis = ""
64
Patrick Williamsb48b7b42016-08-17 15:04:38 -050065# SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH
66# current openldap didn't enable SASL
67export CCARGS-sasl = "\
Brad Bishopd7bf8c12018-02-25 22:55:05 -050068 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${STAGING_INCDIR}/sasl', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050069export AUXLIBS-sasl = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060070 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050071export CCARGS-sasl_class-native = ""
72export AUXLIBS-sasl_class-native = ""
73
74# PCRE, TLS support default
Brad Bishopd7bf8c12018-02-25 22:55:05 -050075export CCARGS = "${CFLAGS} -DHAS_PCRE -DUSE_TLS -I${STAGING_INCDIR}/openssl ${CCARGS-ldap} ${CCARGS-sasl} ${CCARGS-nonis}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}"
77export POSTCONF = "${STAGING_DIR_NATIVE}${sbindir_native}/postconf"
78
79# OPT,DEBUG is aready in CFLAGS
80# ignore the OPTS="CC=$CC" in Makefile it will not use the CC=$CC $CCARGS
81EXTRA_OEMAKE += "OPT= DEBUG= OPTS= "
82
83do_compile () {
84 unset CFLAGS CPPFLAGS CXXFLAGS
85 local native_build
86
87 native_build="${@['0', '1'][bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d)]}"
88
89 # if not native build, then pass SYSTEM and RELEASE to makedefs
90 if [ "${native_build}" != "1" ]; then
91 # uname -s for target
92 SYSTEM="Linux"
93
94 # uname -r, use 2.6 as bottomline, even target kernel ver > 2.6
95 RELEASE="2.6.34"
96 sed -i -e \
97 "s:\$(SHELL) makedefs):\$(SHELL) makedefs $SYSTEM $RELEASE):" \
98 ${S}/Makefile.in
99 export BUILD_SYSROOT="${STAGING_DIR_HOST}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500100 else
101 # native build
102 export BUILD_SYSROOT="${STAGING_DIR_NATIVE}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500103 fi
104
105 oe_runmake makefiles
106 oe_runmake
107}
108
109do_install_prepend_class-native() {
110 export POSTCONF="bin/postconf"
111}
112
113SYSTEMD_SERVICE_${PN} = "postfix.service"
114
115do_install () {
116 sh ./postfix-install 'install_root=${D}' \
117 'config_directory=${sysconfdir}/postfix' \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400118 'daemon_directory=${libexecdir}/postfix' \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500119 'command_directory=${sbindir}' \
120 'queue_directory=${localstatedir}/spool/postfix' \
121 'sendmail_path=${sbindir}/sendmail.postfix' \
122 'newaliases_path=${bindir}/newaliases' \
123 'mailq_path=${bindir}/mailq' \
124 'manpage_directory=${mandir}' \
125 'readme_directory=${datadir}/doc/postfix' \
126 'data_directory=${localstatedir}/lib/postfix' \
127 -non-interactive
128 rm -rf ${D}${localstatedir}/spool/postfix
129 mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/sample-main.cf
130 install -m 755 ${S}/bin/smtp-sink ${D}/${sbindir}/
131 install -d ${D}${sysconfdir}/init.d
Brad Bishop316dfdd2018-06-25 12:45:53 -0400132 install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500133 sed -i 's#@LIBEXECDIR@#${libexecdir}#' ${D}${sysconfdir}/postfix/main.cf
134
135 install -m 755 ${WORKDIR}/check_hostname.sh ${D}${sbindir}/
136
137 install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix
138 install -m 644 ${WORKDIR}/internal_recipient ${D}${sysconfdir}/postfix/internal_recipient
139
140 install -d ${D}${systemd_unitdir}/system
141 install -m 0644 ${WORKDIR}/postfix.service ${D}${systemd_unitdir}/system
142 sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}${systemd_unitdir}/system/postfix.service
143 sed -i -e 's#@LOCALSTATEDIR@#${localstatedir}#g' ${D}${systemd_unitdir}/system/postfix.service
144 sed -i -e 's#@SBINDIR@#${sbindir}#g' ${D}${systemd_unitdir}/system/postfix.service
145
Brad Bishop316dfdd2018-06-25 12:45:53 -0400146 install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500147
148 install -m 770 -d ${D}${localstatedir}/spool/postfix
149 chown postfix:postfix ${D}${localstatedir}/spool/postfix
150
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500151 install -m 0755 -d ${D}${localstatedir}/lib/postfix
152 chown postfix:nogroup ${D}${localstatedir}/lib/postfix
153 install -m 0755 -d ${D}${localstatedir}/spool/postfix
154 chown root:postfix ${D}${localstatedir}/spool/postfix
155 install -m 0700 -d ${D}${localstatedir}/spool/postfix/active
156 chown postfix:root ${D}${localstatedir}/spool/postfix/active
157 install -m 0700 -d ${D}${localstatedir}/spool/postfix/bounce
158 chown postfix:root ${D}${localstatedir}/spool/postfix/bounce
159 install -m 0700 -d ${D}${localstatedir}/spool/postfix/corrupt
160 chown postfix:root ${D}${localstatedir}/spool/postfix/corrupt
161 install -m 0700 -d ${D}${localstatedir}/spool/postfix/defer
162 chown postfix:root ${D}${localstatedir}/spool/postfix/defer
163 install -m 0700 -d ${D}${localstatedir}/spool/postfix/deferred
164 chown postfix:root ${D}${localstatedir}/spool/postfix/deferred
165 install -m 0700 -d ${D}${localstatedir}/spool/postfix/flush
166 chown postfix:root ${D}${localstatedir}/spool/postfix/flush
167 install -m 0700 -d ${D}${localstatedir}/spool/postfix/hold
168 chown postfix:root ${D}${localstatedir}/spool/postfix/hold
169 install -m 0700 -d ${D}${localstatedir}/spool/postfix/incoming
170 chown postfix:root ${D}${localstatedir}/spool/postfix/incoming
171 install -m 0700 -d ${D}${localstatedir}/spool/postfix/saved
172 chown postfix:root ${D}${localstatedir}/spool/postfix/saved
173 install -m 0700 -d ${D}${localstatedir}/spool/postfix/trace
174 chown postfix:root ${D}${localstatedir}/spool/postfix/trace
175 install -m 0730 -d ${D}${localstatedir}/spool/postfix/maildrop
176 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/maildrop
177 install -m 0755 -d ${D}${localstatedir}/spool/postfix/pid
178 chown root:root ${D}${localstatedir}/spool/postfix/pid
179 install -m 0700 -d ${D}${localstatedir}/spool/postfix/private
180 chown postfix:root ${D}${localstatedir}/spool/postfix/private
181 install -m 0710 -d ${D}${localstatedir}/spool/postfix/public
182 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/public
183 install -m 0755 -d ${D}${localstatedir}/spool/vmail
184 chown vmail:vmail ${D}${localstatedir}/spool/vmail
185
186 chown :postdrop ${D}${sbindir}/postqueue
187 chown :postdrop ${D}${sbindir}/postdrop
188 chmod g+s ${D}${sbindir}/postqueue
189 chmod g+s ${D}${sbindir}/postdrop
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800190
191 rm -rf ${D}/etc/postfix/makedefs.out
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500192}
193
194do_install_append_class-native() {
195 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases
196 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq
197}
198
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800199ALTERNATIVE_${PN} += "sendmail mailq newaliases"
200ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq"
201ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500202ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix"
203ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800204
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500205ALTERNATIVE_PRIORITY = "120"
206
Patrick Williamsddad1a12017-02-23 20:36:32 -0600207ALTERNATIVE_${PN}-doc += "mailq.1 newaliases.1 sendmail.1"
208ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1"
209ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1"
210ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1"
211
Brad Bishop316dfdd2018-06-25 12:45:53 -0400212PACKAGE_WRITE_DEPS += "postfix-native"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500213pkg_postinst_${PN} () {
214 if [ "x$D" = "x" ]; then
215 touch /etc/aliases
216 newaliases
217
218 # generate virtual_alias, default is hash
219 touch /etc/postfix/virtual_alias
220 postmap /etc/postfix/virtual_alias
221 else
Brad Bishop316dfdd2018-06-25 12:45:53 -0400222 if ${@'true' if 'linuxstdbase' in d.getVar('DISTROOVERRIDES', False) else 'false'}; then
223 # /usr/lib/sendmail is required by LSB core test
224 [ ! -L $D/usr/lib/sendmail ] && ln -sf ${sbindir}/sendmail $D/usr/lib/
225 fi
226
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500227 touch $D/etc/aliases
Brad Bishop316dfdd2018-06-25 12:45:53 -0400228 # This can fail depending on host setup
229 if ! newaliases -C $D/etc/postfix/main.cf -oA$D/etc/aliases; then
230 $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800231 else
232 touch $D/etc/postfix/virtual_alias
233 postmap -c $D/etc/postfix $D/etc/postfix/virtual_alias
Brad Bishop316dfdd2018-06-25 12:45:53 -0400234 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500235
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500236 fi
237}
238
239# Exclude .debug directories from the main package
240FILES_${PN} = "${sysconfdir} ${localstatedir} ${bindir}/* ${sbindir}/* \
241 ${libexecdir}/* ${systemd_unitdir}/*"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400242FILES_${PN}-dbg += "${libexecdir}/postfix/.debug"