postfix.spec 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 OpenPKG Project <http://openpkg.org/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package versions
  24. %define V_postfix 3.5.7
  25. %define V_pflogsumm 1.1.5
  26. %define V_whoson 2.4.0
  27. # package information
  28. Name: postfix
  29. Summary: Mail Transfer Agent (MTA)
  30. URL: http://www.postfix.org/
  31. Vendor: Wietse Venema
  32. Packager: OpenPKG Project
  33. Distribution: OpenPKG Community
  34. Class: BASE
  35. Group: Mail
  36. License: IPL
  37. Version: %{V_postfix}
  38. Release: 20200830
  39. # package options
  40. %option with_fsl yes
  41. %option with_ssl no
  42. %option with_sasl no
  43. %option with_sqlite no
  44. %option with_mysql no
  45. %option with_pgsql no
  46. %option with_ldap no
  47. %option with_whoson no
  48. %option with_fdsetsize no
  49. # list of sources
  50. Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
  51. Source1: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
  52. Source2: postfix.txt
  53. Source3: fsl.postfix
  54. Source4: rc.postfix
  55. Patch0: postfix.patch
  56. Patch1: postfix.patch.pfls
  57. Patch2: http://download.openpkg.org/components/versioned/postfix/postfix-%{V_whoson}-whoson.patch
  58. # build information
  59. BuildPreReq: OpenPKG, openpkg >= 20160101, perl, gcc
  60. PreReq: OpenPKG, openpkg >= 20160101, perl, procmail, perl-time
  61. BuildPreReq: make, pcre, db
  62. PreReq: make, pcre, db
  63. %if "%{with_fsl}" == "yes"
  64. BuildPreReq: fsl
  65. PreReq: fsl
  66. %endif
  67. %if "%{with_ssl}" == "yes"
  68. BuildPreReq: openssl
  69. PreReq: openssl
  70. %endif
  71. %if "%{with_sasl}" == "yes"
  72. BuildPreReq: sasl
  73. PreReq: sasl
  74. %endif
  75. %if "%{with_sqlite}" == "yes"
  76. BuildPreReq: sqlite
  77. PreReq: sqlite
  78. %endif
  79. %if "%{with_mysql}" == "yes"
  80. BuildPreReq: mysql
  81. PreReq: mysql
  82. %endif
  83. %if "%{with_pgsql}" == "yes"
  84. BuildPreReq: postgresql, openssl
  85. PreReq: postgresql, openssl
  86. %endif
  87. %if "%{with_ldap}" == "yes"
  88. BuildPreReq: openldap, openssl
  89. PreReq: openldap, openssl
  90. %endif
  91. %if "%{with_whoson}" == "yes"
  92. BuildPreReq: whoson
  93. PreReq: whoson
  94. %endif
  95. Provides: MTA
  96. Conflicts: exim, sendmail, ssmtp
  97. %description
  98. Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
  99. replace the Sendmail MTA. It is fully standards compliant and
  100. supports SMTP, ESMTP, LMTP over IPv4/IPv6 with optional TLS/SASL.
  101. Local specifics in this OpenPKG version:
  102. o Postfix delivers locally via Procmail
  103. o Postfix logs directly to the filesystem via OSSP fsl
  104. o Berkeley-DB dictionary support
  105. o PCRE matching support
  106. o Optional STARTTLS encryption support (see package options)
  107. o Optional SASL2 authentication support (see package options)
  108. o Optional SQLite dictionary support (see package options)
  109. o Optional MySQL dictionary support (see package options)
  110. o Optional PostgreSQL dictionary support (see package options)
  111. o Optional OpenLDAP dictionary support (see package options)
  112. o Optional WHOSON dictionary support (see package options)
  113. %track
  114. prog postfix = {
  115. version = %{V_postfix}
  116. url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
  117. regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz
  118. }
  119. prog postfix:pflogsumm = {
  120. version = %{V_pflogsumm}
  121. url = http://jimsun.linxnet.com/postfix_contrib.html
  122. regex = pflogsumm-(__VER__)\.tar\.gz
  123. }
  124. prog postfix:whoson = {
  125. version = %{V_whoson}
  126. url = http://download.openpkg.org/components/versioned/postfix/
  127. regex = postfix-(__VER__)-whoson.patch
  128. }
  129. %prep
  130. # unpack distribution files
  131. %setup -q
  132. %setup -q -T -D -a 1
  133. # apply OpenPKG patches
  134. %patch -p0
  135. ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 -b <%{PATCH1} ) || exit $?
  136. # apply vendor WHOSON patch
  137. %if "%{with_whoson}" == "yes"
  138. %patch -p0 -P 2
  139. %endif
  140. %build
  141. # configure Postfix (hard-core part I)
  142. %{l_shtool} subst \
  143. -e 's;/usr/include;%{l_prefix}/include;g' \
  144. makedefs
  145. # configure Postfix (regular part)
  146. unset LD_LIBRARY_PATH || true
  147. CCARGS=""
  148. CCARGS="$CCARGS %{l_cflags -O}"
  149. CCARGS="$CCARGS %{l_cppflags}"
  150. CCARGS="$CCARGS -DDEF_COMMAND_DIR=\\\"%{l_prefix}/sbin\\\""
  151. CCARGS="$CCARGS -DDEF_SENDMAIL_PATH=\\\"%{l_prefix}/sbin/sendmail\\\""
  152. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
  153. CCARGS="$CCARGS -DDEF_DAEMON_DIR=\\\"%{l_prefix}/libexec/postfix\\\""
  154. CCARGS="$CCARGS -DDEF_QUEUE_DIR=\\\"%{l_prefix}/var/postfix\\\""
  155. CCARGS="$CCARGS -DDEF_DATA_DIR=\\\"%{l_prefix}/var/postfix/data\\\""
  156. AUXLIBS=""
  157. AUXLIBS="$AUXLIBS %{l_ldflags}"
  158. CCARGS="$CCARGS -DHAS_DB"
  159. AUXLIBS="$AUXLIBS -ldb"
  160. CCARGS="$CCARGS -DHAS_PCRE"
  161. AUXLIBS="$AUXLIBS -lpcre"
  162. %if "%{with_sqlite}" == "yes"
  163. CCARGS="$CCARGS -DHAS_SQLITE"
  164. AUXLIBS="$AUXLIBS -lsqlite3"
  165. %endif
  166. %if "%{with_mysql}" == "yes"
  167. CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
  168. AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
  169. %endif
  170. %if "%{with_pgsql}" == "yes"
  171. CCARGS="$CCARGS -DHAS_PGSQL %{l_cppflags postgresql .}"
  172. AUXLIBS="$AUXLIBS -lpq -lssl -lcrypto -lcrypt"
  173. %endif
  174. %if "%{with_sasl}" == "yes"
  175. CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL %{l_cppflags sasl .}"
  176. AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
  177. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  178. AUXLIBS="$AUXLIBS -ldl"
  179. elif [ -f /usr/lib64/libdl.so -o -f /usr/lib64/libdl.a ]; then
  180. AUXLIBS="$AUXLIBS -ldl"
  181. elif [ -f /lib/x86_64-linux-gnu/libdl.so.2 -o -f /lib/x86_64-linux-gnu/libdl.a ]; then
  182. AUXLIBS="$AUXLIBS -ldl"
  183. fi
  184. %endif
  185. %if "%{with_ssl}" == "yes"
  186. CCARGS="$CCARGS -DUSE_TLS"
  187. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  188. %endif
  189. %if "%{with_ldap}" == "yes"
  190. CCARGS="$CCARGS -DHAS_LDAP"
  191. AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
  192. %endif
  193. %if "%{with_fsl}" == "yes"
  194. AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
  195. CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
  196. %endif
  197. %if "%{with_fdsetsize}" != "no"
  198. %if "%{with_fdsetsize}" == "yes"
  199. CCARGS="$CCARGS -DFD_SETSIZE=1024"
  200. %else
  201. CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
  202. %endif
  203. %endif
  204. case "%{l_platform -t}" in
  205. *-sunos* ) AUXLIBS="$AUXLIBS -lrt" ;;
  206. esac
  207. %{l_make} %{l_mflags} -f Makefile.init makefiles \
  208. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  209. # configure Postfix (hard-core part II)
  210. %{l_shtool} subst \
  211. -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
  212. -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
  213. src/util/sys_defs.h
  214. # build Postfix
  215. %{l_make} %{l_mflags}
  216. %install
  217. # perform standard installation procedure
  218. %{l_shtool} subst -e "s;chown;true;" postfix-install
  219. sh postfix-install -non-interactive \
  220. install_root=$RPM_BUILD_ROOT \
  221. config_directory=%{l_prefix}/etc/postfix \
  222. daemon_directory=%{l_prefix}/libexec/postfix \
  223. command_directory=%{l_prefix}/sbin \
  224. queue_directory=%{l_prefix}/var/postfix \
  225. data_directory=%{l_prefix}/var/postfix/data \
  226. sendmail_path=%{l_prefix}/sbin/sendmail \
  227. newaliases_path=%{l_prefix}/sbin/newaliases \
  228. mailq_path=%{l_prefix}/sbin/mailq \
  229. manpage_directory=%{l_prefix}/man \
  230. mail_user=%{l_musr} \
  231. setgid_group=%{l_rgrp}
  232. # post-adjust binaries
  233. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  234. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  235. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  236. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  237. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  238. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  239. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  240. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  241. # post-adjust configuration
  242. for cfg in \
  243. *LICENSE makedefs.out bounce.cf.default access aliases \
  244. canonical header_checks relocated transport virtual \
  245. main.cf main.cf.proto master.cf master.cf.proto main.cf.default; do
  246. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/$cfg
  247. done
  248. # install default configuration
  249. for name in `grep "^<file" %{SOURCE postfix.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
  250. (echo ""; cat %{SOURCE postfix.txt}; echo "") |\
  251. sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
  252. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  253. $name $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  254. done
  255. %{l_shtool} subst \
  256. %if "%{with_ssl}" == "yes"
  257. -e 's/^SSL://' \
  258. %else
  259. -e '/^SSL:/d' \
  260. %endif
  261. %if "%{with_sasl}" == "yes"
  262. -e 's/^SASL://' \
  263. %else
  264. -e '/^SASL:/d' \
  265. %endif
  266. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  267. # pre-create variable stuff
  268. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  269. %{l_shtool} mkdir -f -p -m 700 data
  270. %{l_shtool} mkdir -f -p -m 755 log
  271. ) || exit $?
  272. # install addons
  273. %{l_shtool} install -c -m 755 \
  274. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  275. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  276. %{l_shtool} install -c -m 755 \
  277. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  278. -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \
  279. auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape
  280. %{l_shtool} install -c -m 644 \
  281. man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8
  282. ( cd pflogsumm-%{V_pflogsumm}
  283. %{l_shtool} install -c -m 755 \
  284. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  285. pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  286. %{l_shtool} install -c -m 644 \
  287. pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  288. ) || exit $?
  289. # install run-command script
  290. %{l_shtool} mkdir -f -p -m 755 \
  291. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  292. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  293. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  294. # adjust installation to avoid file name conflicts
  295. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  296. mv master.8 postfix_master.8
  297. ) || exit $?
  298. # install OSSP fsl configuration
  299. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  300. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  301. %{SOURCE fsl.postfix} \
  302. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  303. # generate file list
  304. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  305. %{l_files_std} \
  306. '%config %{l_prefix}/etc/fsl/fsl.postfix' \
  307. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
  308. '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  309. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  310. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  311. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  312. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
  313. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix/pid' \
  314. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  315. %files -f files
  316. %clean
  317. %pre
  318. # before upgrade, save status and stop service
  319. [ $1 -eq 2 ] || exit 0
  320. eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
  321. %{l_rc} postfix stop 2>/dev/null
  322. exit 0
  323. %post
  324. if [ $1 -eq 1 ]; then
  325. # after install, generate configuration
  326. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
  327. fi
  328. if [ $1 -eq 2 ]; then
  329. # after upgrade, regenerate configuration
  330. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
  331. # after upgrade, restore status
  332. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
  333. [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
  334. fi
  335. exit 0
  336. %preun
  337. # before erase, stop service and remove log files
  338. [ $1 -eq 0 ] || exit 0
  339. %{l_rc} postfix stop 2>/dev/null
  340. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
  341. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.sum* >/dev/null 2>&1 || true
  342. # remove generated configuration files
  343. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean >/dev/null 2>&1; true ) || true
  344. # remove generated run-time files and directories
  345. rm -rf $RPM_INSTALL_PREFIX/var/postfix/data/*
  346. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  347. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  348. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  349. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  350. xargs rmdir >/dev/null 2>&1 || true
  351. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  352. xargs rmdir >/dev/null 2>&1 || true
  353. exit 0