sendmail.spec 15 KB

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