openldap.spec 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. ##
  2. ## openldap.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 Ralf S. Engelschall <http://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. # package information
  25. Name: openldap
  26. Summary: Lightweight Directory Access Protocol (LDAP) Toolkit
  27. URL: http://www.openldap.org/
  28. Vendor: OpenLDAP Project
  29. Packager: OpenPKG
  30. Distribution: OpenPKG
  31. Class: BASE
  32. Group: Database
  33. License: GPL
  34. Version: 2.3.15
  35. Release: 20060105
  36. # package options
  37. %option with_fsl yes
  38. %option with_crypt yes
  39. %option with_sasl no
  40. %option with_perl no
  41. %option with_odbc no
  42. # list of sources
  43. Source0: ftp://ftp.openldap.org/pub/openldap/openldap-release/openldap-%{version}.tgz
  44. Source1: rc.openldap
  45. Source2: fsl.openldap
  46. Source3: openldap.pc
  47. Patch0: openldap.patch
  48. # build information
  49. Prefix: %{l_prefix}
  50. BuildRoot: %{l_buildroot}
  51. BuildPreReq: OpenPKG, openpkg >= 20050615, make, gcc
  52. PreReq: OpenPKG, openpkg >= 20050615
  53. BuildPreReq: readline, openssl, db >= 4.2, pth
  54. PreReq: readline, openssl, db >= 4.2, pth
  55. %if "%{with_fsl}" == "yes"
  56. BuildPreReq: fsl >= 1.2.0
  57. PreReq: fsl >= 1.2.0
  58. %endif
  59. %if "%{with_sasl}" == "yes"
  60. BuildPreReq: sasl
  61. PreReq: sasl
  62. %endif
  63. %if "%{with_odbc}" == "yes"
  64. BuildPreReq: unixodbc
  65. PreReq: unixodbc
  66. %endif
  67. AutoReq: no
  68. AutoReqProv: no
  69. %description
  70. OpenLDAP is an open source implementation of the Lightweight
  71. Directory Access Protocol (LDAP). The suite includes libraries
  72. implementing the LDAP protocol plus a stand-alone LDAP server
  73. slapd(8) and a stand-alone LDAP replication server slurpd(8).
  74. %track
  75. prog openldap = {
  76. version = %{version}
  77. url = ftp://ftp.openldap.org/pub/openldap/openldap-release/
  78. regex = openldap-(__VER__)\.tgz
  79. }
  80. %prep
  81. %setup -q
  82. %patch -p0
  83. %build
  84. # configuration: standard build flags
  85. export CC="%{l_cc}"
  86. export CFLAGS="%{l_cflags -O}"
  87. export CPPFLAGS="%{l_cppflags}"
  88. export LDFLAGS="%{l_ldflags}"
  89. export LIBS=""
  90. export ARGS=""
  91. ARGS="$ARGS --prefix=%{l_prefix}"
  92. ARGS="$ARGS --libexecdir=%{l_prefix}/libexec/openldap"
  93. ARGS="$ARGS --localstatedir=%{l_prefix}/var/openldap"
  94. ARGS="$ARGS --enable-syslog"
  95. ARGS="$ARGS --with-readline"
  96. ARGS="$ARGS --with-tls"
  97. ARGS="$ARGS --disable-dynamic"
  98. ARGS="$ARGS --disable-shared"
  99. ARGS="$ARGS --disable-modules"
  100. ARGS="$ARGS --enable-ldbm"
  101. ARGS="$ARGS --enable-ldbm-api=berkeley"
  102. ARGS="$ARGS --enable-ldbm-type=btree"
  103. ARGS="$ARGS --enable-bdb"
  104. ARGS="$ARGS --enable-rewrite"
  105. ARGS="$ARGS --enable-hdb"
  106. ARGS="$ARGS --enable-ldap"
  107. ARGS="$ARGS --enable-meta"
  108. ARGS="$ARGS --enable-monitor"
  109. ARGS="$ARGS --enable-dnssrv"
  110. ARGS="$ARGS --enable-null"
  111. ARGS="$ARGS --enable-shell"
  112. ARGS="$ARGS --with-dyngroup"
  113. ARGS="$ARGS --with-proxycache"
  114. ARGS="$ARGS --enable-slurpd"
  115. # configuration: force to use OSSP fsl
  116. LDFLAGS="$LDFLAGS %{l_fsl_ldflags}"
  117. LIBS="$LIBS %{l_fsl_libs}"
  118. # configuration: force to use GNU pth
  119. CFLAGS="$CFLAGS `%{l_prefix}/bin/pth-config --cflags`"
  120. CPPFLAGS="$CPPFLAGS -I`%{l_prefix}/bin/pth-config --includedir`"
  121. LDFLAGS="$LDFLAGS `%{l_prefix}/bin/pth-config --ldflags`"
  122. LIBS="`%{l_prefix}/bin/pth-config --libs` $LIBS"
  123. ARGS="$ARGS --with-threads=pth"
  124. # configuration: optional SASL support
  125. %if "%{with_sasl}" == "yes"
  126. ( echo "ac_cv_lib_sasl2_sasl_client_init=yes"
  127. ) >config.cache
  128. CPPFLAGS="%{l_cppflags sasl} $CPPFLAGS"
  129. ARGS="$ARGS --with-cyrus-sasl --enable-spasswd"
  130. %else
  131. ARGS="$ARGS --without-cyrus-sasl --disable-spasswd"
  132. %endif
  133. # configuration: optional crypt(3) support
  134. %if "%{with_crypt}" == "yes"
  135. ARGS="$ARGS --enable-crypt"
  136. %endif
  137. # configuration: optional Perl support
  138. %if "%{with_perl}" == "yes"
  139. ARGS="$ARGS --enable-perl"
  140. %endif
  141. # configuration: optional ODBC-based RDBMS support
  142. %if "%{with_odbc}" == "yes"
  143. ARGS="$ARGS --enable-sql"
  144. %endif
  145. # configuration: special platform support
  146. case "%{l_platform -t}" in
  147. *-sunos* ) LIBS="$LIBS -lrt" ;;
  148. esac
  149. # configuration: use hard-links and make sure our Berkeley-DB is picked up first
  150. %{l_shtool} subst \
  151. -e 's;ln -s;ln;g' \
  152. -e 's;-ldb4[234];-ldb;g' \
  153. -e 's;<db\.h>;"db.h";g' \
  154. configure
  155. # configuration
  156. ./configure --cache-file=./config.cache $ARGS
  157. # build toolkit
  158. %{l_make} %{l_mflags} depend
  159. %{l_make} %{l_mflags}
  160. %install
  161. # install toolkit
  162. rm -rf $RPM_BUILD_ROOT
  163. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  164. # post adjustment: remove extra files
  165. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*.default
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*/*.default
  167. # post adjustment: enable and correct slurpd.pid (slapd.pid as a precaution, too)
  168. %{l_shtool} subst \
  169. -e 's;^[ #]*\(pidfile \).*$;\1 %{l_prefix}/var/openldap/run/slapd.pid;' \
  170. -e 's;^[ #]*\(replica-pidfile \).*$;\1 %{l_prefix}/var/openldap/run/slurpd.pid;' \
  171. $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/slapd.conf
  172. # post adjustment: remove OSSP fsl dependency from libtool files
  173. %{l_shtool} subst \
  174. -e 's;-lfsl *;;' \
  175. $RPM_BUILD_ROOT%{l_prefix}/lib/*.la
  176. # install run-command script
  177. %{l_shtool} mkdir -f -p -m 755 \
  178. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  179. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  180. %{SOURCE rc.openldap} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  181. # install OSSP fsl configuration
  182. %{l_shtool} mkdir -f -p -m 755 \
  183. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  184. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  185. %{SOURCE fsl.openldap} \
  186. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  187. # install pkg-config configuration
  188. %{l_shtool} mkdir -f -p -m 755 \
  189. $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
  190. libs="-lldap -llber"
  191. %if "%{with_sasl}" == "yes"
  192. libs="$libs -lsasl2"
  193. %endif
  194. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  195. -e "s;@version@;%{version};" \
  196. -e "s;@libs@;$libs;" \
  197. %{SOURCE openldap.pc} \
  198. $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
  199. # determine installation files
  200. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  201. %{l_files_std} \
  202. '%not %dir %{l_prefix}/etc/fsl' \
  203. '%not %dir %{l_prefix}/lib/pkgconfig' \
  204. '%config %{l_prefix}/etc/fsl/fsl.openldap' \
  205. '%config %{l_prefix}/etc/openldap/*.conf'
  206. %files -f files
  207. %clean
  208. rm -rf $RPM_BUILD_ROOT
  209. %pre
  210. # before upgrade, save status and stop service
  211. [ $1 -eq 2 ] || exit 0
  212. eval `%{l_rc} openldap status 2>/dev/null | tee %{l_tmpfile}`
  213. %{l_rc} openldap stop 2>/dev/null
  214. exit 0
  215. %post
  216. # after upgrade, restore status
  217. [ $1 -eq 2 ] || exit 0
  218. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  219. [ ".$openldap_active" = .yes ] && %{l_rc} openldap start
  220. exit 0
  221. %preun
  222. # before erase, stop service and remove log files
  223. [ $1 -eq 0 ] || exit 0
  224. %{l_rc} openldap stop 2>/dev/null
  225. rm -f $RPM_INSTALL_PREFIX/var/openldap/openldap.log* >/dev/null 2>&1 || true
  226. exit 0