Mon, 01 Jul 2013 22:00:33 +0200
Correct use of nonportable u_int types and update to new vendor version.
1 ##
2 ## openldap.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2009 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
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 Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: BASE
32 Group: LDAP
33 License: GPL
34 Version: 2.4.35
35 Release: 20120800
37 # package options
38 %option with_server yes
39 %option with_fsl yes
40 %option with_crypt yes
41 %option with_overlays yes
42 %option with_pth yes
43 %option with_pthreads no
44 %option with_sasl no
45 %option with_perl no
46 %option with_odbc no
48 # list of sources
49 Source0: ftp://ftp.openldap.org/pub/openldap/openldap-release/openldap-%{version}.tgz
50 Source1: rc.openldap
51 Source2: fsl.openldap
52 Source3: openldap.pc
53 Patch0: openldap.patch
55 # build information
56 BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc
57 PreReq: OpenPKG, openpkg >= 20100101
58 BuildPreReq: openssl, db >= 4.5
59 PreReq: openssl, db >= 4.5
60 %if "%{with_server}" == "yes" && "%{with_fsl}" == "yes"
61 BuildPreReq: fsl
62 PreReq: fsl
63 %endif
64 %if "%{with_server}" == "yes" && "%{with_pthreads}" == "yes"
65 BuildPreReq: db::with_pthreads = yes
66 PreReq: db::with_pthreads = yes
67 %endif
68 %if "%{with_server}" == "yes" && "%{with_pth}" == "yes"
69 BuildPreReq: pth
70 PreReq: pth
71 %endif
72 %if "%{with_sasl}" == "yes"
73 BuildPreReq: sasl
74 PreReq: sasl
75 %endif
76 %if "%{with_server}" == "yes" && "%{with_odbc}" == "yes"
77 BuildPreReq: ODBC
78 PreReq: ODBC
79 %endif
81 %description
82 OpenLDAP is an open source implementation of the Lightweight
83 Directory Access Protocol (LDAP). The suite includes libraries
84 implementing the LDAP protocol plus a stand alone LDAP server
85 slapd(8).
87 %track
88 prog openldap = {
89 version = %{version}
90 url = ftp://ftp.openldap.org/pub/openldap/openldap-release/
91 regex = openldap-(__VER__)\.tgz
92 }
94 %prep
95 %setup -q
96 %patch -p0
97 %{l_shtool} subst \
98 -e 's;-ldb-4\.[1-9];-ldb;g' \
99 -e 's;-ldb-4-[1-9];-ldb;g' \
100 -e 's;-ldb-4[1-9];-ldb;g' \
101 -e 's;-ldb-4;-ldb;g' \
102 configure
103 ( cd servers/slapd/back-bdb/
104 %{l_shtool} subst \
105 -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \
106 back-bdb.h init.c config.c dbcache.c dn2id.c idl.c
107 ) || exit $?
109 %build
110 cp /dev/null config.cache
112 # configuration: standard build flags
113 export CC="%{l_cc}"
114 export CFLAGS="%{l_cflags -O}"
115 export CPPFLAGS="%{l_cppflags}"
116 export LDFLAGS="%{l_ldflags}"
117 export LIBS=""
118 export ARGS=""
119 ARGS="$ARGS --prefix=%{l_prefix}"
120 ARGS="$ARGS --mandir=%{l_prefix}/man"
121 ARGS="$ARGS --infodir=%{l_prefix}/info"
122 ARGS="$ARGS --libexecdir=%{l_prefix}/libexec/openldap"
123 ARGS="$ARGS --localstatedir=%{l_prefix}/var/openldap"
124 ARGS="$ARGS --enable-syslog"
125 ARGS="$ARGS --with-tls"
126 ARGS="$ARGS --without-fetch"
127 ARGS="$ARGS --disable-dynamic"
128 ARGS="$ARGS --disable-shared"
129 %if "%{with_server}" == "yes"
130 ARGS="$ARGS --enable-slapd"
131 ARGS="$ARGS --disable-modules"
132 ARGS="$ARGS --enable-local"
133 ARGS="$ARGS --enable-bdb"
134 ARGS="$ARGS --enable-hdb"
135 ARGS="$ARGS --enable-rewrite"
136 ARGS="$ARGS --enable-ldap"
137 ARGS="$ARGS --enable-meta"
138 ARGS="$ARGS --enable-monitor"
139 ARGS="$ARGS --enable-dnssrv"
140 ARGS="$ARGS --enable-null"
141 ARGS="$ARGS --enable-shell"
142 ARGS="$ARGS --enable-proxycache"
143 ARGS="$ARGS --disable-mdb"
144 %else
145 ARGS="$ARGS --disable-slapd"
146 ARGS="$ARGS --disable-modules"
147 %endif
149 # configuration: force to use OSSP fsl
150 %if "%{with_server}" == "yes"
151 LDFLAGS="$LDFLAGS %{l_fsl_ldflags}"
152 LIBS="$LIBS %{l_fsl_libs}"
153 %endif
155 # configuration: force to use GNU pth if enabled
156 %if "%{with_server}" == "yes"
157 %if "%{with_pth}" == "yes"
158 CFLAGS="$CFLAGS `%{l_prefix}/bin/pth-config --cflags`"
159 CPPFLAGS="$CPPFLAGS -I`%{l_prefix}/bin/pth-config --includedir`"
160 LDFLAGS="$LDFLAGS `%{l_prefix}/bin/pth-config --ldflags`"
161 LIBS="`%{l_prefix}/bin/pth-config --libs` $LIBS"
162 ARGS="$ARGS --with-threads=pth"
163 ( echo "ac_cv_header_sys_devpoll_h=no"
164 echo "ac_cv_header_sys_epoll_h=no"
165 ) >>config.cache
166 %else
167 %if "%{with_pthreads}" == "yes"
168 ARGS="$ARGS --with-threads=posix"
169 %else
170 ARGS="$ARGS --with-threads=no"
171 %endif
172 %endif
173 %endif
175 # configuration: optional overlay support
176 %if "%{with_server}" == "yes" && "%{with_overlays}" == "yes"
177 ARGS="$ARGS --enable-overlays=yes"
178 %endif
180 # configuration: optional SASL support
181 %if "%{with_sasl}" == "yes"
182 ( echo "ac_cv_lib_sasl2_sasl_client_init=yes"
183 ) >>config.cache
184 CPPFLAGS="%{l_cppflags sasl} $CPPFLAGS"
185 ARGS="$ARGS --with-cyrus-sasl --enable-spasswd"
186 %else
187 ARGS="$ARGS --without-cyrus-sasl --disable-spasswd"
188 %endif
190 # configuration: optional crypt(3) support
191 %if "%{with_crypt}" == "yes"
192 ARGS="$ARGS --enable-crypt"
193 %endif
195 # configuration: optional Perl support
196 %if "%{with_server}" == "yes" && "%{with_perl}" == "yes"
197 ARGS="$ARGS --enable-perl"
198 %endif
200 # configuration: optional ODBC-based RDBMS support
201 %if "%{with_server}" == "yes" && "%{with_odbc}" == "yes"
202 ARGS="$ARGS --enable-sql"
203 %endif
205 # configuration: special platform support
206 case "%{l_platform -t}" in
207 *-sunos* ) CFLAGS="$CFLAGS -D_AVL_H"; LIBS="$LIBS -lrt" ;;
208 esac
210 # configuration: use hard links and make sure our Berkeley DB is picked up first
211 %{l_shtool} subst \
212 -e 's;ln -s;ln;g' \
213 -e 's;-ldb4[1-9];%{l_prefix}/lib/libdb.a;g' \
214 -e 's;<db\.h>;"db.h";g' \
215 configure
217 # configuration
218 ./configure --cache-file=./config.cache $ARGS
220 # build toolkit
221 %{l_make} %{l_mflags -O} depend
222 %{l_make} %{l_mflags -O}
224 %install
225 # install toolkit
226 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
228 # post adjustment: remove extra files
229 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*.default
230 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*/*.default
232 # post adjustment: move files
233 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/DB_CONFIG.example
234 %if "%{with_server}" == "yes"
235 mv $RPM_BUILD_ROOT%{l_prefix}/var/openldap/openldap-data/DB_CONFIG.example \
236 $RPM_BUILD_ROOT%{l_prefix}/var/openldap/openldap-data/DB_CONFIG
237 %endif
239 # post adjustment: enable and correct slapd.pid
240 %if "%{with_server}" == "yes"
241 %{l_shtool} subst \
242 -e 's;^\(pidfile\).*$;\1 %{l_prefix}/var/openldap/run/slapd.pid;' \
243 -e 's;^\(argsfile\).*$;\1 %{l_prefix}/var/openldap/run/slapd.args;' \
244 $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/slapd.conf
245 %endif
247 # post adjustment: remove OSSP fsl dependency from libtool files
248 %if "%{with_server}" == "yes"
249 %{l_shtool} subst \
250 -e 's;-lfsl *;;' \
251 $RPM_BUILD_ROOT%{l_prefix}/lib/*.la
252 %endif
254 # install run command script
255 %if "%{with_server}" == "yes"
256 %{l_shtool} mkdir -f -p -m 755 \
257 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
258 %{l_shtool} install -c -m 755 %{l_value -s -a} \
259 %{SOURCE rc.openldap} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
260 %endif
262 # install OSSP fsl configuration
263 %if "%{with_server}" == "yes"
264 %{l_shtool} mkdir -f -p -m 755 \
265 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
266 %{l_shtool} install -c -m 644 %{l_value -s -a} \
267 %{SOURCE fsl.openldap} \
268 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
269 %endif
271 # install pkg-config configuration
272 %{l_shtool} mkdir -f -p -m 755 \
273 $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
274 libs="-lldap -llber"
275 libdir="-L\${libdir}"
276 %if "%{with_sasl}" == "yes"
277 libs="$libs -lsasl2"
278 %endif
279 %if "%{with_pth}" == "yes"
280 libs="$libs -lpth"
281 libdir="$libdir -L\${libdir}/pth"
282 %endif
283 %{l_shtool} install -c -m 644 %{l_value -s -a} \
284 -e "s;@version@;%{version};" \
285 -e "s;@libs@;$libs;" \
286 -e "s;@libdir@;$libdir;" \
287 %{SOURCE openldap.pc} \
288 $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
290 # optionally remove server components
291 %if "%{with_server}" != "yes"
292 rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/schema
293 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/slapd.conf
294 rm -rf $RPM_BUILD_ROOT%{l_prefix}/sbin
295 rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/openldap
296 rm -f $RPM_BUILD_ROOT%{l_prefix}/include/slapi-plugin.h
297 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man5/slap*
298 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/slap*
299 %endif
301 # determine installation files
302 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
303 %{l_files_std} \
304 %if "%{with_server}" == "yes"
305 '%config %{l_prefix}/etc/fsl/fsl.openldap' \
306 '%config %{l_prefix}/etc/openldap/schema/*.schema' \
307 '%config %{l_prefix}/etc/openldap/schema/*.ldif' \
308 %endif
309 '%config %{l_prefix}/etc/openldap/*.conf'
311 %files -f files
313 %clean
315 %pre
316 %if "%{with_server}" == "yes"
317 # before upgrade, save status and stop service
318 [ $1 -eq 2 ] || exit 0
319 eval `%{l_rc} openldap status 2>/dev/null | tee %{l_tmpfile}`
320 %{l_rc} openldap stop 2>/dev/null
321 exit 0
322 %endif
324 %post
325 # after upgrade, restore status
326 %if "%{with_server}" == "yes"
327 [ $1 -eq 2 ] || exit 0
328 { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
329 [ ".$openldap_active" = .yes ] && %{l_rc} openldap start
330 exit 0
331 %endif
333 %preun
334 # before erase, stop service and remove log files
335 %if "%{with_server}" == "yes"
336 [ $1 -eq 0 ] || exit 0
337 %{l_rc} openldap stop 2>/dev/null
338 rm -f $RPM_INSTALL_PREFIX/var/openldap/openldap.log* >/dev/null 2>&1 || true
339 exit 0
340 %endif