sendmail.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. ##
  2. ## sendmail.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2001 Ralf S. Engelschall <rse@engelschall.com>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. %define V_sendmail 8.11.6
  25. %define V_wide 8.11.6+3.4W
  26. %define V_smtpfeed 1.16
  27. %define V_lmtp2nntp 1.0.0
  28. # package information
  29. Name: sendmail
  30. Summary: Mail Transfer Agent
  31. URL: http://www.sendmail.org/
  32. Vendor: Eric Allman
  33. Packager: The OpenPKG Project
  34. Distribution: OpenPKG [EXP]
  35. Group: Mail
  36. License: BSD
  37. Version: %{V_sendmail}
  38. Release: 13
  39. # list of sources
  40. Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{V_sendmail}.tar.gz
  41. Source1: ftp://ftp.kyoto.wide.ad.jp/pub/mail/smtpfeed/smtpfeed-%{V_smtpfeed}.tar.gz
  42. Source2: ftp://ftp.ossp.org/pkg/lmtp2nntp/lmtp2nntp-%{V_lmtp2nntp}.tar.gz
  43. Source3: etc.sendmail.tar
  44. Source4: ftp://ftp.openpkg.org/DST/sendmail/fakesyslog.tar.gz
  45. Source5: cf.tar
  46. Source6: rc.sendmail
  47. Patch0: ftp://ftp.kyoto.wide.ad.jp/pub/mail/sendmail/sendmail%{V_wide}.patch.gz
  48. Patch1: sendmail.%{V_sendmail}.patch.autonomous
  49. # build information
  50. Prefix: %{l_prefix}
  51. BuildRoot: %{l_buildroot}
  52. BuildPreReq: openpkg >= 0.9-24, m4, make, db, openssl, sfio, patch
  53. PreReq: openpkg >= 0.9-24, m4, make, perl, procmail
  54. AutoReq: no
  55. AutoReqProv: no
  56. Provides: MTA
  57. %description
  58. Sendmail is the most-popular Mail Transfer Agent (MTA).
  59. Local specifics in this OpenPKG version:
  60. o Sendmail uses two process pools (incoming and outgoing)
  61. o Sendmail logs directly to the filesystem and not via syslog(3)
  62. o Sendmail delivers local mail via Procmail to ~<user>/.mail/inbox
  63. o Sendmail by default uses SMTPfeed for outgoing mass-delivery
  64. o Sendmail by default supports STARTTLS
  65. %prep
  66. # unpack standard tarballs
  67. %setup0 -q -c
  68. %setup1 -q -T -D -a 1
  69. %setup2 -q -T -D -a 2
  70. %setup3 -q -T -D -a 3
  71. %setup4 -q -T -D -a 4
  72. # apply Sendmail patch manually
  73. ( cd sendmail-%{V_sendmail}/sendmail
  74. %{l_gzip} -dc %{SOURCE sendmail%{V_wide}.patch.gz} |\
  75. sed -e 's;LOG_INFO;LOG_DEBUG;' | %{l_patch} -p1
  76. %{l_patch} -p1 <%{SOURCE sendmail.%{V_sendmail}.patch.autonomous}
  77. )
  78. # add own M4 stuff to Sendmail configuration set
  79. ( cd sendmail-%{V_sendmail}
  80. %{l_tar} xf %{SOURCE cf.tar}
  81. )
  82. %build
  83. PATH="%{l_prefix}/bin:$PATH"; export PATH
  84. # build faked syslog(3) library
  85. fakesyslogdir="`pwd`/fakesyslog"
  86. ( cd fakesyslog
  87. CC="%{l_cc}" \
  88. CFLAGS="%{l_cflags -O}" \
  89. ./configure \
  90. --with-logfile=%{l_prefix}/var/sendmail/sendmail.log
  91. %{l_make} %{l_mflags}
  92. )
  93. # build Sendmail
  94. ( cd sendmail-%{V_sendmail}
  95. # indicate with a plus sign that we use a patched version
  96. chmod u+w sendmail/version.c
  97. %{l_rpmtool} subst \
  98. 's;\(Version\[\][^"]*\)"[^"]*";\1"%{V_sendmail}+";' \
  99. -- sendmail/version.c
  100. # configure Sendmail
  101. ( echo "define(\`confMAPDEF', \`-DMAP_REGEX')dnl"
  102. echo "define(\`confSBINOWN', \`%{l_fsusr}')dnl"
  103. echo "define(\`confSBINGRP', \`%{l_fsgrp}')dnl"
  104. echo "define(\`confUBINOWN', \`%{l_fsusr}')dnl"
  105. echo "define(\`confUBINGRP', \`%{l_fsgrp}')dnl"
  106. echo "define(\`confMANOWN', \`%{l_fsusr}')dnl"
  107. echo "define(\`confMANGRP', \`%{l_fsgrp}')dnl"
  108. echo "define(\`confEBINDIR', \`%{l_prefix}/libexec/sendmail')dnl"
  109. echo "define(\`confHFDIR', \`%{l_prefix}/etc/sendmail')dnl"
  110. echo "define(\`confHFFILE', \`sendmail.help')dnl"
  111. echo "define(\`confINCLUDEDIR', \`%{l_prefix}/include/sendmail')dnl"
  112. echo "define(\`confINSTALL_RAWMAN', \`1')dnl"
  113. echo "define(\`confLIBDIR', \`%{l_prefix}/lib/sendmail')dnl"
  114. echo "define(\`confMANROOT', \`%{l_prefix}/man/cat')dnl"
  115. echo "define(\`confMANROOTMAN', \`%{l_prefix}/man/man')dnl"
  116. echo "define(\`confMBINDIR', \`%{l_prefix}/sbin')dnl"
  117. echo "define(\`confSBINDIR', \`%{l_prefix}/sbin')dnl"
  118. echo "define(\`confSHAREDLIBDIR', \`%{l_prefix}/lib')dnl"
  119. echo "define(\`confSTDIR', \`%{l_prefix}/var/sendmail')dnl"
  120. echo "define(\`confSTFILE', \`sendmail.stat')dnl"
  121. echo "define(\`confUBINDIR', \`%{l_prefix}/bin')dnl"
  122. echo "define(\`confLNOPTS', \`-f')dnl"
  123. echo "APPENDDEF(\`confENVDEF', \`-DPATCH_AUTONOMOUS')dnl"
  124. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILCF=\\\"%{l_prefix}/etc/sendmail/sendmail.cf\\\"')dnl"
  125. echo "APPENDDEF(\`confENVDEF', \`-D_PATH_SENDMAILPID=\\\"%{l_prefix}/var/sendmail/sendmail.pid\\\"')dnl"
  126. echo "APPENDDEF(\`confENVDEF', \`-DSFIO')dnl"
  127. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include')dnl"
  128. echo "APPENDDEF(\`confLIBDIRS', \`-L%{l_prefix}/lib')dnl"
  129. echo "APPENDDEF(\`confLIBS', \`-ldb')dnl"
  130. echo "define(\`confSTDIO_TYPE', \`portable')dnl"
  131. echo "APPENDDEF(\`confINCDIRS', \`-I%{l_prefix}/include/sfio')dnl"
  132. echo "APPENDDEF(\`confLIBS', \`-lsfio')dnl"
  133. echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSTARTTLS')dnl"
  134. echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lssl -lcrypto')dnl"
  135. echo "APPENDDEF(\`confLIBDIRS', \`-L$fakesyslogdir')dnl"
  136. echo "APPENDDEF(\`confLIBS', \`-lfakesyslog')dnl"
  137. ) >devtools/Site/site.config.m4
  138. # build Sendmail package
  139. %{l_make} %{l_mflags}
  140. )
  141. # build the LMTP mailer SMTPFeed
  142. ( cd smtpfeed-%{V_smtpfeed}
  143. %{l_rpmtool} subst \
  144. 's;smtpfeed 1.[0-9]*;smtpfeed %{V_smtpfeed};' \
  145. -- version.c
  146. CC="%{l_cc}" \
  147. CFLAGS="%{l_cflags -O}" \
  148. LDFLAGS="-L$fakesyslogdir" \
  149. LIBS="-lfakesyslog" \
  150. ./configure \
  151. --prefix=%{l_prefix}
  152. %{l_make} %{l_mflags -O}
  153. )
  154. # build the LMTP mailer LMTP2NNTP
  155. ( cd lmtp2nntp-%{V_lmtp2nntp}
  156. CC="%{l_cc}" \
  157. CFLAGS="%{l_cflags -O}" \
  158. ./configure \
  159. --prefix=%{l_prefix}
  160. %{l_make} %{l_mflags}
  161. )
  162. %install
  163. rm -rf $RPM_BUILD_ROOT
  164. PATH="%{l_prefix}/bin:$PATH"; export PATH
  165. # manually create filesystem hierarchy, because Sendmail's
  166. # install target doesn't properly create it itself.
  167. %{l_shtool} mkdir -f -p -m 755 \
  168. $RPM_BUILD_ROOT%{l_prefix} \
  169. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail \
  170. $RPM_BUILD_ROOT%{l_prefix}/bin \
  171. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  172. $RPM_BUILD_ROOT%{l_prefix}/lib \
  173. $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail \
  174. $RPM_BUILD_ROOT%{l_prefix}/man \
  175. $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
  176. $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
  177. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  178. $RPM_BUILD_ROOT%{l_prefix}/man/cat1 \
  179. $RPM_BUILD_ROOT%{l_prefix}/man/cat5 \
  180. $RPM_BUILD_ROOT%{l_prefix}/man/cat8
  181. # install Sendmail
  182. ( cd sendmail-%{V_sendmail}
  183. myusr=`(id -un) 2>/dev/null ||\
  184. (whoami) 2>/dev/null ||\
  185. (who am i | cut "-d " -f1) 2>/dev/null ||\
  186. echo $LOGNAME`
  187. mygrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  188. grep "^${myusr}:" | awk -F: '{ print $4; }' | head -1`
  189. mygrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
  190. grep ":${mygrp}:" | awk -F: '{ print $1; }' | head -1`
  191. %{l_rpmtool} subst \
  192. "s;^\\(SBINOWN.*=\\).*;\\1 $myusr;" \
  193. "s;^\\(SBINGRP.*=\\).*;\\1 $mygrp;" \
  194. "s;^\\(UBINOWN.*=\\).*;\\1 $myusr;" \
  195. "s;^\\(UBINGRP.*=\\).*;\\1 $mygrp;" \
  196. "s;^\\(MANOWN.*=\\).*;\\1 $myusr;" \
  197. "s;^\\(MANGRP.*=\\).*;\\1 $mygrp;" \
  198. 's;ln -s *;$(LN) $(LNOPTS) $(DESTDIR);' \
  199. -- Makefile */Makefile */*/Makefile
  200. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  201. # remember the Sendmail M4 stuff for re-configuration
  202. (%{l_tar} cf $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar cf)
  203. compress $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.tar
  204. %{l_shtool} install -c -m 644 cf/README \
  205. $RPM_BUILD_ROOT%{l_prefix}/etc/sendmail/cf.README
  206. %{l_shtool} install -c -m 755 contrib/re-mqueue.pl \
  207. $RPM_BUILD_ROOT%{l_prefix}/sbin/re-mqueue
  208. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  209. contrib/qtool.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qtool
  210. %{l_shtool} install -c -m 755 -e 's;^#!.*;#!%{l_prefix}/bin/perl;' \
  211. contrib/qtool.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qtool.8
  212. )
  213. # install SMTPFeed
  214. ( cd smtpfeed-%{V_smtpfeed}
  215. %{l_shtool} install -c -s -m 755 \
  216. smtpfeed $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail/
  217. %{l_shtool} install -c -m 644 \
  218. smtpfeed.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
  219. )
  220. # install LMTP2NNTP
  221. ( cd lmtp2nntp-%{V_lmtp2nntp}
  222. %{l_shtool} install -c -s -m 755 \
  223. lmtp2nntp $RPM_BUILD_ROOT%{l_prefix}/libexec/sendmail/
  224. %{l_shtool} install -c -m 644 \
  225. lmtp2nntp.1 %$RPM_BUILD_ROOT%{l_prefix}/man/man8/lmtp2nntp.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_fsusr@;%{l_fsusr};g" \
  242. -e "s;@l_fsgrp@;%{l_fsgrp};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_fsusr@;%{l_fsusr};g' \
  253. -e 's;@l_fsgrp@;%{l_fsgrp};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 $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/mqueue
  257. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.in.pid
  258. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.out.pid
  259. touch $RPM_BUILD_ROOT%{l_prefix}/var/sendmail/sendmail.log
  260. # adjust installation tree
  261. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/cat*
  262. chmod -R u+w $RPM_BUILD_ROOT%{l_prefix}/
  263. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  264. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2> /dev/null || true
  265. # determine file list
  266. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  267. %{l_files_std} \
  268. '%attr(4755,root,%{l_fsgrp}) %{l_prefix}/sbin/sendmail' \
  269. '%attr(4755,root,%{l_fsgrp}) %{l_prefix}/bin/hoststat' \
  270. '%attr(4755,root,%{l_fsgrp}) %{l_prefix}/bin/mailq' \
  271. '%attr(4755,root,%{l_fsgrp}) %{l_prefix}/bin/newaliases' \
  272. '%attr(4755,root,%{l_fsgrp}) %{l_prefix}/bin/purgestat' \
  273. '%config %{l_prefix}/etc/sendmail/*' \
  274. '%config %attr(644,root,%{l_fsgrp}) %{l_prefix}/etc/sendmail/ca.crt' \
  275. '%config %attr(644,root,%{l_fsgrp}) %{l_prefix}/etc/sendmail/sendmail.crt' \
  276. '%config %attr(600,root,%{l_fsgrp}) %{l_prefix}/etc/sendmail/sendmail.key' \
  277. '%attr(700,root,%{l_fsgrp}) %{l_prefix}/var/sendmail/mqueue' \
  278. '%attr(644,root,%{l_fsgrp}) %{l_prefix}/var/sendmail/sendmail.log' \
  279. '%attr(644,root,%{l_fsgrp}) %{l_prefix}/var/sendmail/sendmail.*.pid'
  280. %files -f files
  281. %clean
  282. rm -rf $RPM_BUILD_ROOT
  283. %post
  284. if [ $1 -eq 1 ]; then
  285. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} all >/dev/null 2>&1)
  286. elif [ $1 -gt 1 ]; then
  287. (cd $RPM_INSTALL_PREFIX/etc/sendmail; %{l_make} clean all >/dev/null 2>&1)
  288. $RPM_INSTALL_PREFIX/etc/rc sendmail reload >/dev/null 2>&1 || true
  289. fi
  290. %preun
  291. if [ $1 -eq 0 ]; then
  292. $RPM_INSTALL_PREFIX/etc/rc sendmail stop >/dev/null 2>&1 || true
  293. (cd $RPM_INSTALL_PREFIX/etc/sendmail/; %{l_make} clean >/dev/null 2>&1)
  294. fi