sendmail.spec 14 KB

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