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" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 9 | DEPENDS = "db icu libpcre libnsl2 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 | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 17 | S = "${WORKDIR}/postfix-${PV}" |
| 18 | |
| 19 | CLEANBROKEN = "1" |
| 20 | |
| 21 | BBCLASSEXTEND = "native" |
| 22 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | inherit update-rc.d useradd update-alternatives systemd lib_package |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 24 | |
| 25 | INITSCRIPT_NAME = "postfix" |
| 26 | INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ." |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 27 | USERADD_PACKAGES = "${PN}-bin" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 28 | USERADD_PARAM:${PN}-bin = \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 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 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 32 | GROUPADD_PARAM:${PN}-bin = "--system postfix;--system postdrop;--system vmail" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 33 | |
| 34 | export 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 |
| 42 | export CCARGS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 43 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 44 | export AUXLIBS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 45 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 46 | |
| 47 | # no native openldap |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 48 | export CCARGS-ldap:class-native = "" |
| 49 | export AUXLIBS-ldap:class-native = "" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 50 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 51 | export CCARGS-nonis:libc-musl = "-DNO_NIS" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 52 | export CCARGS-nonis = "" |
| 53 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 54 | # SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH |
| 55 | # current openldap didn't enable SASL |
| 56 | export CCARGS-sasl = "\ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 57 | ${@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] | 58 | export AUXLIBS-sasl = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 59 | ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 60 | export CCARGS-sasl:class-native = "" |
| 61 | export AUXLIBS-sasl:class-native = "" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 62 | |
| 63 | # PCRE, TLS support default |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 64 | 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] | 65 | export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}" |
| 66 | export 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 |
| 70 | EXTRA_OEMAKE += "OPT= DEBUG= OPTS= " |
| 71 | |
| 72 | do_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 Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 89 | else |
| 90 | # native build |
| 91 | export BUILD_SYSROOT="${STAGING_DIR_NATIVE}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 92 | fi |
| 93 | |
| 94 | oe_runmake makefiles |
| 95 | oe_runmake |
| 96 | } |
| 97 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 98 | do_install:prepend:class-native() { |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 99 | export POSTCONF="bin/postconf" |
| 100 | } |
| 101 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 102 | SYSTEMD_SERVICE:${PN} = "postfix.service" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 103 | |
| 104 | do_install () { |
| 105 | sh ./postfix-install 'install_root=${D}' \ |
| 106 | 'config_directory=${sysconfdir}/postfix' \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 107 | 'daemon_directory=${libexecdir}/postfix' \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 108 | '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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 121 | install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 122 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 135 | install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 136 | |
| 137 | install -m 770 -d ${D}${localstatedir}/spool/postfix |
| 138 | chown postfix:postfix ${D}${localstatedir}/spool/postfix |
| 139 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 140 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 179 | |
| 180 | rm -rf ${D}/etc/postfix/makedefs.out |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 181 | } |
| 182 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 183 | do_install:append:class-native() { |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 184 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases |
| 185 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq |
| 186 | } |
| 187 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 188 | ALTERNATIVE:${PN}-bin = "sendmail mailq newaliases" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 189 | # /usr/lib/sendmial is required by LSB core test |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 190 | ALTERNATIVE:${PN}-bin:linuxstdbase = "sendmail mailq newaliases usr-lib-sendmail" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 191 | ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq" |
| 192 | ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 193 | ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix" |
| 194 | ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 195 | ALTERNATIVE_TARGET[usr-lib-sendmail] = "${sbindir}/sendmail.postfix" |
| 196 | ALTERNATIVE_LINK_NAME[usr-lib-sendmail] = "/usr/lib/sendmail" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 197 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 198 | ALTERNATIVE_PRIORITY = "120" |
| 199 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 200 | ALTERNATIVE:${PN}-doc += "mailq.1 newaliases.1 sendmail.1" |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 201 | ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1" |
| 202 | ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1" |
| 203 | ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1" |
| 204 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 205 | pkg_postinst_ontarget:${PN}-cfg () { |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 206 | touch /etc/aliases |
| 207 | newaliases |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 208 | |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 209 | # generate virtual_alias, default is hash |
| 210 | touch /etc/postfix/virtual_alias |
| 211 | postmap /etc/postfix/virtual_alias |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 212 | } |
| 213 | |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame] | 214 | PACKAGES =+ "${PN}-cfg" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 215 | RDEPENDS:${PN}-cfg:class-target += "${PN}-bin" |
| 216 | RDEPENDS:${PN}:class-target += "${PN}-cfg" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 217 | # Exclude .debug directories from the main package |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 218 | FILES:${PN}-bin += "${localstatedir} ${bindir}/* ${sbindir}/* \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 219 | ${libexecdir}/* ${systemd_unitdir}/*" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 220 | FILES:${PN}-cfg = "${sysconfdir}" |
| 221 | FILES:${PN}-dbg += "${libexecdir}/postfix/.debug" |
| 222 | ALLOW_EMPTY:${PN} = "1" |