sendmail.spec 15 KB

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