openldap.spec 8.5 KB

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