aboutsummaryrefslogtreecommitdiffstats
path: root/packages/postfix/postfix_2.0.20.bb
blob: c64afeea03a8a2f5d369bba3cafc9862748410bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
SECTION = "console/network"
DEPENDS = "virtual/db libpcre postfix-native"
LICENSE = "IPL"
PR = "r10"

SRC_URI = "ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${PV}.tar.gz \
	   file://${FILESDIR}/makedefs.patch;patch=1 \
	   file://${FILESDIR}/install.patch;patch=1 \
	   file://main.cf_2.0 \
	   file://volatiles \
	   file://postfix \
	   "

S = "${WORKDIR}/postfix-${PV}"

inherit update-rc.d

INITSCRIPT_NAME = "postfix"
INITSCRIPT_PARAMS = "start 58 3 4 5 . stop 13 0 1 6 ."

#FIXME: this is broken because the native build won't work on systems where
# native bdb does not require libpthread.  ARM doesn't require libpthread
# because it uses an assembler mutex implementation.
LIBBDB_EXTRA = "-lpthread"
LIBBDB_EXTRA_arm = ""
LIBBDB_EXTRA_armeb = ""

export SYSLIBS = "-lpcre -ldb ${LIBBDB_EXTRA} -lnsl -lresolv ${LDFLAGS}"
export EXPORT = "AUXLIBS='-lpcre' CCARGS='-DHAS_PCRE ${CFLAGS}' OPT='' DEBUG='-g'"
export CC_append = " -DHAS_PCRE ${CFLAGS}"
export EXTRA_OEMAKE = "-e"
export POSTCONF = "${STAGING_BINDIR_NATIVE}/postconf"

do_compile () {
	unset CFLAGS CPPFLAGS CXXFLAGS
	oe_runmake makefiles
	oe_runmake
}

do_install () {
	sh ./postfix-install 'install_root=${D}' -non-interactive
	rm -rf ${D}${localstatedir}/spool/postfix
        mv ${D}${sysconfdir}/postfix/main.cf ${D}${sysconfdir}/postfix/sample-main.cf
	install -d ${D}${localstatedir}/tmp
	install -d ${D}${sysconfdir}/default/volatiles
	install -d ${D}${sysconfdir}/init.d
	install -m 755 ${WORKDIR}/main.cf_2.0 ${D}${localstatedir}/tmp/main_cf.sh
        install -m 644 ${WORKDIR}/volatiles ${D}${sysconfdir}/default/volatiles/01_postfix
        install -m 755 ${WORKDIR}/postfix ${D}${sysconfdir}/init.d/postfix
	mv ${D}${sbindir}/sendmail ${D}${sbindir}/sendmail.${PN}
}

pkg_postinst () {
        grep postfix /etc/group || addgroup postfix
        grep postdrop /etc/group || addgroup postdrop
        grep vmail /etc/group || addgroup vmail
        grep postfix /etc/passwd || adduser --disabled-password --home=/var/spool/postfix --ingroup postfix -g "Postfix" postfix
        grep vmail /etc/passwd || adduser --disabled-password --home=/var/spool/vmail --ingroup vmail -g "Postfix" vmail
	chgrp postdrop /usr/sbin/postqueue
	chgrp postdrop /usr/sbin/postdrop
	chmod g+s /usr/sbin/postqueue
	chmod g+s /usr/sbin/postdrop
	/var/tmp/main_cf.sh >/etc/postfix/main.cf
	rm -f /var/tmp/main_cf.sh
	chmod 644 /etc/postfix/main.cf
	[ -d /var/spool/postfix ] && rmdir /var/spool/postfix
	/etc/init.d/populate-volatile.sh update
	touch /etc/aliases
	newaliases
	update-alternatives --install sendmail sendmail ${sbindir}/sendmail.${PN} 40
}

pkg_postrm () {
	update-alternatives --remove sendmail ${sbindir}/sendmail 
}

# Exclude .debug directories from the main package
FILES_${PN} = "${sysconfdir} ${localstatedir} ${bindir}/* ${sbindir}/* \
               ${libexecdir}/postfix/*"
FILES_${PN}-dbg += "${libexecdir}/postfix/.debug"