blob: 0e433bb511baa62a48134f6f2699bcf9b1641b8c [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"
Andrew Geissler5199d832021-09-24 16:47:35 -05009DEPENDS = "db icu libpcre libnsl2 m4-native 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 Williamsb58112e2024-03-07 11:16:36 -060017SRC_URI = "ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${PV}.tar.gz \
18 file://main.cf \
19 file://postfix \
20 file://internal_recipient \
21 file://postfix.service \
22 file://aliasesdb \
23 file://check_hostname.sh \
24 file://0001-Fix-makedefs.patch \
25 file://0002-Change-fixed-postconf-to-a-variable-for-cross-compil.patch \
26 file://0003-makedefs-Use-native-compiler-to-build-makedefs.test.patch \
27 file://0004-Fix-icu-config.patch \
28 file://0005-makedefs-add-lnsl-and-lresolv-to-SYSLIBS-by-default.patch \
29 "
30
Patrick Williams03514f12024-04-05 07:04:11 -050031SRC_URI[sha256sum] = "4b6e17c826cc438cc3016a9c0a55ea7e77c6cbafba7dd57241d81b690b0e9774"
Patrick Williamsb58112e2024-03-07 11:16:36 -060032
33UPSTREAM_CHECK_REGEX = "postfix\-(?P<pver>3\.8(\.\d+)+).tar.gz"
34
Patrick Williamsb48b7b42016-08-17 15:04:38 -050035S = "${WORKDIR}/postfix-${PV}"
36
37CLEANBROKEN = "1"
38
39BBCLASSEXTEND = "native"
40
Andrew Geissler5199d832021-09-24 16:47:35 -050041inherit pkgconfig update-rc.d useradd update-alternatives systemd lib_package
Patrick Williamsb48b7b42016-08-17 15:04:38 -050042
43INITSCRIPT_NAME = "postfix"
44INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ."
Andrew Geissler82c905d2020-04-13 13:39:40 -050045USERADD_PACKAGES = "${PN}-bin"
Patrick Williams213cb262021-08-07 19:21:33 -050046USERADD_PARAM:${PN}-bin = \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050047"-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \
48 -d /var/spool/vmail -r -g vmail --shell /bin/false vmail \
49"
Patrick Williams213cb262021-08-07 19:21:33 -050050GROUPADD_PARAM:${PN}-bin = "--system postfix;--system postdrop;--system vmail"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050051
52export SYSLIBS = "${LDFLAGS}"
53
54# CCARGS specifies includes, defines
55# AUXLIBS specifies libraries
56# Linux2/Linux3 has HAS_DB defined
57# makedefs will make CC to be CC+CCARGS
58
59# ldap support
60export CCARGS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060061 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062export AUXLIBS-ldap = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060063 ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050064
65# no native openldap
Patrick Williams213cb262021-08-07 19:21:33 -050066export CCARGS-ldap:class-native = ""
67export AUXLIBS-ldap:class-native = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050068
Patrick Williams213cb262021-08-07 19:21:33 -050069export CCARGS-nonis:libc-musl = "-DNO_NIS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050070export CCARGS-nonis = ""
71
Patrick Williamsb48b7b42016-08-17 15:04:38 -050072# SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH
73# current openldap didn't enable SASL
74export CCARGS-sasl = "\
Brad Bishopd7bf8c12018-02-25 22:55:05 -050075 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${STAGING_INCDIR}/sasl', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076export AUXLIBS-sasl = "\
Patrick Williamsddad1a12017-02-23 20:36:32 -060077 ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}"
Patrick Williams213cb262021-08-07 19:21:33 -050078export CCARGS-sasl:class-native = ""
79export AUXLIBS-sasl:class-native = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050080
81# PCRE, TLS support default
Brad Bishopd7bf8c12018-02-25 22:55:05 -050082export CCARGS = "${CFLAGS} -DHAS_PCRE -DUSE_TLS -I${STAGING_INCDIR}/openssl ${CCARGS-ldap} ${CCARGS-sasl} ${CCARGS-nonis}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050083export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}"
84export POSTCONF = "${STAGING_DIR_NATIVE}${sbindir_native}/postconf"
85
86# OPT,DEBUG is aready in CFLAGS
87# ignore the OPTS="CC=$CC" in Makefile it will not use the CC=$CC $CCARGS
88EXTRA_OEMAKE += "OPT= DEBUG= OPTS= "
89
90do_compile () {
91 unset CFLAGS CPPFLAGS CXXFLAGS
92 local native_build
93
94 native_build="${@['0', '1'][bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d)]}"
95
96 # if not native build, then pass SYSTEM and RELEASE to makedefs
97 if [ "${native_build}" != "1" ]; then
98 # uname -s for target
99 SYSTEM="Linux"
100
101 # uname -r, use 2.6 as bottomline, even target kernel ver > 2.6
102 RELEASE="2.6.34"
103 sed -i -e \
104 "s:\$(SHELL) makedefs):\$(SHELL) makedefs $SYSTEM $RELEASE):" \
105 ${S}/Makefile.in
106 export BUILD_SYSROOT="${STAGING_DIR_HOST}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500107 else
108 # native build
109 export BUILD_SYSROOT="${STAGING_DIR_NATIVE}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500110 fi
111
112 oe_runmake makefiles
113 oe_runmake
114}
115
Patrick Williams213cb262021-08-07 19:21:33 -0500116do_install:prepend:class-native() {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500117 export POSTCONF="bin/postconf"
118}
119
Patrick Williams213cb262021-08-07 19:21:33 -0500120SYSTEMD_SERVICE:${PN} = "postfix.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500121
122do_install () {
123 sh ./postfix-install 'install_root=${D}' \
124 'config_directory=${sysconfdir}/postfix' \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400125 'daemon_directory=${libexecdir}/postfix' \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500126 'command_directory=${sbindir}' \
127 'queue_directory=${localstatedir}/spool/postfix' \
128 'sendmail_path=${sbindir}/sendmail.postfix' \
129 'newaliases_path=${bindir}/newaliases' \
130 'mailq_path=${bindir}/mailq' \
131 'manpage_directory=${mandir}' \
132 'readme_directory=${datadir}/doc/postfix' \
133 'data_directory=${localstatedir}/lib/postfix' \
134 -non-interactive
135 rm -rf ${D}${localstatedir}/spool/postfix
Andrew Geissler517393d2023-01-13 08:55:19 -0600136 mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/${MLPREFIX}sample-main.cf
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500137 install -m 755 ${S}/bin/smtp-sink ${D}/${sbindir}/
138 install -d ${D}${sysconfdir}/init.d
Brad Bishop316dfdd2018-06-25 12:45:53 -0400139 install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500140 sed -i 's#@LIBEXECDIR@#${libexecdir}#' ${D}${sysconfdir}/postfix/main.cf
141
142 install -m 755 ${WORKDIR}/check_hostname.sh ${D}${sbindir}/
143
144 install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix
145 install -m 644 ${WORKDIR}/internal_recipient ${D}${sysconfdir}/postfix/internal_recipient
146
147 install -d ${D}${systemd_unitdir}/system
148 install -m 0644 ${WORKDIR}/postfix.service ${D}${systemd_unitdir}/system
149 sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}${systemd_unitdir}/system/postfix.service
150 sed -i -e 's#@LOCALSTATEDIR@#${localstatedir}#g' ${D}${systemd_unitdir}/system/postfix.service
151 sed -i -e 's#@SBINDIR@#${sbindir}#g' ${D}${systemd_unitdir}/system/postfix.service
152
Brad Bishop316dfdd2018-06-25 12:45:53 -0400153 install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500154
155 install -m 770 -d ${D}${localstatedir}/spool/postfix
156 chown postfix:postfix ${D}${localstatedir}/spool/postfix
157
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500158 install -m 0755 -d ${D}${localstatedir}/lib/postfix
159 chown postfix:nogroup ${D}${localstatedir}/lib/postfix
160 install -m 0755 -d ${D}${localstatedir}/spool/postfix
161 chown root:postfix ${D}${localstatedir}/spool/postfix
162 install -m 0700 -d ${D}${localstatedir}/spool/postfix/active
163 chown postfix:root ${D}${localstatedir}/spool/postfix/active
164 install -m 0700 -d ${D}${localstatedir}/spool/postfix/bounce
165 chown postfix:root ${D}${localstatedir}/spool/postfix/bounce
166 install -m 0700 -d ${D}${localstatedir}/spool/postfix/corrupt
167 chown postfix:root ${D}${localstatedir}/spool/postfix/corrupt
168 install -m 0700 -d ${D}${localstatedir}/spool/postfix/defer
169 chown postfix:root ${D}${localstatedir}/spool/postfix/defer
170 install -m 0700 -d ${D}${localstatedir}/spool/postfix/deferred
171 chown postfix:root ${D}${localstatedir}/spool/postfix/deferred
172 install -m 0700 -d ${D}${localstatedir}/spool/postfix/flush
173 chown postfix:root ${D}${localstatedir}/spool/postfix/flush
174 install -m 0700 -d ${D}${localstatedir}/spool/postfix/hold
175 chown postfix:root ${D}${localstatedir}/spool/postfix/hold
176 install -m 0700 -d ${D}${localstatedir}/spool/postfix/incoming
177 chown postfix:root ${D}${localstatedir}/spool/postfix/incoming
178 install -m 0700 -d ${D}${localstatedir}/spool/postfix/saved
179 chown postfix:root ${D}${localstatedir}/spool/postfix/saved
180 install -m 0700 -d ${D}${localstatedir}/spool/postfix/trace
181 chown postfix:root ${D}${localstatedir}/spool/postfix/trace
182 install -m 0730 -d ${D}${localstatedir}/spool/postfix/maildrop
183 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/maildrop
184 install -m 0755 -d ${D}${localstatedir}/spool/postfix/pid
185 chown root:root ${D}${localstatedir}/spool/postfix/pid
186 install -m 0700 -d ${D}${localstatedir}/spool/postfix/private
187 chown postfix:root ${D}${localstatedir}/spool/postfix/private
188 install -m 0710 -d ${D}${localstatedir}/spool/postfix/public
189 chown postfix:postdrop ${D}${localstatedir}/spool/postfix/public
190 install -m 0755 -d ${D}${localstatedir}/spool/vmail
191 chown vmail:vmail ${D}${localstatedir}/spool/vmail
192
193 chown :postdrop ${D}${sbindir}/postqueue
194 chown :postdrop ${D}${sbindir}/postdrop
195 chmod g+s ${D}${sbindir}/postqueue
196 chmod g+s ${D}${sbindir}/postdrop
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800197
198 rm -rf ${D}/etc/postfix/makedefs.out
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500199}
200
Patrick Williams213cb262021-08-07 19:21:33 -0500201do_install:append:class-native() {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500202 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases
203 ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq
204}
205
Patrick Williams213cb262021-08-07 19:21:33 -0500206ALTERNATIVE:${PN}-bin = "sendmail mailq newaliases"
Brad Bishop26bdd442019-08-16 17:08:17 -0400207# /usr/lib/sendmial is required by LSB core test
Patrick Williams213cb262021-08-07 19:21:33 -0500208ALTERNATIVE:${PN}-bin:linuxstdbase = "sendmail mailq newaliases usr-lib-sendmail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800209ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq"
210ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500211ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix"
212ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail"
Brad Bishop26bdd442019-08-16 17:08:17 -0400213ALTERNATIVE_TARGET[usr-lib-sendmail] = "${sbindir}/sendmail.postfix"
214ALTERNATIVE_LINK_NAME[usr-lib-sendmail] = "/usr/lib/sendmail"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800215
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500216ALTERNATIVE_PRIORITY = "120"
217
Patrick Williams213cb262021-08-07 19:21:33 -0500218ALTERNATIVE:${PN}-doc += "mailq.1 newaliases.1 sendmail.1"
Patrick Williamsddad1a12017-02-23 20:36:32 -0600219ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1"
220ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1"
221ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1"
222
Patrick Williams213cb262021-08-07 19:21:33 -0500223pkg_postinst_ontarget:${PN}-cfg () {
Brad Bishop2d39a062019-10-28 08:33:36 -0400224 touch /etc/aliases
225 newaliases
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500226
Brad Bishop2d39a062019-10-28 08:33:36 -0400227 # generate virtual_alias, default is hash
228 touch /etc/postfix/virtual_alias
229 postmap /etc/postfix/virtual_alias
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500230}
231
Brad Bishop2d39a062019-10-28 08:33:36 -0400232PACKAGES =+ "${PN}-cfg"
Patrick Williams213cb262021-08-07 19:21:33 -0500233RDEPENDS:${PN}-cfg:class-target += "${PN}-bin"
234RDEPENDS:${PN}:class-target += "${PN}-cfg"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500235# Exclude .debug directories from the main package
Patrick Williams213cb262021-08-07 19:21:33 -0500236FILES:${PN}-bin += "${localstatedir} ${bindir}/* ${sbindir}/* \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500237 ${libexecdir}/* ${systemd_unitdir}/*"
Patrick Williams213cb262021-08-07 19:21:33 -0500238FILES:${PN}-cfg = "${sysconfdir}"
239FILES:${PN}-dbg += "${libexecdir}/postfix/.debug"
240ALLOW_EMPTY:${PN} = "1"