blob: 7bf258374c8fa6681b257e6fcccecaf30ed4ee13 [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
Andrew Geissler82c905d2020-04-13 13:39:40 -050023inherit update-rc.d useradd update-alternatives systemd lib_package
Patrick Williamsb48b7b42016-08-17 15:04:38 -050024
25INITSCRIPT_NAME = "postfix"
26INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ."
Andrew Geissler82c905d2020-04-13 13:39:40 -050027USERADD_PACKAGES = "${PN}-bin"
Patrick Williams213cb262021-08-07 19:21:33 -050028USERADD_PARAM:${PN}-bin = \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050029"-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \
30 -d /var/spool/vmail -r -g vmail --shell /bin/false vmail \
31"
Patrick Williams213cb262021-08-07 19:21:33 -050032GROUPADD_PARAM:${PN}-bin = "--system postfix;--system postdrop;--system vmail"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050033
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
Patrick Williams213cb262021-08-07 19:21:33 -050048export CCARGS-ldap:class-native = ""
49export AUXLIBS-ldap:class-native = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050050
Patrick Williams213cb262021-08-07 19:21:33 -050051export CCARGS-nonis:libc-musl = "-DNO_NIS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052export 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 Williams213cb262021-08-07 19:21:33 -050060export CCARGS-sasl:class-native = ""
61export AUXLIBS-sasl:class-native = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062
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
Patrick Williams213cb262021-08-07 19:21:33 -050098do_install:prepend:class-native() {
Patrick Williamsb48b7b42016-08-17 15:04:38 -050099 export POSTCONF="bin/postconf"
100}
101
Patrick Williams213cb262021-08-07 19:21:33 -0500102SYSTEMD_SERVICE:${PN} = "postfix.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500103
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
Patrick Williams213cb262021-08-07 19:21:33 -0500183do_install:append:class-native() {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500184 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases
185 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq
186}
187
Patrick Williams213cb262021-08-07 19:21:33 -0500188ALTERNATIVE:${PN}-bin = "sendmail mailq newaliases"
Brad Bishop26bdd442019-08-16 17:08:17 -0400189# /usr/lib/sendmial is required by LSB core test
Patrick Williams213cb262021-08-07 19:21:33 -0500190ALTERNATIVE:${PN}-bin: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 Williams213cb262021-08-07 19:21:33 -0500200ALTERNATIVE:${PN}-doc += "mailq.1 newaliases.1 sendmail.1"
Patrick Williamsddad1a12017-02-23 20:36:32 -0600201ALTERNATIVE_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
Patrick Williams213cb262021-08-07 19:21:33 -0500205pkg_postinst_ontarget:${PN}-cfg () {
Brad Bishop2d39a062019-10-28 08:33:36 -0400206 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"
Patrick Williams213cb262021-08-07 19:21:33 -0500215RDEPENDS:${PN}-cfg:class-target += "${PN}-bin"
216RDEPENDS:${PN}:class-target += "${PN}-cfg"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500217# Exclude .debug directories from the main package
Patrick Williams213cb262021-08-07 19:21:33 -0500218FILES:${PN}-bin += "${localstatedir} ${bindir}/* ${sbindir}/* \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500219 ${libexecdir}/* ${systemd_unitdir}/*"
Patrick Williams213cb262021-08-07 19:21:33 -0500220FILES:${PN}-cfg = "${sysconfdir}"
221FILES:${PN}-dbg += "${libexecdir}/postfix/.debug"
222ALLOW_EMPTY:${PN} = "1"