sendmail.spec 15 KB

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