blob: 64c20d0f5e95bf9742c002ad032e6bd74d42d1d1 [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
Patrick Williamsb48b7b42016-08-17 15:04:38 -050017S = "${WORKDIR}/postfix-${PV}"
18
19CLEANBROKEN = "1"
20
21BBCLASSEXTEND = "native"
22
23inherit update-rc.d useradd update-alternatives systemd
24
25INITSCRIPT_NAME = "postfix"
26INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ."
27USERADD_PACKAGES = "${PN}"
28USERADD_PARAM_${PN} = \
29"-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \
30 -d /var/spool/vmail -r -g vmail --shell /bin/false vmail \
31"
32GROUPADD_PARAM_${PN} = "--system postfix;--system postdrop;--system vmail"
33
34export SYSLIBS = "${LDFLAGS}"
35
36# CCARGS specifies includes, defines
37# AUXLIBS specifies libraries
38# Linux2/Linux3 has HAS_DB defined
39# makedefs will make CC to be CC+CCARGS
40
41# ldap support
42export CCARGS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060043 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050044export AUXLIBS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060045 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050046
47# no native openldap
48export CCARGS-ldap_class-native = ""
49export AUXLIBS-ldap_class-native = ""
50
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051export CCARGS-nonis_libc-musl = "-DNO_NIS"
52export CCARGS-nonis = ""
53
Patrick Williamsb48b7b42016-08-17 15:04:38 -050054# SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH
55# current openldap didn't enable SASL
56export CCARGS-sasl = "\
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${STAGING_INCDIR}/sasl', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050058export AUXLIBS-sasl = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060059 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050060export CCARGS-sasl_class-native = ""
61export AUXLIBS-sasl_class-native = ""
62
63# PCRE, TLS support default
Brad Bishopd7bf8c12018-02-25 22:55:05 -050064export CCARGS = "${CFLAGS} -DHAS_PCRE -DUSE_TLS -I${STAGING_INCDIR}/openssl ${CCARGS-ldap} ${CCARGS-sasl} ${CCARGS-nonis}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050065export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}"
66export POSTCONF = "${STAGING_DIR_NATIVE}${sbindir_native}/postconf"
67
68# OPT,DEBUG is aready in CFLAGS
69# ignore the OPTS="CC=$CC" in Makefile it will not use the CC=$CC $CCARGS
70EXTRA_OEMAKE += "OPT= DEBUG= OPTS= "
71
72do_compile () {
73 unset CFLAGS CPPFLAGS CXXFLAGS
74 local native_build
75
76 native_build="${@['0', '1'][bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d)]}"
77
78 # if not native build, then pass SYSTEM and RELEASE to makedefs
79 if [ "${native_build}" != "1" ]; then
80 # uname -s for target
81 SYSTEM="Linux"
82
83 # uname -r, use 2.6 as bottomline, even target kernel ver > 2.6
84 RELEASE="2.6.34"
85 sed -i -e \
86 "s:\$(SHELL) makedefs):\$(SHELL) makedefs $SYSTEM $RELEASE):" \
87 ${S}/Makefile.in
88 export BUILD_SYSROOT="${STAGING_DIR_HOST}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050089 else
90 # native build
91 export BUILD_SYSROOT="${STAGING_DIR_NATIVE}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050092 fi
93
94 oe_runmake makefiles
95 oe_runmake
96}
97
98do_install_prepend_class-native() {
99 export POSTCONF="bin/postconf"
100}
101
102SYSTEMD_SERVICE_${PN} = "postfix.service"
103
104do_install () {
105 sh ./postfix-install 'install_root=${D}' \
106 'config_directory=${sysconfdir}/postfix' \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400107 'daemon_directory=${libexecdir}/postfix' \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500108 'command_directory=${sbindir}' \
109 'queue_directory=${localstatedir}/spool/postfix' \
110 'sendmail_path=${sbindir}/sendmail.postfix' \
111 'newaliases_path=${bindir}/newaliases' \
112 'mailq_path=${bindir}/mailq' \
113 'manpage_directory=${mandir}' \
114 'readme_directory=${datadir}/doc/postfix' \
115 'data_directory=${localstatedir}/lib/postfix' \
116 -non-interactive
117 rm -rf ${D}${localstatedir}/spool/postfix
118 mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/sample-main.cf
119 install -m 755 ${S}/bin/smtp-sink ${D}/${sbindir}/
120 install -d ${D}${sysconfdir}/init.d
Brad Bishop316dfdd2018-06-25 12:45:53 -0400121 install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500122 sed -i 's#@LIBEXECDIR@#${libexecdir}#' ${D}${sysconfdir}/postfix/main.cf
123
124 install -m 755 ${WORKDIR}/check_hostname.sh ${D}${sbindir}/
125
126 install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix
127 install -m 644 ${WORKDIR}/internal_recipient ${D}${sysconfdir}/postfix/internal_recipient
128
129 install -d ${D}${systemd_unitdir}/system
130 install -m 0644 ${WORKDIR}/postfix.service ${D}${systemd_unitdir}/system
131 sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}${systemd_unitdir}/system/postfix.service
132 sed -i -e 's#@LOCALSTATEDIR@#${localstatedir}#g' ${D}${systemd_unitdir}/system/postfix.service
133 sed -i -e 's#@SBINDIR@#${sbindir}#g' ${D}${systemd_unitdir}/system/postfix.service
134
Brad Bishop316dfdd2018-06-25 12:45:53 -0400135 install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500136
137 install -m 770 -d ${D}${localstatedir}/spool/postfix
138 chown postfix:postfix ${D}${localstatedir}/spool/postfix
139
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500140 install -m 0755 -d ${D}${localstatedir}/lib/postfix
141 chown postfix:nogroup ${D}${localstatedir}/lib/postfix
142 install -m 0755 -d ${D}${localstatedir}/spool/postfix
143 chown root:postfix ${D}${localstatedir}/spool/postfix
144 install -m 0700 -d ${D}${localstatedir}/spool/postfix/active
145 chown postfix:root ${D}${localstatedir}/spool/postfix/active
146 install -m 0700 -d ${D}${localstatedir}/spool/postfix/bounce
147 chown postfix:root ${D}${localstatedir}/spool/postfix/bounce
148 install -m 0700 -d ${D}${localstatedir}/spool/postfix/corrupt
149 chown postfix:root ${D}${localstatedir}/spool/postfix/corrupt
150 install -m 0700 -d ${D}${localstatedir}/spool/postfix/defer
151 chown postfix:root ${D}${localstatedir}/spool/postfix/defer
152 install -m 0700 -d ${D}${localstatedir}/spool/postfix/deferred
153 chown postfix:root ${D}${localstatedir}/spool/postfix/deferred
154 install -m 0700 -d ${D}${localstatedir}/spool/postfix/flush
155 chown postfix:root ${D}${localstatedir}/spool/postfix/flush
156 install -m 0700 -d ${D}${localstatedir}/spool/postfix/hold
157 chown postfix:root ${D}${localstatedir}/spool/postfix/hold
158 install -m 0700 -d ${D}${localstatedir}/spool/postfix/incoming
159 chown postfix:root ${D}${localstatedir}/spool/postfix/incoming
160 install -m 0700 -d ${D}${localstatedir}/spool/postfix/saved
161 chown postfix:root ${D}${localstatedir}/spool/postfix/saved
162 install -m 0700 -d ${D}${localstatedir}/spool/postfix/trace
163 chown postfix:root ${D}${localstatedir}/spool/postfix/trace
164 install -m 0730 -d ${D}${localstatedir}/spool/postfix/maildrop
165 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/maildrop
166 install -m 0755 -d ${D}${localstatedir}/spool/postfix/pid
167 chown root:root ${D}${localstatedir}/spool/postfix/pid
168 install -m 0700 -d ${D}${localstatedir}/spool/postfix/private
169 chown postfix:root ${D}${localstatedir}/spool/postfix/private
170 install -m 0710 -d ${D}${localstatedir}/spool/postfix/public
171 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/public
172 install -m 0755 -d ${D}${localstatedir}/spool/vmail
173 chown vmail:vmail ${D}${localstatedir}/spool/vmail
174
175 chown :postdrop ${D}${sbindir}/postqueue
176 chown :postdrop ${D}${sbindir}/postdrop
177 chmod g+s ${D}${sbindir}/postqueue
178 chmod g+s ${D}${sbindir}/postdrop
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800179
180 rm -rf ${D}/etc/postfix/makedefs.out
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500181}
182
183do_install_append_class-native() {
184 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases
185 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq
186}
187
Brad Bishop26bdd442019-08-16 17:08:17 -0400188ALTERNATIVE_${PN} = "sendmail mailq newaliases"
189# /usr/lib/sendmial is required by LSB core test
190ALTERNATIVE_${PN}_linuxstdbase = "sendmail mailq newaliases usr-lib-sendmail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800191ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq"
192ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500193ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix"
194ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail"
Brad Bishop26bdd442019-08-16 17:08:17 -0400195ALTERNATIVE_TARGET[usr-lib-sendmail] = "${sbindir}/sendmail.postfix"
196ALTERNATIVE_LINK_NAME[usr-lib-sendmail] = "/usr/lib/sendmail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800197
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500198ALTERNATIVE_PRIORITY = "120"
199
Patrick Williamsddad1a12017-02-23 20:36:32 -0600200ALTERNATIVE_${PN}-doc += "mailq.1 newaliases.1 sendmail.1"
201ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1"
202ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1"
203ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1"
204
Brad Bishop2d39a062019-10-28 08:33:36 -0400205pkg_postinst_ontarget_${PN}-cfg () {
206 touch /etc/aliases
207 newaliases
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500208
Brad Bishop2d39a062019-10-28 08:33:36 -0400209 # generate virtual_alias, default is hash
210 touch /etc/postfix/virtual_alias
211 postmap /etc/postfix/virtual_alias
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500212}
213
Brad Bishop2d39a062019-10-28 08:33:36 -0400214PACKAGES =+ "${PN}-cfg"
215RDEPENDS_${PN}_class-target += "${PN}-cfg"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500216# Exclude .debug directories from the main package
Brad Bishop2d39a062019-10-28 08:33:36 -0400217FILES_${PN} = "${localstatedir} ${bindir}/* ${sbindir}/* \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500218 ${libexecdir}/* ${systemd_unitdir}/*"
Brad Bishop2d39a062019-10-28 08:33:36 -0400219FILES_${PN}-cfg = "${sysconfdir}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400220FILES_${PN}-dbg += "${libexecdir}/postfix/.debug"