sendmail.spec 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. # TODO:
  26. # 1 User, group ids in %files must be reviewed
  27. # 2 default config files use 8.11.6 options
  28. # build options
  29. %{!?with_tls: %define with_tls yes}
  30. %{!?with_sasl: %define with_sasl no}
  31. %{!?with_milter: %define with_milter no}
  32. %{!?with_ldap: %define with_ldap no}
  33. # package information
  34. Name: sendmail
  35. Summary: Mail Transfer Agent
  36. URL: http://www.sendmail.org/
  37. Vendor: Eric Allman
  38. Packager: The OpenPKG Project
  39. Distribution: OpenPKG [EVAL]
  40. Group: Mail
  41. License: BSD
  42. Version: 8.12.6
  43. Release: 20021211
  44. # list of sources
  45. Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{version}.tar.gz
  46. Source1: etc.sendmail.tar
  47. Source2: cf.tar
  48. Source3: fsl.sendmail
  49. Source4: rc.sendmail
  50. Patch0: http://www.sendmail.org/patches/smrsh-20020924.patch
  51. Patch1: http://www.sendmail.org/patches/proto.m4.8.649.2.13
  52. Patch2: http://www.sendmail.org/~ca/email/patches/recipient.c.8.330.2.1
  53. Patch3: http://www.sendmail.org/~ca/email/patches/proto.m4.8.646
  54. Patch4: sendmail-db4.patch
  55. # build information
  56. Prefix: %{l_prefix}
  57. BuildRoot: %{l_buildroot}
  58. BuildPreReq: OpenPKG, openpkg, m4, fsl, tar, gcc, make, db
  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 contains
  75. features specific to the OpenPKG distribution including fsl(3) logging
  76. rather than syslog(3) and STARTTLS support by default.
  77. Options:
  78. --define 'with_tls %{with_tls}'
  79. --define 'with_sasl %{with_sasl}'
  80. --define 'with_milter %{with_milter}'
  81. --define 'with_ldap %{with_ldap}'
  82. %prep
  83. # unpack standard tarballs
  84. %setup0 -q -c
  85. %setup1 -q -T -D -a 1
  86. ( cd sendmail-%{version}/smrsh
  87. %patch0 -p0
  88. )
  89. ( cd sendmail-%{version}/cf/m4
  90. %patch1 -p0
  91. )
  92. ( cd sendmail-%{version}/sendmail
  93. %patch2 -p0
  94. )
  95. ( cd sendmail-%{version}/cf/m4
  96. %patch3 -p0
  97. )
  98. %patch4 -p0
  99. # add own M4 stuff to Sendmail configuration set
  100. ( cd sendmail-%{version}
  101. %{l_tar} xf %{SOURCE cf.tar}
  102. )
  103. %build
  104. # build Sendmail
  105. ( cd sendmail-%{version}
  106. # indicate with a plus sign that we use a patched version
  107. chmod u+w sendmail/version.c
  108. %{l_shtool} subst \
  109. -e 's;\(Version\[\][^"]*\)"[^"]*";\1"%{version}+";' \
  110. sendmail/version.c
  111. # add linker flag defs for fsl(3)
  112. LDFLAGS="`%{l_prefix}/bin/fsl-config --ldflags --all`" \
  113. LIBS="`%{l_prefix}/bin/fsl-config --libs --all`" \
  114. # configure Sendmail
  115. ( echo "define(\`confMAPDEF', \`-DMAP_REGEX')dnl"
  116. echo "define(\`confSBINOWN', \`%{l_musr}')dnl"
  117. echo "define(\`confSBINGRP', \`%{l_mgrp}')dnl"
  118. echo "define(\`confUBINOWN', \`%{l_musr}')dnl"
  119. echo "define(\`confUBINGRP', \`%{l_mgrp}')dnl"
  120. echo "define(\`confMANOWN', \`%{l_musr}')dnl"
  121. echo "define(\`confMANGRP', \`%{l_mgrp}')dnl"
  122. echo "define(\`confEBINDIR', \`%{l_prefix}/libexec/sendmail')dnl"
  123. echo "define(\`confHFDIR', \`%{l_prefix}/etc/sendmail')dnl"
  124. echo "define(\`confHFFILE', \`sendmail.help')dnl"
  125. echo "define(\`confINCLUDEDIR', \`%{l_prefix}/include/sendmail')dnl"
  126. echo "define(\`confINSTALL_RAWMAN', \`1')dnl"
  127. echo "define(\`confLIBDIR', \`%{l_prefix}/lib/sendmail')dnl"
  128. echo "define(\`confMANROOT', \`%{l_prefix}/man/cat')dnl"
  129. echo "define(\`confMANROOTMAN', \`%{l_prefix}/man/man')dnl"
  130. echo "define(\`confMBINDIR', \`%{l_prefix}/sbin')dnl"
  131. echo "define(\`confSBINDIR', \`%{l_prefix}/sbin')dnl"
  132. echo "define(\`confSHAREDLIBDIR', \`%{l_prefix}/lib')dnl"
  133. echo "define(\`confSTDIR', \`%{l_prefix}/var/sendmail')dnl"
  134. echo "define(\`confSTFILE', \`sendmail.stat')dnl"
  135. echo "define(\`confUBINDIR', \`%{l_prefix}/bin')dnl"
  136. echo "define(\`confLNOPTS', \`-f')dnl"
  137. echo "define(\`confFORCE_RMAIL', \`yes')dnl"
  138. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILCF=\\\"%{l_prefix}/etc/sendmail/sendmail.cf\\\"')dnl"
  139. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILPID=\\\"%{l_prefix}/var/sendmail/sendmail.pid\\\"')dnl"
  140. echo "APPENDDEF(\`confENVDEF', \`-DNEWDB')dnl"
  141. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include')dnl"
  142. echo "APPENDDEF(\`confLIBDIRS', \`-L%{l_prefix}/lib')dnl"
  143. echo "APPENDDEF(\`confLIBS', \`-lfsl -ldb')dnl"
  144. echo "define(\`confSTDIO_TYPE', \`portable')dnl"
  145. echo "APPENDDEF(\`confENVDEF', \`-DDNSMAP')dnl"
  146. %if "%{with_tls}" == "yes"
  147. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSTARTTLS')dnl"
  148. echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lssl -lcrypto')dnl"
  149. %endif
  150. %if "%{with_sasl}" == "yes"
  151. echo "APPENDDEF(\`confENVDEF', \`-DSASL=1')dnl"
  152. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include/sasl')dnl"
  153. echo "APPENDDEF(\`confLIBS', \`-lsasl2 -lcrypto')dnl"
  154. %endif
  155. %if "%{with_milter}" == "yes"
  156. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DMILTER')dnl"
  157. echo "APPENDDEF(\`conf_libmilter_ENVDEF', \`-D_FFR_MILTER_ROOT_UNSAFE')dnl"
  158. %endif
  159. %if "%{with_ldap}" == "yes"
  160. echo "APPENDDEF(\`confMAPDEF', \`-DLDAPMAP')dnl"
  161. echo "APPENDDEF(\`confENVDEF', \`-DSM_CONF_LDAP_MEMFREE=1')dnl"
  162. echo "APPENDDEF(\`confLIBS', \`-lldap -llber -lssl -lcrypto')dnl"
  163. %endif
  164. ) >devtools/Site/site.config.m4
  165. # build Sendmail package
  166. %{l_make} %{l_mflags}
  167. )
  168. %install
  169. rm -rf $RPM_BUILD_ROOT
  170. # manually create filesystem hierarchy, because Sendmail's
  171. # install target doesn't properly create it itself.
  172. %{l_shtool} mkdir -f -p -m 755 \
  173. $RPM_BUILD_ROOT%{l_prefix} \
  174. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail \
  175. $RPM_BUILD_ROOT%{l_prefix}/bin \
  176. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  177. $RPM_BUILD_ROOT%{l_prefix}/lib \
  178. $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail \
  179. $RPM_BUILD_ROOT%{l_prefix}/man \
  180. $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
  181. $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
  182. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  183. $RPM_BUILD_ROOT%{l_prefix}/man/cat1 \
  184. $RPM_BUILD_ROOT%{l_prefix}/man/cat5 \
  185. $RPM_BUILD_ROOT%{l_prefix}/man/cat8
  186. # install Sendmail
  187. ( cd sendmail-%{version}
  188. myusr=`(id -un) 2>/dev/null ||\
  189. (whoami) 2>/dev/null ||\
  190. (who am i | cut "-d " -f1) 2>/dev/null ||\
  191. echo $LOGNAME`
  192. mygrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  193. grep "^${myusr}:" | awk -F: '{ print $4; }' | head -1`
  194. mygrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
  195. grep ":${mygrp}:" | awk -F: '{ print $1; }' | head -1`
  196. %{l_shtool} subst \
  197. -e "s;^\\(SBINOWN.*=\\).*;\\1 $myusr;" \
  198. -e "s;^\\(SBINGRP.*=\\).*;\\1 $mygrp;" \
  199. -e "s;^\\(UBINOWN.*=\\).*;\\1 $myusr;" \
  200. -e "s;^\\(UBINGRP.*=\\).*;\\1 $mygrp;" \
  201. -e "s;^\\(GBINOWN.*=\\).*;\\1 $myusr;" \
  202. -e "s;^\\(GBINGRP.*=\\).*;\\1 $mygrp;" \
  203. -e "s;^\\(MANOWN.*=\\).*;\\1 $myusr;" \
  204. -e "s;^\\(MANGRP.*=\\).*;\\1 $mygrp;" \
  205. -e "s;^\\(CFOWN.*=\\).*;\\1 $myusr;" \
  206. -e "s;^\\(CFGRP.*=\\).*;\\1 $mygrp;" \
  207. -e "s;^\\(MBINOWN.*=\\).*;\\1 $myusr;" \
  208. -e "s;^\\(MBINGRP.*=\\).*;\\1 $mygrp;" \
  209. -e "s;^\\(MSPQOWN.*=\\).*;\\1 $myusr;" \
  210. -e "s;^\\(MSPQGRP.*=\\).*;\\1 $mygrp;" \
  211. -e "s;^\\(LIBOWN.*=\\).*;\\1 $myusr;" \
  212. -e "s;^\\(LIBGRP.*=\\).*;\\1 $mygrp;" \
  213. -e "s;^\\(INCOWN.*=\\).*;\\1 $myusr;" \
  214. -e "s;^\\(INCGRP.*=\\).*;\\1 $mygrp;" \
  215. -e 's;ln -s *;$(LN) $(LNOPTS) $(DESTDIR);' \
  216. Makefile */Makefile */*/Makefile
  217. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT \
  218. MSPQ=%{l_prefix}$MSPQ MAILDIR=%{l_prefix}
  219. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rmail \
  220. $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  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. )
  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_hostname@;${l_hostname};g" \
  256. -e "s;@l_domainname@;${l_domainname};g" \
  257. -e "s;@l_ostype@;${l_ostype};g" \
  258. * $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/
  259. )
  260. # install the run-command script
  261. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  262. %{l_shtool} install -c -m 755 \
  263. -e 's;@l_prefix@;%{l_prefix};g' \
  264. -e 's;@l_musr@;%{l_musr};g' \
  265. -e 's;@l_mgrp@;%{l_mgrp};g' \
  266. %{SOURCE rc.sendmail} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  267. # create important files which have to be present from the beginning
  268. %{l_shtool} mkdir -f -p -m 700 \
  269. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue \
  270. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue/.hoststat
  271. %{l_shtool} mkdir -f -p -m 770 \
  272. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue \
  273. $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/clientmqueue/.hoststat
  274. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.in.pid
  275. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.out.pid
  276. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.log
  277. # adjust installation tree
  278. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/cat*
  279. chmod -R u+w $RPM_BUILD_ROOT%{l_prefix}/
  280. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  281. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2> /dev/null || true
  282. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail/* 2> /dev/null || true
  283. # determine file list
  284. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  285. %{l_files_std} \
  286. '%attr(2755,root,%{l_rgrp}) %{l_prefix}/sbin/sendmail' \
  287. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/hoststat' \
  288. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/mailq' \
  289. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/newaliases' \
  290. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/purgestat' \
  291. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/bin/vacation' \
  292. '%attr(4755,root,%{l_mgrp}) %{l_prefix}/libexec/sendmail/smrsh' \
  293. '%attr(755,root,%{l_mgrp}) %{l_prefix}/etc/sendmail' \
  294. '%config %{l_prefix}/etc/sendmail/*' \
  295. '%config %attr(644,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/ca.crt' \
  296. '%config %attr(644,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.crt' \
  297. '%config %attr(600,root,%{l_mgrp}) %{l_prefix}/etc/sendmail/sendmail.key' \
  298. '%config %{l_prefix}/etc/fsl/fsl.sendmail' \
  299. '%not %dir %{l_prefix}/etc/fsl' \
  300. '%attr(700,root,%{l_mgrp}) %{l_prefix}/var/sendmail/mqueue' \
  301. '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/sendmail/clientmqueue' \
  302. '%attr(644,root,%{l_mgrp}) %{l_prefix}/var/sendmail/sendmail.log' \
  303. '%attr(644,root,%{l_mgrp}) %{l_prefix}/var/sendmail/sendmail.*.pid'
  304. %files -f files
  305. %clean
  306. rm -rf $RPM_BUILD_ROOT
  307. %post
  308. if [ $1 -eq 1 ]; then
  309. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} all >/dev/null 2>&1 || true)
  310. elif [ $1 -gt 1 ]; then
  311. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} clean all >/dev/null 2>&1 || true)
  312. $RPM_INSTALL_PREFIX/etc/rc sendmail reload >/dev/null 2>&1 || true
  313. fi
  314. %preun
  315. if [ $1 -eq 0 ]; then
  316. $RPM_INSTALL_PREFIX/etc/rc sendmail stop >/dev/null 2>&1 || true
  317. (cd $RPM_INSTALL_PREFIX/etc/sendmail/; %{l_make} clean >/dev/null 2>&1 || true)
  318. fi