2 # Copyright (C) 2014-2015 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
:=3ec1416e7d4fba9566297c8fcf7a348c
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 -DNO_EAI
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
114 shlib_directory=/usr/lib/postfix
115 meta_directory=/etc/postfix
120 define Package/postfix/conffiles
121 $(config_directory)/main.cf
122 $(config_directory)/master.cf
123 $(config_directory)/aliases
126 define Build/Configure
127 if [ "$(CONFIG_POSTFIX_DB)" = "" -a "$(CONFIG_POSTFIX_CDB)" = "" ]; then\
128 echo "Build error: You must select at least one of the DB types";\
132 cd $(PKG_BUILD_DIR); $(MAKE) makefiles CCARGS='$(CCARGS
)' $(TARGET_CONFIGURE_OPTS) AUXLIBS="$(AUXLIBS)"
135 # Steps to regenerate files/main.cf.default:
137 # 1. Compile the package with current file
138 # 2. Execute the following command on target device:
139 # postconf -d > /tmp/main.cf.new
140 # 3. Transfer /tmp/main.cf.new file to the build system
141 # 4. Execute the following command:
142 # cat /tmp/main.cf.new | ( echo '# DO NOT EDIT THIS FILE. EDIT THE MAIN.CF FILE INSTEAD. THE'; echo '# TEXT HERE JUST SHOWS DEFAULT SETTINGS BUILT INTO POSTFIX.'; echo '#'; grep -v ^alias_maps\ = |grep -v ^alias_database\ = |grep -v ^command_directory\ = |grep -v ^config_directory\ = |grep -v ^daemon_directory\ = |grep -v ^data_directory\ = |grep -v ^default_database_type\ = |grep -v ^html_directory\ = |grep -v ^mail_spool_directory\ = |grep -v ^mailq_path\ = |grep -v ^manpage_directory\ = |grep -v ^meta_directory\ = |grep -v ^mydomain\ = |grep -v ^myhostname\ = |grep -v ^mynetworks\ = |grep -v ^mynetworks_style\ = |grep -v ^newaliases_path\ = |grep -v ^queue_directory\ = |grep -v ^readme_directory\ = |grep -v ^sample_directory\ = |grep -v ^sendmail_path\ = |grep -v ^shlib_directory\ = |grep -v ^smtputf8_enable\ = ) > files/main.cf.default
143 # 5. Done. Now you can rebuild the package with new main.cf.default.
147 # Currently postfix has a bug with Makefiles that CCARGS are not passed to the compiler, so we are copying them to CC
148 cd
$(PKG_BUILD_DIR
); $(MAKE
) $(TARGET_CONFIGURE_OPTS
) CC
='$(TARGET_CC) $(CCARGS)'
149 cp .
/files
/main.cf.default
$(PKG_BUILD_DIR
)/conf
/main.cf.default
150 echo
"default_database_type = $(default_database_type)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
151 echo
"alias_database = $(default_database_type):$(config_directory)/aliases" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
152 echo
"alias_maps = $(default_database_type):$(config_directory)/aliases" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
153 echo
"sendmail_path = $(sendmail_path)$(ln_suffix)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
154 echo
"newaliases_path = $(newaliases_path)$(ln_suffix)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
155 echo
"mailq_path = $(mailq_path)$(ln_suffix)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
156 echo
"html_directory = $(html_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
157 echo
"manpage_directory = $(manpage_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
158 echo
"sample_directory = $(sample_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
159 echo
"readme_directory = $(readme_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
160 echo
"command_directory = $(command_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
161 echo
"daemon_directory = $(daemon_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
162 echo
"data_directory = $(data_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
163 echo
"queue_directory = $(queue_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
164 echo
"config_directory = $(config_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
165 echo
"mail_spool_directory = $(mail_spool_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
166 echo
"shlib_directory = $(shlib_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
167 echo
"meta_directory = $(meta_directory)" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
168 echo
"smtputf8_enable = no" >> $(PKG_BUILD_DIR
)/conf
/main.cf.default
171 define Package
/postfix
/install
172 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
) shlib_directory
=$(shlib_directory
) meta_directory
=$(meta_directory
) mail_version
=$(PKG_VERSION
) non-interactive-package
173 $(INSTALL_DIR
) $(1)$(mail_spool_directory
)
174 $(INSTALL_DIR
) $(1)/etc
/init.d
/
175 $(INSTALL_BIN
) .
/files
/postfix.init
$(1)/etc
/init.d
/postfix
178 define Package
/postfix
/postinst
181 if
[ -f
"$${IPKG_INSTROOT}$(sendmail_path)" -a
"$$(readlink "$${IPKG_INSTROOT}$(sendmail_path
)")" != "$(sendmail_path)$(ln_suffix)" ]; then
182 mv
"$${IPKG_INSTROOT}$(sendmail_path)" "$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
183 echo
"Warning: $${IPKG_INSTROOT}$(sendmail_path) saved as $${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
185 if
[ ! -f
"$${IPKG_INSTROOT}$(sendmail_path)" ]; then
186 ln
-s
"$${IPKG_INSTROOT}$(sendmail_path)$(ln_suffix)" "$(sendmail_path)"
189 if
[ -f
"$${IPKG_INSTROOT}$(newaliases_path)" -a
"$$(readlink "$${IPKG_INSTROOT}$(newaliases_path
)")" != "$(newaliases_path)$(ln_suffix)" ]; then
190 mv
"$${IPKG_INSTROOT}$(newaliases_path)" "$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
191 echo
"Warning: $${IPKG_INSTROOT}$(newaliases_path) saved as $${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
193 if
[ ! -f
"$${IPKG_INSTROOT}$(newaliases_path)" ]; then
194 ln
-s
"$${IPKG_INSTROOT}$(newaliases_path)$(ln_suffix)" "$(newaliases_path)"
197 if
[ -f
"$${IPKG_INSTROOT}$(mailq_path)" -a
"$$(readlink "$${IPKG_INSTROOT}$(mailq_path
)")" != "$(mailq_path)$(ln_suffix)" ]; then
198 mv
"$${IPKG_INSTROOT}$(mailq_path)" "$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
199 echo
"Warning: $${IPKG_INSTROOT}$(mailq_path) saved as $${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
201 if
[ ! -f
"$(mailq_path)" ]; then
202 ln
-s
"$${IPKG_INSTROOT}$(mailq_path)$(ln_suffix)" "$(mailq_path)"
205 grep
-qc main\.cf
"$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
>/dev
/null || echo
"$(config_directory)/main.cf" >> "$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
206 grep
-qc master\.cf
"$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
>/dev
/null || echo
"$(config_directory)/master.cf" >> "$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
207 grep
-qc aliases
"$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
>/dev
/null || echo
"$(config_directory)/aliases" >> "$${IPKG_INSTROOT}"/etc
/sysupgrade.conf
209 touch
"$${IPKG_INSTROOT}$(config_directory)"/opkg_postinst
211 if
[ -z
"$${IPKG_INSTROOT}" ]; then
212 ps | grep
"postfix/master" | grep
-cvq grep
>/dev
/null
&& /etc
/init.d
/postfix reload
217 define Package
/postfix
/prerm
219 ps | grep
"postfix/master" | grep
-cvq grep
>/dev
/null
&& postfix stop
220 /etc
/init.d
/postfix disable
223 define Package
/postfix
/postrm
225 rm -f
$${IPKG_INSTROOT}$(config_directory
)/aliases.cdb
$${IPKG_INSTROOT}$(config_directory
)/aliases.db
$${IPKG_INSTROOT}$(data_directory
)/master.lock
227 rm -f
"$${IPKG_INSTROOT}$(sendmail_path)" "$${IPKG_INSTROOT}$(newaliases_path)" "$${IPKG_INSTROOT}$(mailq_path)"
229 if
[ -f
"$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)" ]; then
230 mv
"$${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(sendmail_path)"
231 echo
"Warning: $${IPKG_INSTROOT}$(sendmail_path) restored from $${IPKG_INSTROOT}$(sendmail_path)$(ln_old_suffix)"
233 if
[ -f
"$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)" ]; then
234 mv
"$${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(newaliases_path)"
235 echo
"Warning: $${IPKG_INSTROOT}$(newaliases_path) restored from $${IPKG_INSTROOT}$(newaliases_path)$(ln_old_suffix)"
237 if
[ -f
"$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)" ]; then
238 mv
"$${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)" "$${IPKG_INSTROOT}$(mailq_path)"
239 echo
"Warning: $${IPKG_INSTROOT}$(mailq_path) restored from $${IPKG_INSTROOT}$(mailq_path)$(ln_old_suffix)"
243 $(eval
$(call BuildPackage
,postfix
))