diff options
author | Jackie Huang <jackie.huang@windriver.com> | 2014-07-13 22:27:15 -0400 |
---|---|---|
committer | Joe MacDonald <joe_macdonald@mentor.com> | 2014-07-20 23:30:19 -0400 |
commit | 96acc14b6c4928f52aa2f44af9532f3e2065b067 (patch) | |
tree | 5ee31cad6aefaf80a15e89179a79e54f37c1359c /meta-networking/recipes-daemons/postfix/postfix.inc | |
parent | 239debcd8a0359aad64406476b801948f9b8ff14 (diff) | |
download | meta-openembedded-96acc14b6c4928f52aa2f44af9532f3e2065b067.tar.gz |
postfix: add new recipe
Postfix is Wietse Venema's mail server that started life at IBM
research as an alternative to the widely-used Sendmail program.
Postfix attempts to be fast, easy to administer, and secure.
The outside has a definite Sendmail-ish flavor, but the inside
is completely different.
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking/recipes-daemons/postfix/postfix.inc')
-rw-r--r-- | meta-networking/recipes-daemons/postfix/postfix.inc | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/postfix/postfix.inc b/meta-networking/recipes-daemons/postfix/postfix.inc new file mode 100644 index 000000000..c58787ed6 --- /dev/null +++ b/meta-networking/recipes-daemons/postfix/postfix.inc | |||
@@ -0,0 +1,230 @@ | |||
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 = "console/network" | ||
9 | DEPENDS = "virtual/db libpcre openssl postfix-native \ | ||
10 | ${@base_contains('DISTRO_FEATURES', 'ldap', 'openldap', '', d)} \ | ||
11 | ${@base_contains('DISTRO_FEATURES', 'sasl', 'cyrus-sasl', '', d)} \ | ||
12 | " | ||
13 | DEPENDS_virtclass-native = "virtual/db-native openssl-native libpcre-native" | ||
14 | |||
15 | LICENSE = "IPL-1.0" | ||
16 | LIC_FILES_CHKSUM = "file://LICENSE;md5=64375f37431336ea1b1b3005fe3fa354" | ||
17 | |||
18 | SRC_URI = "ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${PV}.tar.gz \ | ||
19 | file://makedefs.patch \ | ||
20 | file://install.patch \ | ||
21 | file://main.cf_2.0 \ | ||
22 | file://postfix \ | ||
23 | file://internal_recipient \ | ||
24 | file://postfix.service \ | ||
25 | " | ||
26 | |||
27 | S = "${WORKDIR}/postfix-${PV}" | ||
28 | |||
29 | BBCLASSEXTEND = "native" | ||
30 | |||
31 | inherit update-rc.d useradd update-alternatives systemd | ||
32 | |||
33 | INITSCRIPT_NAME = "postfix" | ||
34 | INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ." | ||
35 | USERADD_PACKAGES = "${PN}" | ||
36 | USERADD_PARAM_${PN} = \ | ||
37 | "-d /var/spool/postfix -r -g postfix --shell /bin/false postfix; \ | ||
38 | -d /var/spool/vmail -r -u 5000 -g vmail --shell /bin/false vmail \ | ||
39 | " | ||
40 | GROUPADD_PARAM_${PN} = "--system postfix;--system postdrop;-g 5000 --system vmail" | ||
41 | |||
42 | export SYSLIBS = "${LDFLAGS}" | ||
43 | |||
44 | # CCARGS specifies includes, defines | ||
45 | # AUXLIBS specifies libraries | ||
46 | # Linux2/Linux3 has HAS_DB defined | ||
47 | # makedefs will make CC to be CC+CCARGS | ||
48 | |||
49 | # ldap support | ||
50 | export CCARGS-ldap = "\ | ||
51 | ${@base_contains('DISTRO_FEATURES', 'ldap', '-DHAS_LDAP', '', d)}" | ||
52 | export AUXLIBS-ldap = "\ | ||
53 | ${@base_contains('DISTRO_FEATURES', 'ldap', '-lldap -llber', '', d)}" | ||
54 | |||
55 | # no native openldap | ||
56 | export CCARGS-ldap_virtclass-native = "" | ||
57 | export AUXLIBS-ldap_virtclass-native = "" | ||
58 | |||
59 | # SASL support -DUSE_LDAP_SASL -DUSE_SASL_AUTH | ||
60 | # current openldap didn't enable SASL | ||
61 | export CCARGS-sasl = "\ | ||
62 | ${@base_contains('DISTRO_FEATURES', 'sasl', '-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I=/usr/include/sasl', '', d)}" | ||
63 | export AUXLIBS-sasl = "\ | ||
64 | ${@base_contains('DISTRO_FEATURES', 'sasl', '-lsasl2', '', d)}" | ||
65 | export CCARGS-sasl_virtclass-native = "" | ||
66 | export AUXLIBS-sasl_virtclass-native = "" | ||
67 | |||
68 | # PCRE, TLS support default | ||
69 | export CCARGS = "${CFLAGS} -DHAS_PCRE -DUSE_TLS ${CCARGS-ldap} ${CCARGS-sasl}" | ||
70 | export AUXLIBS = "-lpcre -lssl -lcrypto ${AUXLIBS-sasl} ${AUXLIBS-ldap}" | ||
71 | export POSTCONF = "${STAGING_DIR_NATIVE}${sbindir_native}/postconf" | ||
72 | |||
73 | # OPT,DEBUG is aready in CFLAGS | ||
74 | # ignore the OPTS="CC=$CC" in Makefile it will not use the CC=$CC $CCARGS | ||
75 | EXTRA_OEMAKE += "OPT= DEBUG= OPTS= " | ||
76 | |||
77 | do_compile () { | ||
78 | unset CFLAGS CPPFLAGS CXXFLAGS | ||
79 | local native_build | ||
80 | |||
81 | native_build="${@['0', '1'][bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d)]}" | ||
82 | |||
83 | # if not native build, then pass SYSTEM and RELEASE to makedefs | ||
84 | if [ "${native_build}" != "1" ]; then | ||
85 | # uname -s for target | ||
86 | SYSTEM="Linux" | ||
87 | |||
88 | # uname -r, use 2.6 as bottomline, even target kernel ver > 2.6 | ||
89 | RELEASE="2.6.34" | ||
90 | sed -i -e \ | ||
91 | "s:\$(SHELL) makedefs):\$(SHELL) makedefs $SYSTEM $RELEASE):" \ | ||
92 | ${S}/Makefile.in | ||
93 | export BUILD_SYSROOT="${STAGING_DIR_HOST}" | ||
94 | export BUILD_SYSROOT_NSL_PATH="${STAGING_BASELIBDIR} \ | ||
95 | ${STAGING_LIBDIR}" | ||
96 | else | ||
97 | # native build | ||
98 | export BUILD_SYSROOT="${STAGING_DIR_NATIVE}" | ||
99 | |||
100 | # ubuntu x86 host: /lib/x86_64-linux-gnu(64) /lib/i386-linux-gnu (32) | ||
101 | # on 64 bits, 32 libs in i386-linux-gnu | ||
102 | # let makedefs finds nsl and resolv libs, host CC will link | ||
103 | # the correct libraries | ||
104 | BUILD_SYSROOT_NSL_PATH="$(${CC} -print-search-dirs 2>/dev/null | \ | ||
105 | sed -n '/^libraries: =/s/libraries: =//p' | \ | ||
106 | sed -e 's/:/\n/g' | xargs -n1 readlink -f | \ | ||
107 | grep -v 'gcc\|/[0-9.]\+$' | sort -u)" | ||
108 | if [ -z "$BUILD_SYSROOT_NSL_PATH" ]; then | ||
109 | BUILD_SYSROOT_NSL_PATH="/usr/lib64 /lib64 \ | ||
110 | /lib/x86_64-linux-gnu \ | ||
111 | /usr/lib /lib \ | ||
112 | /lib/i386-linux-gnu" | ||
113 | fi | ||
114 | export BUILD_SYSROOT_NSL_PATH | ||
115 | fi | ||
116 | |||
117 | oe_runmake makefiles | ||
118 | oe_runmake | ||
119 | } | ||
120 | |||
121 | do_install_prepend_virtclass-native() { | ||
122 | export POSTCONF="bin/postconf" | ||
123 | } | ||
124 | |||
125 | SYSTEMD_SERVICE_${PN} = "postfix.service" | ||
126 | SYSTEMD_AUTO_ENABLE = "disable" | ||
127 | |||
128 | do_install () { | ||
129 | sh ./postfix-install 'install_root=${D}' \ | ||
130 | 'config_directory=${sysconfdir}/postfix' \ | ||
131 | 'daemon_directory=${exec_prefix}/libexec/postfix' \ | ||
132 | 'command_directory=${sbindir}' \ | ||
133 | 'queue_directory=${localstatedir}/spool/postfix' \ | ||
134 | 'sendmail_path=${sbindir}/sendmail.postfix' \ | ||
135 | 'newaliases_path=${bindir}/newaliases' \ | ||
136 | 'mailq_path=${bindir}/mailq' \ | ||
137 | 'manpage_directory=${mandir}' \ | ||
138 | 'readme_directory=${datadir}/doc/postfix' \ | ||
139 | 'data_directory=${localstatedir}/lib/postfix' \ | ||
140 | -non-interactive | ||
141 | rm -rf ${D}${localstatedir}/spool/postfix | ||
142 | mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/sample-main.cf | ||
143 | install -d ${D}${sysconfdir}/init.d | ||
144 | install -m 644 ${WORKDIR}/main.cf_2.0 ${D}${sysconfdir}/postfix/main.cf | ||
145 | install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix | ||
146 | install -m 644 ${WORKDIR}/internal_recipient ${D}${sysconfdir}/postfix/internal_recipient | ||
147 | |||
148 | install -d ${D}${systemd_unitdir}/system | ||
149 | install -m 0644 ${WORKDIR}/postfix.service ${D}${systemd_unitdir}/system | ||
150 | sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${systemd_unitdir}/system/postfix.service | ||
151 | |||
152 | install -m 770 -d ${D}${localstatedir}/spool/postfix | ||
153 | chown postfix:postfix ${D}${localstatedir}/spool/postfix | ||
154 | chown postfix:postfix ${D}${localstatedir}/lib/postfix | ||
155 | |||
156 | install -m 2755 -d ${D}${localstatedir}/spool/mail | ||
157 | chown postfix:nogroup ${D}${localstatedir}/spool/mail | ||
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 | ||
197 | } | ||
198 | |||
199 | do_install_append_class-native() { | ||
200 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/newaliases | ||
201 | ln -sf ../sbin/sendmail.postfix ${D}${bindir}/mailq | ||
202 | } | ||
203 | |||
204 | NATIVE_INSTALL_WORKS = "1" | ||
205 | |||
206 | ALTERNATIVE_${PN} = "sendmail" | ||
207 | ALTERNATIVE_TARGET[sendmail] = "${sbindir}/sendmail.postfix" | ||
208 | ALTERNATIVE_LINK_NAME[sendmail] = "${sbindir}/sendmail" | ||
209 | ALTERNATIVE_PRIORITY = "120" | ||
210 | |||
211 | pkg_postinst_${PN} () { | ||
212 | if [ "x$D" = "x" ]; then | ||
213 | touch /etc/aliases | ||
214 | newaliases | ||
215 | |||
216 | # generate virtual_alias, default is hash | ||
217 | touch /etc/postfix/virtual_alias | ||
218 | postmap /etc/postfix/virtual_alias | ||
219 | else | ||
220 | touch $D/etc/aliases | ||
221 | newaliases -C $D/etc/postfix/main.cf -oA$D/etc/aliases | ||
222 | touch $D/etc/postfix/virtual_alias | ||
223 | postmap -c $D/etc/postfix $D/etc/postfix/virtual_alias | ||
224 | fi | ||
225 | } | ||
226 | |||
227 | # Exclude .debug directories from the main package | ||
228 | FILES_${PN} = "${sysconfdir} ${localstatedir} ${bindir}/* ${sbindir}/* \ | ||
229 | ${exec_prefix}/libexec/postfix/* ${systemd_unitdir}/*" | ||
230 | FILES_${PN}-dbg += "${exec_prefix}/libexec/postfix/.debug" | ||