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 | |
| 17 | SRC_URI = "ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${PV}.tar.gz \ |
| 18 | file://makedefs.patch \ |
| 19 | file://install.patch \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | file://main.cf \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 21 | file://postfix \ |
| 22 | file://internal_recipient \ |
| 23 | file://postfix.service \ |
| 24 | file://aliasesdb \ |
| 25 | file://check_hostname.sh \ |
| 26 | " |
| 27 | |
| 28 | S = "${WORKDIR}/postfix-${PV}" |
| 29 | |
| 30 | CLEANBROKEN = "1" |
| 31 | |
| 32 | BBCLASSEXTEND = "native" |
| 33 | |
| 34 | inherit update-rc.d useradd update-alternatives systemd |
| 35 | |
| 36 | INITSCRIPT_NAME = "postfix" |
| 37 | INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ." |
| 38 | USERADD_PACKAGES = "${PN}" |
| 39 | USERADD_PARAM_${PN} = \ |
| 40 | "-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \ |
| 41 | -d /var/spool/vmail -r -g vmail --shell /bin/false vmail \ |
| 42 | " |
| 43 | GROUPADD_PARAM_${PN} = "--system postfix;--system postdrop;--system vmail" |
| 44 | |
| 45 | export SYSLIBS = "${LDFLAGS}" |
| 46 | |
| 47 | # CCARGS specifies includes, defines |
| 48 | # AUXLIBS specifies libraries |
| 49 | # Linux2/Linux3 has HAS_DB defined |
| 50 | # makedefs will make CC to be CC+CCARGS |
| 51 | |
| 52 | # ldap support |
| 53 | export CCARGS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 54 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 55 | export AUXLIBS-ldap = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 56 | ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 57 | |
| 58 | # no native openldap |
| 59 | export CCARGS-ldap_class-native = "" |
| 60 | export AUXLIBS-ldap_class-native = "" |
| 61 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 62 | export CCARGS-nonis_libc-musl = "-DNO_NIS" |
| 63 | export CCARGS-nonis = "" |
| 64 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 65 | # SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH |
| 66 | # current openldap didn't enable SASL |
| 67 | export CCARGS-sasl = "\ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | ${@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] | 69 | export AUXLIBS-sasl = "\ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 70 | ${@bb.utils.contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 71 | export CCARGS-sasl_class-native = "" |
| 72 | export AUXLIBS-sasl_class-native = "" |
| 73 | |
| 74 | # PCRE, TLS support default |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 75 | 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] | 76 | export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}" |
| 77 | export POSTCONF = "${STAGING_DIR_NATIVE}${sbindir_native}/postconf" |
| 78 | |
| 79 | # OPT,DEBUG is aready in CFLAGS |
| 80 | # ignore the OPTS="CC=$CC" in Makefile it will not use the CC=$CC $CCARGS |
| 81 | EXTRA_OEMAKE += "OPT= DEBUG= OPTS= " |
| 82 | |
| 83 | do_compile () { |
| 84 | unset CFLAGS CPPFLAGS CXXFLAGS |
| 85 | local native_build |
| 86 | |
| 87 | native_build="${@['0', '1'][bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d)]}" |
| 88 | |
| 89 | # if not native build, then pass SYSTEM and RELEASE to makedefs |
| 90 | if [ "${native_build}" != "1" ]; then |
| 91 | # uname -s for target |
| 92 | SYSTEM="Linux" |
| 93 | |
| 94 | # uname -r, use 2.6 as bottomline, even target kernel ver > 2.6 |
| 95 | RELEASE="2.6.34" |
| 96 | sed -i -e \ |
| 97 | "s:\$(SHELL) makedefs):\$(SHELL) makedefs $SYSTEM $RELEASE):" \ |
| 98 | ${S}/Makefile.in |
| 99 | export BUILD_SYSROOT="${STAGING_DIR_HOST}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 100 | else |
| 101 | # native build |
| 102 | export BUILD_SYSROOT="${STAGING_DIR_NATIVE}" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 103 | fi |
| 104 | |
| 105 | oe_runmake makefiles |
| 106 | oe_runmake |
| 107 | } |
| 108 | |
| 109 | do_install_prepend_class-native() { |
| 110 | export POSTCONF="bin/postconf" |
| 111 | } |
| 112 | |
| 113 | SYSTEMD_SERVICE_${PN} = "postfix.service" |
| 114 | |
| 115 | do_install () { |
| 116 | sh ./postfix-install 'install_root=${D}' \ |
| 117 | 'config_directory=${sysconfdir}/postfix' \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 118 | 'daemon_directory=${libexecdir}/postfix' \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 119 | 'command_directory=${sbindir}' \ |
| 120 | 'queue_directory=${localstatedir}/spool/postfix' \ |
| 121 | 'sendmail_path=${sbindir}/sendmail.postfix' \ |
| 122 | 'newaliases_path=${bindir}/newaliases' \ |
| 123 | 'mailq_path=${bindir}/mailq' \ |
| 124 | 'manpage_directory=${mandir}' \ |
| 125 | 'readme_directory=${datadir}/doc/postfix' \ |
| 126 | 'data_directory=${localstatedir}/lib/postfix' \ |
| 127 | -non-interactive |
| 128 | rm -rf ${D}${localstatedir}/spool/postfix |
| 129 | mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/sample-main.cf |
| 130 | install -m 755 ${S}/bin/smtp-sink ${D}/${sbindir}/ |
| 131 | install -d ${D}${sysconfdir}/init.d |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 132 | install -m 644 ${WORKDIR}/main.cf ${D}${sysconfdir}/postfix/main.cf |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 133 | sed -i 's#@LIBEXECDIR@#${libexecdir}#' ${D}${sysconfdir}/postfix/main.cf |
| 134 | |
| 135 | install -m 755 ${WORKDIR}/check_hostname.sh ${D}${sbindir}/ |
| 136 | |
| 137 | install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix |
| 138 | install -m 644 ${WORKDIR}/internal_recipient ${D}${sysconfdir}/postfix/internal_recipient |
| 139 | |
| 140 | install -d ${D}${systemd_unitdir}/system |
| 141 | install -m 0644 ${WORKDIR}/postfix.service ${D}${systemd_unitdir}/system |
| 142 | sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}${systemd_unitdir}/system/postfix.service |
| 143 | sed -i -e 's#@LOCALSTATEDIR@#${localstatedir}#g' ${D}${systemd_unitdir}/system/postfix.service |
| 144 | sed -i -e 's#@SBINDIR@#${sbindir}#g' ${D}${systemd_unitdir}/system/postfix.service |
| 145 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 146 | install -m 0755 ${WORKDIR}/aliasesdb ${D}${libexecdir}/postfix |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 147 | |
| 148 | install -m 770 -d ${D}${localstatedir}/spool/postfix |
| 149 | chown postfix:postfix ${D}${localstatedir}/spool/postfix |
| 150 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 151 | install -m 0755 -d ${D}${localstatedir}/lib/postfix |
| 152 | chown postfix:nogroup ${D}${localstatedir}/lib/postfix |
| 153 | install -m 0755 -d ${D}${localstatedir}/spool/postfix |
| 154 | chown root:postfix ${D}${localstatedir}/spool/postfix |
| 155 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/active |
| 156 | chown postfix:root ${D}${localstatedir}/spool/postfix/active |
| 157 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/bounce |
| 158 | chown postfix:root ${D}${localstatedir}/spool/postfix/bounce |
| 159 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/corrupt |
| 160 | chown postfix:root ${D}${localstatedir}/spool/postfix/corrupt |
| 161 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/defer |
| 162 | chown postfix:root ${D}${localstatedir}/spool/postfix/defer |
| 163 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/deferred |
| 164 | chown postfix:root ${D}${localstatedir}/spool/postfix/deferred |
| 165 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/flush |
| 166 | chown postfix:root ${D}${localstatedir}/spool/postfix/flush |
| 167 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/hold |
| 168 | chown postfix:root ${D}${localstatedir}/spool/postfix/hold |
| 169 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/incoming |
| 170 | chown postfix:root ${D}${localstatedir}/spool/postfix/incoming |
| 171 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/saved |
| 172 | chown postfix:root ${D}${localstatedir}/spool/postfix/saved |
| 173 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/trace |
| 174 | chown postfix:root ${D}${localstatedir}/spool/postfix/trace |
| 175 | install -m 0730 -d ${D}${localstatedir}/spool/postfix/maildrop |
| 176 | chown postfix:postdrop ${D}${localstatedir}/spool/postfix/maildrop |
| 177 | install -m 0755 -d ${D}${localstatedir}/spool/postfix/pid |
| 178 | chown root:root ${D}${localstatedir}/spool/postfix/pid |
| 179 | install -m 0700 -d ${D}${localstatedir}/spool/postfix/private |
| 180 | chown postfix:root ${D}${localstatedir}/spool/postfix/private |
| 181 | install -m 0710 -d ${D}${localstatedir}/spool/postfix/public |
| 182 | chown postfix:postdrop ${D}${localstatedir}/spool/postfix/public |
| 183 | install -m 0755 -d ${D}${localstatedir}/spool/vmail |
| 184 | chown vmail:vmail ${D}${localstatedir}/spool/vmail |
| 185 | |
| 186 | chown :postdrop ${D}${sbindir}/postqueue |
| 187 | chown :postdrop ${D}${sbindir}/postdrop |
| 188 | chmod g+s ${D}${sbindir}/postqueue |
| 189 | chmod g+s ${D}${sbindir}/postdrop |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 190 | |
| 191 | rm -rf ${D}/etc/postfix/makedefs.out |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | do_install_append_class-native() { |
| 195 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases |
| 196 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq |
| 197 | } |
| 198 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 199 | ALTERNATIVE_${PN} += "sendmail mailq newaliases" |
| 200 | ALTERNATIVE_TARGET[mailq] = "${bindir}/mailq" |
| 201 | ALTERNATIVE_TARGET[newaliases] = "${bindir}/newaliases" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 202 | ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix" |
| 203 | ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 204 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 205 | ALTERNATIVE_PRIORITY = "120" |
| 206 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 207 | ALTERNATIVE_${PN}-doc += "mailq.1 newaliases.1 sendmail.1" |
| 208 | ALTERNATIVE_LINK_NAME[mailq.1] = "${mandir}/man1/mailq.1" |
| 209 | ALTERNATIVE_LINK_NAME[newaliases.1] = "${mandir}/man1/newaliases.1" |
| 210 | ALTERNATIVE_LINK_NAME[sendmail.1] = "${mandir}/man1/sendmail.1" |
| 211 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 212 | PACKAGE_WRITE_DEPS += "postfix-native" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 213 | pkg_postinst_${PN} () { |
| 214 | if [ "x$D" = "x" ]; then |
| 215 | touch /etc/aliases |
| 216 | newaliases |
| 217 | |
| 218 | # generate virtual_alias, default is hash |
| 219 | touch /etc/postfix/virtual_alias |
| 220 | postmap /etc/postfix/virtual_alias |
| 221 | else |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 222 | if ${@'true' if 'linuxstdbase' in d.getVar('DISTROOVERRIDES', False) else 'false'}; then |
| 223 | # /usr/lib/sendmail is required by LSB core test |
| 224 | [ ! -L $D/usr/lib/sendmail ] && ln -sf ${sbindir}/sendmail $D/usr/lib/ |
| 225 | fi |
| 226 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 227 | touch $D/etc/aliases |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 228 | # This can fail depending on host setup |
| 229 | if ! newaliases -C $D/etc/postfix/main.cf -oA$D/etc/aliases; then |
| 230 | $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 231 | else |
| 232 | touch $D/etc/postfix/virtual_alias |
| 233 | postmap -c $D/etc/postfix $D/etc/postfix/virtual_alias |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 234 | fi |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 235 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 236 | fi |
| 237 | } |
| 238 | |
| 239 | # Exclude .debug directories from the main package |
| 240 | FILES_${PN} = "${sysconfdir} ${localstatedir} ${bindir}/* ${sbindir}/* \ |
| 241 | ${libexecdir}/* ${systemd_unitdir}/*" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 242 | FILES_${PN}-dbg += "${libexecdir}/postfix/.debug" |