sendmail.spec 13 KB

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