Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | SUMMARY = "Postfix Mail Transport Agent" |
| 2 | DESCRIPTION = "Postfix is Wietse Venema's mail server that started life at \ |
| 3 | IBM research as an alternative to the widely-used Sendmail program. \ |
| 4 | Postfix attempts to be fast, easy to administer, and secure. The outsidei \ |
| 5 | has a definite Sendmail-ish flavor, but the inside is completely different." |
| 6 | |
| 7 | HOMEPAGE= "http://www.postfix.org" |
| 8 | SECTION = "mail" |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 9 | DEPENDS = "db icu libpcre libnsl2 m4-native openssl postfix-native \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 10 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', 'openldap', '', d)} \ |
| 11 | ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', 'cyrus-sasl', '', d)} \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 12 | " |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 13 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 14 | LICENSE = "IPL-1.0 | EPL-2.0" |
| 15 | LIC_FILES_CHKSUM = "file://LICENSE;md5=b181651ad99a7dc4cc8c4ce2f491ed1a" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 16 | |
Patrick Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame^] | 17 | SRC_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 | |
| 31 | SRC_URI[sha256sum] = "f3e827a2b2e410359ad25d31341970434ab07e36139f9a2ef93981b0ec564c85" |
| 32 | |
| 33 | UPSTREAM_CHECK_REGEX = "postfix\-(?P<pver>3\.8(\.\d+)+).tar.gz" |
| 34 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 35 | S = "${WORKDIR}/postfix-${PV}" |
| 36 | |
| 37 | CLEANBROKEN = "1" |
| 38 | |
| 39 | BBCLASSEXTEND = "native" |
| 40 | |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 41 | inherit pkgconfig update-rc.d useradd update-alternatives systemd lib_package |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 42 | |
| 43 | INITSCRIPT_NAME = "postfix" |
| 44 | INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ." |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 45 | USERADD_PACKAGES = "${PN}-bin" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 46 | USERADD_PARAM:${PN}-bin = \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 47 | "-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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 50 | GROUPADD_PARAM:${PN}-bin = "--system postfix;--system postdrop;--system vmail" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 51 | |
| 52 | export 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 |
| 60 | export CCARGS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 61 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 62 | export AUXLIBS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 63 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 64 | |
| 65 | # no native openldap |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 66 | export CCARGS-ldap:class-native = "" |
| 67 | export AUXLIBS-ldap:class-native = "" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 68 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 69 | export CCARGS-nonis:libc-musl = "-DNO_NIS" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | export CCARGS-nonis = "" |
| 71 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 72 | # SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH |
| 73 | # current openldap didn't enable SASL |
| 74 | export CCARGS-sasl = "\ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 75 | ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${STAGING_INCDIR}/sasl', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 76 | export AUXLIBS-sasl = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 77 | ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 78 | export CCARGS-sasl:class-native = "" |
| 79 | export AUXLIBS-sasl:class-native = "" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 80 | |
| 81 | # PCRE, TLS support default |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 82 | export CCARGS = "${CFLAGS} -DHAS_PCRE -DUSE_TLS -I${STAGING_INCDIR}/openssl ${CCARGS-ldap} ${CCARGS-sasl} ${CCARGS-nonis}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 83 | export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}" |
| 84 | export 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 |
| 88 | EXTRA_OEMAKE += "OPT= DEBUG= OPTS= " |
| 89 | |
| 90 | do_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 Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 107 | else |
| 108 | # native build |
| 109 | export BUILD_SYSROOT="${STAGING_DIR_NATIVE}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 110 | fi |
| 111 | |
| 112 | oe_runmake makefiles |
| 113 | oe_runmake |
| 114 | } |
| 115 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 116 | do_install:prepend:class-native() { |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 117 | export POSTCONF="bin/postconf" |
| 118 | } |
| 119 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 120 | SYSTEMD_SERVICE:${PN} = "postfix.service" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 121 | |
| 122 | do_install () { |
| 123 | sh ./postfix-install 'install_root=${D}' \ |
| 124 | 'config_directory=${sysconfdir}/postfix' \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 125 | 'daemon_directory=${libexecdir}/postfix' \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 126 | '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 Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 136 | mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/${MLPREFIX}sample-main.cf |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 137 | install -m 755 ${S}/bin/smtp-sink ${D}/${sbindir}/ |
| 138 | install -d ${D}${sysconfdir}/init.d |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 139 | install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 140 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 153 | install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 154 | |
| 155 | install -m 770 -d ${D}${localstatedir}/spool/postfix |
| 156 | chown postfix:postfix ${D}${localstatedir}/spool/postfix |
| 157 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 158 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 197 | |
| 198 | rm -rf ${D}/etc/postfix/makedefs.out |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 199 | } |
| 200 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 201 | do_install:append:class-native() { |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 202 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases |
| 203 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq |
| 204 | } |
| 205 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 206 | ALTERNATIVE:${PN}-bin = "sendmail mailq newaliases" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 207 | # /usr/lib/sendmial is required by LSB core test |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 208 | ALTERNATIVE:${PN}-bin:linuxstdbase = "sendmail mailq newaliases usr-lib-sendmail" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 209 | ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq" |
| 210 | ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 211 | ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix" |
| 212 | ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 213 | ALTERNATIVE_TARGET[usr-lib-sendmail] = "${sbindir}/sendmail.postfix" |
| 214 | ALTERNATIVE_LINK_NAME[usr-lib-sendmail] = "/usr/lib/sendmail" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 215 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 216 | ALTERNATIVE_PRIORITY = "120" |
| 217 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 218 | ALTERNATIVE:${PN}-doc += "mailq.1 newaliases.1 sendmail.1" |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 219 | ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1" |
| 220 | ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1" |
| 221 | ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1" |
| 222 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 223 | pkg_postinst_ontarget:${PN}-cfg () { |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 224 | touch /etc/aliases |
| 225 | newaliases |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 226 | |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 227 | # generate virtual_alias, default is hash |
| 228 | touch /etc/postfix/virtual_alias |
| 229 | postmap /etc/postfix/virtual_alias |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 230 | } |
| 231 | |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 232 | PACKAGES =+ "${PN}-cfg" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 233 | RDEPENDS:${PN}-cfg:class-target += "${PN}-bin" |
| 234 | RDEPENDS:${PN}:class-target += "${PN}-cfg" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 235 | # Exclude .debug directories from the main package |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 236 | FILES:${PN}-bin += "${localstatedir} ${bindir}/* ${sbindir}/* \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 237 | ${libexecdir}/* ${systemd_unitdir}/*" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 238 | FILES:${PN}-cfg = "${sysconfdir}" |
| 239 | FILES:${PN}-dbg += "${libexecdir}/postfix/.debug" |
| 240 | ALLOW_EMPTY:${PN} = "1" |