sendmail.spec 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. ##
  2. ## sendmail.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package information
  26. Name: sendmail
  27. Summary: Mail Transfer Agent
  28. URL: http://www.sendmail.org/
  29. Vendor: Eric Allman
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG [PLUS]
  32. Group: Mail
  33. License: BSD
  34. Version: 8.12.9
  35. Release: 20030605
  36. # package options
  37. %option with_tls no
  38. %option with_sasl no
  39. %option with_milter no
  40. %option with_ldap no
  41. %option with_mysql no
  42. # list of sources
  43. Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{version}.tar.gz
  44. Source1: etc.sendmail.tar
  45. Source2: cf.tar
  46. Source3: fsl.sendmail
  47. Source4: rc.sendmail
  48. Patch0: sendmail-8.12.0-mysqlmap.patch
  49. # build information
  50. Prefix: %{l_prefix}
  51. BuildRoot: %{l_buildroot}
  52. BuildPreReq: OpenPKG, openpkg >= 20030516, m4, fsl, gcc, make, db >= 4.1.25
  53. PreReq: OpenPKG, openpkg >= 20030516, m4, fsl, make, perl, procmail
  54. %if "%{with_tls}" == "yes"
  55. BuildPreReq: openssl
  56. %endif
  57. %if "%{with_sasl}" == "yes"
  58. BuildPreReq: sasl, openssl
  59. %endif
  60. %if "%{with_ldap}" == "yes"
  61. BuildPreReq: openldap, openssl
  62. %endif
  63. %if "%{with_mysql}" == "yes"
  64. BuildPreReq: MYSQL
  65. %endif
  66. AutoReq: no
  67. AutoReqProv: no
  68. Provides: MTA
  69. Conflicts: ssmtp, exim, postfix
  70. %description
  71. Sendmail is the most popular Mail Transfer Agent (MTA). This copy
  72. contains features specific to the OpenPKG distribution including
  73. fsl(3) logging rather than syslog(3) and optional STARTTLS,
  74. SMTPAUTH, Milter and LDAP support.
  75. %prep
  76. # unpack standard tarballs
  77. %setup0 -q -c
  78. %setup1 -q -T -D -a 1
  79. %if "%{with_mysql}" == "yes"
  80. ( cd sendmail-%{version}
  81. %{l_patch} -p1 <%{SOURCE sendmail-8.12.0-mysqlmap.patch}
  82. )
  83. %endif
  84. # make install process unprivileged
  85. ( cd sendmail-%{version}
  86. %{l_shtool} subst \
  87. -e 's;ln -s *;$(LN) $(LNOPTS) $(DESTDIR);' \
  88. -e 's;chown;true;g' \
  89. -e 's;chgrp;true;g' \
  90. Makefile */Makefile */Makefile.m4 */*/Makefile
  91. %{l_shtool} subst \
  92. -e 's;\$chown;true;g' \
  93. -e 's;chgrp;true;g' \
  94. devtools/bin/install.sh
  95. )
  96. # add own M4 stuff to Sendmail configuration set
  97. ( cd sendmail-%{version}
  98. %{l_tar} xf %{SOURCE cf.tar}
  99. )
  100. # override platform-specific definitions
  101. ( cd sendmail-%{version}
  102. %{l_shtool} subst \
  103. -e 's;\(define *SMRSH_CMDDIR *\).*;\1 "%{l_prefix}/var/sendmail/sm.bin";g' \
  104. -e 's;\(define *_PATH_SENDMAIL *\).*;\1 "%{l_prefix}/sbin/sendmail";g' \
  105. -e 's;\(include *<paths.h>.*\);\1\n#ifdef _PATH_SENDMAIL\n#undef _PATH_SENDMAIL\n#endif;g' \
  106. include/sendmail/pathnames.h include/sm/conf.h
  107. )
  108. %build
  109. # build Sendmail
  110. ( cd sendmail-%{version}
  111. # indicate with a plus sign that we use a patched version
  112. %{l_shtool} subst \
  113. -e 's;\(Version\[\][^"]*\)"[^"]*";\1"%{version}+";' \
  114. sendmail/version.c
  115. # configure Sendmail
  116. ( echo "define(\`confMAPDEF', \`-DMAP_REGEX')dnl"
  117. echo "define(\`confSBINOWN', \`%{l_musr}')dnl"
  118. echo "define(\`confSBINGRP', \`%{l_mgrp}')dnl"
  119. echo "define(\`confUBINOWN', \`%{l_musr}')dnl"
  120. echo "define(\`confUBINGRP', \`%{l_mgrp}')dnl"
  121. echo "define(\`confMANOWN', \`%{l_musr}')dnl"
  122. echo "define(\`confMANGRP', \`%{l_mgrp}')dnl"
  123. echo "define(\`confEBINDIR', \`%{l_prefix}/libexec/sendmail')dnl"
  124. echo "define(\`confHFDIR', \`%{l_prefix}/etc/sendmail')dnl"
  125. echo "define(\`confHFFILE', \`sendmail.help')dnl"
  126. echo "define(\`confINCLUDEDIR', \`%{l_prefix}/include/sendmail')dnl"
  127. echo "define(\`confINSTALL_RAWMAN', \`1')dnl"
  128. echo "define(\`confLIBDIR', \`%{l_prefix}/lib/sendmail')dnl"
  129. echo "define(\`confMANROOT', \`%{l_prefix}/man/cat')dnl"
  130. echo "define(\`confMANROOTMAN', \`%{l_prefix}/man/man')dnl"
  131. echo "define(\`confMBINDIR', \`%{l_prefix}/sbin')dnl"
  132. echo "define(\`confSBINDIR', \`%{l_prefix}/sbin')dnl"
  133. echo "define(\`confSHAREDLIBDIR', \`%{l_prefix}/lib')dnl"
  134. echo "define(\`confSTDIR', \`%{l_prefix}/var/sendmail')dnl"
  135. echo "define(\`confSTFILE', \`sendmail.stat')dnl"
  136. echo "define(\`confUBINDIR', \`%{l_prefix}/bin')dnl"
  137. echo "define(\`confLNOPTS', \`-f')dnl"
  138. echo "define(\`confFORCE_RMAIL', \`yes')dnl"
  139. echo "APPENDDEF(\`confMSP_QUEUE_DIR',\`%{l_prefix}/var/sendmail/clientmqueue')dnl"
  140. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILCF=\\\"%{l_prefix}/etc/sendmail/sendmail.cf\\\"')dnl"
  141. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILPID=\\\"%{l_prefix}/var/sendmail/sendmail.pid\\\"')dnl"
  142. echo "APPENDDEF(\`confENVDEF', \`-D_DIR_SENDMAILCF=\\\"%{l_prefix}/etc/sendmail/\\\"')dnl"
  143. echo "APPENDDEF(\`confENVDEF', \`-DNEWDB')dnl"
  144. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include')dnl"
  145. echo "APPENDDEF(\`confLIBDIRS', \`-L%{l_prefix}/lib')dnl"
  146. echo "APPENDDEF(\`confLIBS', \`-lfsl -ldb')dnl"
  147. echo "define(\`confSTDIO_TYPE', \`portable')dnl"
  148. echo "APPENDDEF(\`confENVDEF', \`-DDNSMAP')dnl"
  149. %if "%{with_tls}" == "yes"
  150. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSTARTTLS')dnl"
  151. echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lssl -lcrypto')dnl"
  152. %endif
  153. %if "%{with_sasl}" == "yes"
  154. echo "APPENDDEF(\`confENVDEF', \`-DSASL=1')dnl"
  155. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include/sasl')dnl"
  156. echo "APPENDDEF(\`confLIBS', \`-lsasl2 -lcrypto')dnl"
  157. %endif
  158. %if "%{with_milter}" == "yes"
  159. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DMILTER')dnl"
  160. echo "APPENDDEF(\`conf_libmilter_ENVDEF', \`-D_FFR_MILTER_ROOT_UNSAFE')dnl"
  161. %endif
  162. %if "%{with_ldap}" == "yes"
  163. echo "APPENDDEF(\`confMAPDEF', \`-DLDAPMAP')dnl"
  164. echo "APPENDDEF(\`confENVDEF', \`-DSM_CONF_LDAP_MEMFREE=1')dnl"
  165. echo "APPENDDEF(\`confLIBS', \`-lldap -llber -lssl -lcrypto')dnl"
  166. %endif
  167. %if "%{with_mysql}" == "yes"
  168. echo "APPENDDEF(\`confMAPDEF',\`-DMYSQLMAP')dnl"
  169. echo "APPENDDEF(\`confINCDIRS',\`-I%{l_prefix}/include/mysql')dnl"
  170. echo "APPENDDEF(\`confLIBS',\`-L%{l_prefix}/lib/mysql -lmysqlclient -lz -lm')dnl"
  171. %endif
  172. ) >devtools/Site/site.config.m4
  173. # build Sendmail package
  174. %{l_make} %{l_mflags}
  175. %if "%{with_milter}" == "yes"
  176. # have to separately invoke "Build" script in libmilter dir
  177. ( cd libmilter
  178. ./Build
  179. ) || exit $?
  180. %endif
  181. ) || exit $?
  182. %install
  183. rm -rf $RPM_BUILD_ROOT
  184. # manually create filesystem hierarchy, because Sendmail's
  185. # install target doesn't properly create it itself.
  186. %{l_shtool} mkdir -f -p -m 755 \
  187. $RPM_BUILD_ROOT%{l_prefix} \
  188. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail \
  189. $RPM_BUILD_ROOT%{l_prefix}/bin \
  190. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  191. $RPM_BUILD_ROOT%{l_prefix}/lib \
  192. $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail \
  193. $RPM_BUILD_ROOT%{l_prefix}/man \
  194. $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
  195. $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
  196. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  197. $RPM_BUILD_ROOT%{l_prefix}/man/cat1 \
  198. $RPM_BUILD_ROOT%{l_prefix}/man/cat5 \
  199. $RPM_BUILD_ROOT%{l_prefix}/man/cat8
  200. # install Sendmail
  201. ( cd sendmail-%{version}
  202. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT \
  203. INSTALL=`pwd`/devtools/bin/install.sh \
  204. MAILDIR=%{l_prefix}/etc/sendmail
  205. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rmail \
  206. $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  207. %if "%{with_milter}" == "yes"
  208. # install libraries and includes for building milters
  209. %{l_shtool} mkdir -f -p -m 755 \
  210. $RPM_BUILD_ROOT%{l_prefix}/include/libmilter
  211. %{l_shtool} install -c -m 644 \
  212. include/libmilter/*.h \
  213. $RPM_BUILD_ROOT%{l_prefix}/include/libmilter/
  214. %{l_shtool} install -c -m 644 \
  215. obj.*/libsm/libsm.a \
  216. obj.*/libsmutil/libsmutil.a \
  217. obj.*/libsmdb/libsmdb.a \
  218. obj.*/libmilter/libmilter.a \
  219. $RPM_BUILD_ROOT%{l_prefix}/lib/
  220. %endif
  221. # install OSSP fsl support
  222. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  223. %{l_shtool} install -c -m 644 \
  224. -e 's;@l_prefix@;%{l_prefix};g' \
  225. %{SOURCE fsl.sendmail} \
  226. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  227. # remember the Sendmail M4 stuff for re-configuration
  228. (%{l_tar} cf $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar cf)
  229. compress $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar
  230. %{l_shtool} install -c -m 644 cf/README \
  231. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.README
  232. %{l_shtool} install -c -m 755 contrib/re-mqueue.pl \
  233. $RPM_BUILD_ROOT%{l_prefix}/sbin/re-mqueue
  234. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  235. contrib/qtool.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qtool
  236. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  237. contrib/qtool.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qtool.8
  238. ) || exit $?
  239. # install a reasonable default configuration
  240. ( cd etc.sendmail
  241. l_hostname=`%{l_shtool} echo -e %h`
  242. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  243. l_ostype=bsd4.4
  244. case "%{l_target}" in
  245. *-freebsd4*) l_ostype=freebsd4 ;;
  246. *-freebsd*) l_ostype=bsd4.4 ;;
  247. *-solaris2.8) l_ostype=solaris8 ;;
  248. *-solaris*) l_ostype=solaris2 ;;
  249. *-linux*) l_ostype=linux ;;
  250. esac
  251. %{l_shtool} install -c -m 644 \
  252. -e 's;@l_prefix@;%{l_prefix};g' \
  253. -e 's;@l_musr@;%{l_musr};g' \
  254. -e 's;@l_mgrp@;%{l_mgrp};g' \
  255. -e 's;@l_rusr@;%{l_rusr};g' \
  256. -e 's;@l_rgrp@;%{l_rgrp};g' \
  257. -e "s;@l_hostname@;${l_hostname};g" \
  258. -e "s;@l_domainname@;${l_domainname};g" \
  259. -e "s;@l_ostype@;${l_ostype};g" \
  260. * $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/
  261. ) || exit $?
  262. # install the run-command script
  263. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  264. %{l_shtool} install -c -m 755 \
  265. -e 's;@l_prefix@;%{l_prefix};g' \
  266. -e 's;@l_susr@;%{l_susr};g' \
  267. -e 's;@l_musr@;%{l_musr};g' \
  268. -e 's;@l_mgrp@;%{l_mgrp};g' \
  269. %{SOURCE rc.sendmail} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  270. # create important files which have to be present from the beginning
  271. %{l_shtool} mkdir -f -p -m 755 \
  272. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sm.bin \
  273. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue \
  274. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue/.hoststat
  275. %{l_shtool} mkdir -f -p -m 755 \
  276. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue \
  277. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue/.hoststat
  278. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.log
  279. # adjust installation tree
  280. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/cat*
  281. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/submit.cf
  282. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  283. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
  284. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail/* 2>/dev/null || true
  285. # determine file list
  286. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  287. %{l_files_std} \
  288. '%attr(2755,%{l_susr},%{l_rgrp}) %{l_prefix}/sbin/sendmail' \
  289. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/hoststat' \
  290. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/mailq' \
  291. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/newaliases' \
  292. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/purgestat' \
  293. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/vacation' \
  294. '%attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/sendmail/smrsh' \
  295. '%attr(755,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/sendmail' \
  296. '%config %{l_prefix}/etc/sendmail/*' \
  297. '%config %attr(644,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/sendmail/ca.crt' \
  298. '%config %attr(644,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.crt' \
  299. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.key' \
  300. '%config %{l_prefix}/etc/fsl/fsl.sendmail' \
  301. '%not %dir %{l_prefix}/etc/fsl' \
  302. '%attr(700,%{l_susr},%{l_mgrp}) %{l_prefix}/var/sendmail/mqueue' \
  303. '%attr(700,%{l_susr},%{l_mgrp}) %{l_prefix}/var/sendmail/mqueue/.hoststat' \
  304. '%attr(770,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/sendmail/clientmqueue' \
  305. '%attr(750,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/sendmail/clientmqueue/.hoststat' \
  306. '%attr(644,%{l_susr},%{l_mgrp}) %{l_prefix}/var/sendmail/sendmail.log'
  307. %files -f files
  308. %clean
  309. rm -rf $RPM_BUILD_ROOT
  310. %post
  311. if [ $1 -eq 1 ]; then
  312. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} all >/dev/null 2>&1 || true)
  313. elif [ $1 -gt 1 ]; then
  314. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} clean all >/dev/null 2>&1 || true)
  315. $RPM_INSTALL_PREFIX/etc/rc sendmail reload >/dev/null 2>&1 || true
  316. fi
  317. %preun
  318. if [ $1 -eq 0 ]; then
  319. $RPM_INSTALL_PREFIX/etc/rc sendmail stop >/dev/null 2>&1 || true
  320. ( cd $RPM_INSTALL_PREFIX/etc/sendmail/;
  321. %{l_make} distclean >/dev/null 2>&1 || true
  322. )
  323. d=$RPM_INSTALL_PREFIX/var/sendmail/mqueue/.hoststat/*
  324. if [ ."$d" != . ]; then
  325. rm -rf $d
  326. fi
  327. d=$RPM_INSTALL_PREFIX/var/sendmail/clientmqueue/.hoststat/*
  328. if [ ."$d" != . ]; then
  329. rm -rf $d
  330. fi
  331. fi