sendmail.spec 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. ##
  2. ## sendmail.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 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 options
  26. %ifndef with_tls
  27. %define with_tls no
  28. %endif
  29. %ifndef with_sasl
  30. %define with_sasl no
  31. %endif
  32. %ifndef with_milter
  33. %define with_milter no
  34. %endif
  35. %ifndef with_ldap
  36. %define with_ldap no
  37. %endif
  38. # package information
  39. Name: sendmail
  40. Summary: Mail Transfer Agent
  41. URL: http://www.sendmail.org/
  42. Vendor: Eric Allman
  43. Packager: The OpenPKG Project
  44. Distribution: OpenPKG [EVAL]
  45. Group: Mail
  46. License: BSD
  47. Version: 8.12.7
  48. Release: 20021230
  49. # list of sources
  50. Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{version}.tar.gz
  51. Source1: etc.sendmail.tar
  52. Source2: cf.tar
  53. Source3: fsl.sendmail
  54. Source4: rc.sendmail
  55. # build information
  56. Prefix: %{l_prefix}
  57. BuildRoot: %{l_buildroot}
  58. BuildPreReq: OpenPKG, openpkg, m4, fsl, tar, gcc, make, db >= 4.1.25
  59. PreReq: OpenPKG, openpkg, m4, fsl, make, perl
  60. %if "%{with_tls}" == "yes"
  61. BuildPreReq: openssl
  62. %endif
  63. %if "%{with_sasl}" == "yes"
  64. BuildPreReq: sasl, openssl
  65. %endif
  66. %if "%{with_ldap}" == "yes"
  67. BuildPreReq: openldap, openssl
  68. %endif
  69. AutoReq: no
  70. AutoReqProv: no
  71. Provides: MTA
  72. Conflicts: ssmtp, exim, postfix
  73. %description
  74. Sendmail is the most popular Mail Transfer Agent (MTA). This copy
  75. contains features specific to the OpenPKG distribution including
  76. fsl(3) logging rather than syslog(3) and optional STARTTLS,
  77. SMTPAUTH, Milter and LDAP support.
  78. Options:
  79. --define 'with_tls %{with_tls}'
  80. --define 'with_sasl %{with_sasl}'
  81. --define 'with_milter %{with_milter}'
  82. --define 'with_ldap %{with_ldap}'
  83. %prep
  84. # unpack standard tarballs
  85. %setup0 -q -c
  86. %setup1 -q -T -D -a 1
  87. # add own M4 stuff to Sendmail configuration set
  88. ( cd sendmail-%{version}
  89. %{l_tar} xf %{SOURCE cf.tar}
  90. )
  91. %build
  92. # build Sendmail
  93. ( cd sendmail-%{version}
  94. # indicate with a plus sign that we use a patched version
  95. chmod u+w sendmail/version.c
  96. %{l_shtool} subst \
  97. -e 's;\(Version\[\][^"]*\)"[^"]*";\1"%{version}+";' \
  98. sendmail/version.c
  99. # add linker flag defs for fsl(3)
  100. LDFLAGS="`%{l_prefix}/bin/fsl-config --ldflags --all`" \
  101. LIBS="`%{l_prefix}/bin/fsl-config --libs --all`" \
  102. # configure Sendmail
  103. ( echo "define(\`confMAPDEF', \`-DMAP_REGEX')dnl"
  104. echo "define(\`confSBINOWN', \`%{l_musr}')dnl"
  105. echo "define(\`confSBINGRP', \`%{l_mgrp}')dnl"
  106. echo "define(\`confUBINOWN', \`%{l_musr}')dnl"
  107. echo "define(\`confUBINGRP', \`%{l_mgrp}')dnl"
  108. echo "define(\`confMANOWN', \`%{l_musr}')dnl"
  109. echo "define(\`confMANGRP', \`%{l_mgrp}')dnl"
  110. echo "define(\`confEBINDIR', \`%{l_prefix}/libexec/sendmail')dnl"
  111. echo "define(\`confHFDIR', \`%{l_prefix}/etc/sendmail')dnl"
  112. echo "define(\`confHFFILE', \`sendmail.help')dnl"
  113. echo "define(\`confINCLUDEDIR', \`%{l_prefix}/include/sendmail')dnl"
  114. echo "define(\`confINSTALL_RAWMAN', \`1')dnl"
  115. echo "define(\`confLIBDIR', \`%{l_prefix}/lib/sendmail')dnl"
  116. echo "define(\`confMANROOT', \`%{l_prefix}/man/cat')dnl"
  117. echo "define(\`confMANROOTMAN', \`%{l_prefix}/man/man')dnl"
  118. echo "define(\`confMBINDIR', \`%{l_prefix}/sbin')dnl"
  119. echo "define(\`confSBINDIR', \`%{l_prefix}/sbin')dnl"
  120. echo "define(\`confSHAREDLIBDIR', \`%{l_prefix}/lib')dnl"
  121. echo "define(\`confSTDIR', \`%{l_prefix}/var/sendmail')dnl"
  122. echo "define(\`confSTFILE', \`sendmail.stat')dnl"
  123. echo "define(\`confUBINDIR', \`%{l_prefix}/bin')dnl"
  124. echo "define(\`confLNOPTS', \`-f')dnl"
  125. echo "define(\`confFORCE_RMAIL', \`yes')dnl"
  126. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILCF=\\\"%{l_prefix}/etc/sendmail/sendmail.cf\\\"')dnl"
  127. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILPID=\\\"%{l_prefix}/var/sendmail/sendmail.pid\\\"')dnl"
  128. echo "APPENDDEF(\`confENVDEF', \`-DNEWDB')dnl"
  129. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include')dnl"
  130. echo "APPENDDEF(\`confLIBDIRS', \`-L%{l_prefix}/lib')dnl"
  131. echo "APPENDDEF(\`confLIBS', \`-lfsl -ldb')dnl"
  132. echo "define(\`confSTDIO_TYPE', \`portable')dnl"
  133. echo "APPENDDEF(\`confENVDEF', \`-DDNSMAP')dnl"
  134. %if "%{with_tls}" == "yes"
  135. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSTARTTLS')dnl"
  136. echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lssl -lcrypto')dnl"
  137. %endif
  138. %if "%{with_sasl}" == "yes"
  139. echo "APPENDDEF(\`confENVDEF', \`-DSASL=1')dnl"
  140. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include/sasl')dnl"
  141. echo "APPENDDEF(\`confLIBS', \`-lsasl2 -lcrypto')dnl"
  142. %endif
  143. %if "%{with_milter}" == "yes"
  144. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DMILTER')dnl"
  145. echo "APPENDDEF(\`conf_libmilter_ENVDEF', \`-D_FFR_MILTER_ROOT_UNSAFE')dnl"
  146. %endif
  147. %if "%{with_ldap}" == "yes"
  148. echo "APPENDDEF(\`confMAPDEF', \`-DLDAPMAP')dnl"
  149. echo "APPENDDEF(\`confENVDEF', \`-DSM_CONF_LDAP_MEMFREE=1')dnl"
  150. echo "APPENDDEF(\`confLIBS', \`-lldap -llber -lssl -lcrypto')dnl"
  151. %endif
  152. ) >devtools/Site/site.config.m4
  153. # build Sendmail package
  154. %{l_make} %{l_mflags}
  155. )
  156. %install
  157. rm -rf $RPM_BUILD_ROOT
  158. # manually create filesystem hierarchy, because Sendmail's
  159. # install target doesn't properly create it itself.
  160. %{l_shtool} mkdir -f -p -m 755 \
  161. $RPM_BUILD_ROOT%{l_prefix} \
  162. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail \
  163. $RPM_BUILD_ROOT%{l_prefix}/bin \
  164. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  165. $RPM_BUILD_ROOT%{l_prefix}/lib \
  166. $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail \
  167. $RPM_BUILD_ROOT%{l_prefix}/man \
  168. $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
  169. $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
  170. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  171. $RPM_BUILD_ROOT%{l_prefix}/man/cat1 \
  172. $RPM_BUILD_ROOT%{l_prefix}/man/cat5 \
  173. $RPM_BUILD_ROOT%{l_prefix}/man/cat8
  174. # install Sendmail
  175. ( cd sendmail-%{version}
  176. myusr=`(id -un) 2>/dev/null ||\
  177. (whoami) 2>/dev/null ||\
  178. (who am i | cut "-d " -f1) 2>/dev/null ||\
  179. echo $LOGNAME`
  180. mygrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  181. grep "^${myusr}:" | awk -F: '{ print $4; }' | head -1`
  182. mygrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
  183. grep ":${mygrp}:" | awk -F: '{ print $1; }' | head -1`
  184. %{l_shtool} subst \
  185. -e "s;^\\(SBINOWN.*=\\).*;\\1 $myusr;" \
  186. -e "s;^\\(SBINGRP.*=\\).*;\\1 $mygrp;" \
  187. -e "s;^\\(UBINOWN.*=\\).*;\\1 $myusr;" \
  188. -e "s;^\\(UBINGRP.*=\\).*;\\1 $mygrp;" \
  189. -e "s;^\\(GBINOWN.*=\\).*;\\1 $myusr;" \
  190. -e "s;^\\(GBINGRP.*=\\).*;\\1 $mygrp;" \
  191. -e "s;^\\(MANOWN.*=\\).*;\\1 $myusr;" \
  192. -e "s;^\\(MANGRP.*=\\).*;\\1 $mygrp;" \
  193. -e "s;^\\(CFOWN.*=\\).*;\\1 $myusr;" \
  194. -e "s;^\\(CFGRP.*=\\).*;\\1 $mygrp;" \
  195. -e "s;^\\(MBINOWN.*=\\).*;\\1 $myusr;" \
  196. -e "s;^\\(MBINGRP.*=\\).*;\\1 $mygrp;" \
  197. -e "s;^\\(MSPQOWN.*=\\).*;\\1 $myusr;" \
  198. -e "s;^\\(MSPQGRP.*=\\).*;\\1 $mygrp;" \
  199. -e "s;^\\(LIBOWN.*=\\).*;\\1 $myusr;" \
  200. -e "s;^\\(LIBGRP.*=\\).*;\\1 $mygrp;" \
  201. -e "s;^\\(INCOWN.*=\\).*;\\1 $myusr;" \
  202. -e "s;^\\(INCGRP.*=\\).*;\\1 $mygrp;" \
  203. -e 's;ln -s *;$(LN) $(LNOPTS) $(DESTDIR);' \
  204. Makefile */Makefile */*/Makefile
  205. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT \
  206. MSPQ=%{l_prefix}$MSPQ MAILDIR=%{l_prefix}
  207. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rmail \
  208. $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  209. # install OSSP fsl support
  210. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  211. %{l_shtool} install -c -m 644 \
  212. -e 's;@l_prefix@;%{l_prefix};g' \
  213. %{SOURCE fsl.sendmail} \
  214. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  215. # remember the Sendmail M4 stuff for re-configuration
  216. (%{l_tar} cf $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar cf)
  217. compress $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar
  218. %{l_shtool} install -c -m 644 cf/README \
  219. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.README
  220. %{l_shtool} install -c -m 755 contrib/re-mqueue.pl \
  221. $RPM_BUILD_ROOT%{l_prefix}/sbin/re-mqueue
  222. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  223. contrib/qtool.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qtool
  224. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  225. contrib/qtool.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qtool.8
  226. )
  227. # install a reasonable default configuration
  228. ( cd etc.sendmail
  229. l_hostname=`%{l_shtool} echo -e %h`
  230. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  231. l_ostype=bsd4.4
  232. case "%{l_target}" in
  233. *-freebsd4*) l_ostype=freebsd4 ;;
  234. *-freebsd*) l_ostype=bsd4.4 ;;
  235. *-solaris2.8) l_ostype=solaris8 ;;
  236. *-solaris*) l_ostype=solaris2 ;;
  237. *-linux*) l_ostype=linux ;;
  238. esac
  239. %{l_shtool} install -c -m 644 \
  240. -e 's;@l_prefix@;%{l_prefix};g' \
  241. -e 's;@l_musr@;%{l_musr};g' \
  242. -e 's;@l_mgrp@;%{l_mgrp};g' \
  243. -e "s;@l_hostname@;${l_hostname};g" \
  244. -e "s;@l_domainname@;${l_domainname};g" \
  245. -e "s;@l_ostype@;${l_ostype};g" \
  246. * $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/
  247. )
  248. # install the run-command script
  249. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  250. %{l_shtool} install -c -m 755 \
  251. -e 's;@l_prefix@;%{l_prefix};g' \
  252. -e 's;@l_musr@;%{l_musr};g' \
  253. -e 's;@l_mgrp@;%{l_mgrp};g' \
  254. %{SOURCE rc.sendmail} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  255. # create important files which have to be present from the beginning
  256. %{l_shtool} mkdir -f -p -m 700 \
  257. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue \
  258. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue/.hoststat
  259. %{l_shtool} mkdir -f -p -m 770 \
  260. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue \
  261. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue/.hoststat
  262. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.in.pid
  263. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.out.pid
  264. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.log
  265. # adjust installation tree
  266. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/cat*
  267. chmod -R u+w $RPM_BUILD_ROOT%{l_prefix}/
  268. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  269. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2> /dev/null || true
  270. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail/* 2> /dev/null || true
  271. # determine file list
  272. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  273. %{l_files_std} \
  274. '%attr(2755,root,%{l_rgrp}) %{l_prefix}/sbin/sendmail' \
  275. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/hoststat' \
  276. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/mailq' \
  277. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/newaliases' \
  278. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/purgestat' \
  279. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/vacation' \
  280. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/libexec/sendmail/smrsh' \
  281. '%attr(755,root,%{l_mgrp}) %{l_prefix}/etc/sendmail' \
  282. '%config %{l_prefix}/etc/sendmail/*' \
  283. '%config %attr(644,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/ca.crt' \
  284. '%config %attr(644,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.crt' \
  285. '%config %attr(600,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.key' \
  286. '%config %{l_prefix}/etc/fsl/fsl.sendmail' \
  287. '%not %dir %{l_prefix}/etc/fsl' \
  288. '%attr(700,root,%{l_mgrp}) %{l_prefix}/var/sendmail/mqueue' \
  289. '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/sendmail/clientmqueue' \
  290. '%attr(644,root,%{l_mgrp}) %{l_prefix}/var/sendmail/sendmail.log' \
  291. '%attr(644,root,%{l_mgrp}) %{l_prefix}/var/sendmail/sendmail.*.pid'
  292. %files -f files
  293. %clean
  294. rm -rf $RPM_BUILD_ROOT
  295. %post
  296. if [ $1 -eq 1 ]; then
  297. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} all >/dev/null 2>&1 || true)
  298. elif [ $1 -gt 1 ]; then
  299. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} clean all >/dev/null 2>&1 || true)
  300. $RPM_INSTALL_PREFIX/etc/rc sendmail reload >/dev/null 2>&1 || true
  301. fi
  302. %preun
  303. if [ $1 -eq 0 ]; then
  304. $RPM_INSTALL_PREFIX/etc/rc sendmail stop >/dev/null 2>&1 || true
  305. (cd $RPM_INSTALL_PREFIX/etc/sendmail/; %{l_make} clean >/dev/null 2>&1 || true)
  306. fi