2 # Copyright (C) 2014 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
12 PKG_SOURCE_URL
:=ftp
://ftp.porcupine.org
/mirrors
/postfix-release
/official
/
14 PKG_MD5SUM
:=c3f0f51d8865559b40e9350eb3816011
15 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.gz
16 PKG_MAINTAINER
:=Denis Shulyaka
<Shulyaka@gmail.com
>
18 PKG_LICENSE_FILES
:=LICENSE
19 PKG_BUILD_DEPENDS
:=+POSTFIX_CDB
:tinycdb
21 include $(INCLUDE_DIR
)/package.mk
23 define Package
/postfix
26 TITLE
:=Postfix Mail Transmit Agent
27 URL
:=http
://www.postfix.org
/
28 DEPENDS
:=+POSTFIX_TLS
:libopenssl
+POSTFIX_SASL
:libsasl2
+POSTFIX_LDAP
:libopenldap
+POSTFIX_DB
:libdb47
+libpcre
31 define Package
/postfix
/description
32 Postfix is Wietse Venema
's mailer that started life as an alternative to the widely-used Sendmail program. Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users. Thus, the outside has a sendmail-ish flavor, but the inside is completely different.
35 define Package/postfix/config
36 menu "Select postfix build options"
41 Implements TLS support in postfix (using OpenSSL).
46 Implements SASL support in postfix (using Cyrus SASL).
51 Implements LDAP support in postfix (using OpenLDAP).
53 bool "BerkeleyDB support"
56 Implements support for btree files using Berkeley DB. Note that hash files support is not compiled into Berkeley DB OpenWRT distribution
61 Implements support for cdb files using tinycdb
65 CCARGS=-DNO_EPOLL -DNO_SIGSETJMP -DNO_NIS
66 AUXLIBS=-L$(STAGING_DIR)/usr/lib
67 default_database_type=cdb
69 ifdef CONFIG_POSTFIX_TLS
71 AUXLIBS+=-lssl -lcrypto
74 ifdef CONFIG_POSTFIX_SASL
75 CCARGS+=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I$(STAGING_DIR)/usr/include/sasl
79 ifdef CONFIG_POSTFIX_LDAP
81 AUXLIBS+=-lldap -llber
84 ifdef CONFIG_POSTFIX_CDB
89 ifdef CONFIG_POSTFIX_DB
92 ifndef CONFIG_POSTFIX_CDB
93 default_database_type=btree
99 CCARGS+=-DDEF_DB_TYPE=\"$(default_database_type)\"
101 config_directory=/etc/postfix# also add this to postfix init file
102 sample_directory=/etc/postfix
103 command_directory=/usr/sbin
104 daemon_directory=/usr/libexec/postfix
105 data_directory=/usr/var/lib/postfix
106 queue_directory=/usr/var/spool/postfix
107 mail_spool_directory=/usr/var/mail
111 sendmail_path=/usr/sbin/sendmail
112 newaliases_path=/usr/bin/newaliases
113 mailq_path=/usr/bin/mailq
118 define Package/postfix/conffiles
119 $(config_directory)/main.cf
120 $(config_directory)/master.cf
121 $(config_directory)/aliases
124 define Build/Configure
125 if [ "$(CONFIG_POSTFIX_DB)" = "" -a "$(CONFIG_POSTFIX_CDB)" = "" ]; then\
126 echo "Build error: You must select at least one of the DB types";\
130 cd $(PKG_BUILD_DIR); $(MAKE) makefiles CCARGS='$(CCARGS
)' $(TARGET_CONFIGURE_OPTS) AUXLIBS="$(AUXLIBS)"
134 # Currently postfix has a bug with Makefiles that CCARGS are not passed to the compiler, so we are copying them to CC
135 cd $(PKG_BUILD_DIR); $(MAKE) $(TARGET_CONFIGURE_OPTS) CC='$(TARGET_CC
) $(CCARGS
)'
136 cp ./files/main.cf.default $(PKG_BUILD_DIR)/conf/main.cf.default
137 echo "default_database_type = $(default_database_type)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
138 echo "alias_database = $(default_database_type):$(config_directory)/aliases" >> $(PKG_BUILD_DIR)/conf/main.cf.default
139 echo "alias_maps = $(default_database_type):$(config_directory)/aliases" >> $(PKG_BUILD_DIR)/conf/main.cf.default
140 echo "sendmail_path = $(sendmail_path)$(ln_suffix)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
141 echo "newaliases_path = $(newaliases_path)$(ln_suffix)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
142 echo "mailq_path = $(mailq_path)$(ln_suffix)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
143 echo "html_directory = $(html_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
144 echo "manpage_directory = $(manpage_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
145 echo "sample_directory = $(sample_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
146 echo "readme_directory = $(readme_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
147 echo "command_directory = $(command_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
148 echo "daemon_directory = $(daemon_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
149 echo "data_directory = $(data_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
150 echo "queue_directory = $(queue_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
151 echo "config_directory = $(config_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
152 echo "mail_spool_directory = $(mail_spool_directory)" >> $(PKG_BUILD_DIR)/conf/main.cf.default
155 define Package/postfix/install
156 cd $(PKG_BUILD_DIR); $(MAKE) install_root=$(1) command_directory=$(command_directory) daemon_directory=$(daemon_directory) data_directory=$(data_directory) html_directory=$(html_directory) mail_owner=postfix mailq_path=$(mailq_path)$(ln_suffix) manpage_directory=$(manpage_directory) newaliases_path=$(newaliases_path)$(ln_suffix) queue_directory=$(queue_directory) readme_directory=$(readme_directory) sendmail_path=$(sendmail_path)$(ln_suffix) setgid_group=postdrop sample_directory=$(sample_directory) config_directory=$(config_directory) non-interactive-package
157 $(INSTALL_DIR) $(1)$(mail_spool_directory)
158 $(INSTALL_DIR) $(1)/etc/init.d/
159 $(INSTALL_BIN) ./files/postfix.init $(1)/etc/init.d/postfix
162 define Package/postfix/postinst
165 if [ -f "$${IPKG_INSTROOT}$(sendmail_path)" -a "$$(readlink "$${IPKG_INSTROOT}$(sendmail_path)")" != "$(sendmail_path)$(ln_suffix)" ]; then
166 mv "$${IPKG_INSTROOT}$(sendmail_path)" "$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
167 echo "Warning: $${IPKG_INSTROOT}$(sendmail_path) saved as $${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
169 if [ ! -f "$${IPKG_INSTROOT}$(sendmail_path)" ]; then
170 ln -s "$${IPKG_INSTROOT}$(sendmail_path)$(ln_suffix)" "$(sendmail_path)"
173 if [ -f "$${IPKG_INSTROOT}$(newaliases_path)" -a "$$(readlink "$${IPKG_INSTROOT}$(newaliases_path)")" != "$(newaliases_path)$(ln_suffix)" ]; then
174 mv "$${IPKG_INSTROOT}$(newaliases_path)" "$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
175 echo "Warning: $${IPKG_INSTROOT}$(newaliases_path) saved as $${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
177 if [ ! -f "$${IPKG_INSTROOT}$(newaliases_path)" ]; then
178 ln -s "$${IPKG_INSTROOT}$(newaliases_path)$(ln_suffix)" "$(newaliases_path)"
181 if [ -f "$${IPKG_INSTROOT}$(mailq_path)" -a "$$(readlink "$${IPKG_INSTROOT}$(mailq_path)")" != "$(mailq_path)$(ln_suffix)" ]; then
182 mv "$${IPKG_INSTROOT}$(mailq_path)" "$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
183 echo "Warning: $${IPKG_INSTROOT}$(mailq_path) saved as $${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
185 if [ ! -f "$(mailq_path)" ]; then
186 ln -s "$${IPKG_INSTROOT}$(mailq_path)$(ln_suffix)" "$(mailq_path)"
189 grep -qc main\.cf "$${IPKG_INSTROOT}"/etc/sysupgrade.conf >/dev/null || echo "$(config_directory)/main.cf" >> "$${IPKG_INSTROOT}"/etc/sysupgrade.conf
190 grep -qc master\.cf "$${IPKG_INSTROOT}"/etc/sysupgrade.conf >/dev/null || echo "$(config_directory)/master.cf" >> "$${IPKG_INSTROOT}"/etc/sysupgrade.conf
191 grep -qc aliases "$${IPKG_INSTROOT}"/etc/sysupgrade.conf >/dev/null || echo "$(config_directory)/aliases" >> "$${IPKG_INSTROOT}"/etc/sysupgrade.conf
193 touch "$${IPKG_INSTROOT}$(config_directory)"/opkg_postinst
195 if [ -z "$${IPKG_INSTROOT}" ]; then
196 ps | grep "postfix/master" | grep -cvq grep >/dev/null && /etc/init.d/postfix reload
201 define Package/postfix/prerm
203 ps | grep "postfix/master" | grep -cvq grep >/dev/null && postfix stop
204 /etc/init.d/postfix disable
207 define Package/postfix/postrm
209 rm -f $${IPKG_INSTROOT}$(config_directory)/aliases.cdb $${IPKG_INSTROOT}$(config_directory)/aliases.db $${IPKG_INSTROOT}$(data_directory)/master.lock
211 rm -f "$${IPKG_INSTROOT}$(sendmail_path)" "$${IPKG_INSTROOT}$(newaliases_path)" "$${IPKG_INSTROOT}$(mailq_path)"
213 if [ -f "$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)" ]; then
214 mv "$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(sendmail_path)"
215 echo "Warning: $${IPKG_INSTROOT}$(sendmail_path) restored from $${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
217 if [ -f "$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)" ]; then
218 mv "$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(newaliases_path)"
219 echo "Warning: $${IPKG_INSTROOT}$(newaliases_path) restored from $${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
221 if [ -f "$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)" ]; then
222 mv "$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(mailq_path)"
223 echo "Warning: $${IPKG_INSTROOT}$(mailq_path) restored from $${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
227 $(eval $(call BuildPackage,postfix))