michael@174: ##
michael@174: ## openldap.spec -- OpenPKG RPM Package Specification
michael@174: ## Copyright (c) 2000-2009 OpenPKG Foundation e.V.
michael@174: ##
michael@174: ## Permission to use, copy, modify, and distribute this software for
michael@174: ## any purpose with or without fee is hereby granted, provided that
michael@174: ## the above copyright notice and this permission notice appear in all
michael@174: ## copies.
michael@174: ##
michael@174: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@174: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@174: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@174: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@174: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@174: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@174: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@174: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@174: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@174: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@174: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@174: ## SUCH DAMAGE.
michael@174: ##
michael@174:
michael@174: # package information
michael@174: Name: openldap
michael@174: Summary: Lightweight Directory Access Protocol (LDAP) Toolkit
michael@174: URL: http://www.openldap.org/
michael@174: Vendor: OpenLDAP Project
michael@174: Packager: OpenPKG Foundation e.V.
michael@174: Distribution: OpenPKG Community
michael@174: Class: BASE
michael@174: Group: LDAP
michael@174: License: GPL
michael@777: Version: 2.4.35
michael@587: Release: 20120800
michael@174:
michael@174: # package options
michael@174: %option with_server yes
michael@174: %option with_fsl yes
michael@174: %option with_crypt yes
michael@174: %option with_overlays yes
michael@587: %option with_pth yes
michael@587: %option with_pthreads no
michael@174: %option with_sasl no
michael@174: %option with_perl no
michael@174: %option with_odbc no
michael@174:
michael@174: # list of sources
michael@174: Source0: ftp://ftp.openldap.org/pub/openldap/openldap-release/openldap-%{version}.tgz
michael@174: Source1: rc.openldap
michael@174: Source2: fsl.openldap
michael@174: Source3: openldap.pc
michael@174: Patch0: openldap.patch
michael@174:
michael@174: # build information
michael@587: BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc
michael@587: PreReq: OpenPKG, openpkg >= 20100101
michael@174: BuildPreReq: openssl, db >= 4.5
michael@174: PreReq: openssl, db >= 4.5
michael@174: %if "%{with_server}" == "yes" && "%{with_fsl}" == "yes"
michael@174: BuildPreReq: fsl
michael@174: PreReq: fsl
michael@174: %endif
michael@174: %if "%{with_server}" == "yes" && "%{with_pthreads}" == "yes"
michael@174: BuildPreReq: db::with_pthreads = yes
michael@174: PreReq: db::with_pthreads = yes
michael@174: %endif
michael@174: %if "%{with_server}" == "yes" && "%{with_pth}" == "yes"
michael@174: BuildPreReq: pth
michael@174: PreReq: pth
michael@174: %endif
michael@174: %if "%{with_sasl}" == "yes"
michael@174: BuildPreReq: sasl
michael@174: PreReq: sasl
michael@174: %endif
michael@174: %if "%{with_server}" == "yes" && "%{with_odbc}" == "yes"
michael@174: BuildPreReq: ODBC
michael@174: PreReq: ODBC
michael@174: %endif
michael@174:
michael@174: %description
michael@174: OpenLDAP is an open source implementation of the Lightweight
michael@174: Directory Access Protocol (LDAP). The suite includes libraries
michael@586: implementing the LDAP protocol plus a stand alone LDAP server
michael@174: slapd(8).
michael@174:
michael@174: %track
michael@174: prog openldap = {
michael@174: version = %{version}
michael@174: url = ftp://ftp.openldap.org/pub/openldap/openldap-release/
michael@174: regex = openldap-(__VER__)\.tgz
michael@174: }
michael@174:
michael@174: %prep
michael@174: %setup -q
michael@174: %patch -p0
michael@174: %{l_shtool} subst \
michael@174: -e 's;-ldb-4\.[1-9];-ldb;g' \
michael@174: -e 's;-ldb-4-[1-9];-ldb;g' \
michael@174: -e 's;-ldb-4[1-9];-ldb;g' \
michael@174: -e 's;-ldb-4;-ldb;g' \
michael@174: configure
michael@777: ( cd servers/slapd/back-bdb/
michael@777: %{l_shtool} subst \
michael@777: -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \
michael@777: back-bdb.h init.c config.c dbcache.c dn2id.c idl.c
michael@777: ) || exit $?
michael@174:
michael@174: %build
michael@174: cp /dev/null config.cache
michael@174:
michael@174: # configuration: standard build flags
michael@174: export CC="%{l_cc}"
michael@174: export CFLAGS="%{l_cflags -O}"
michael@174: export CPPFLAGS="%{l_cppflags}"
michael@174: export LDFLAGS="%{l_ldflags}"
michael@174: export LIBS=""
michael@174: export ARGS=""
michael@174: ARGS="$ARGS --prefix=%{l_prefix}"
michael@380: ARGS="$ARGS --mandir=%{l_prefix}/man"
michael@380: ARGS="$ARGS --infodir=%{l_prefix}/info"
michael@174: ARGS="$ARGS --libexecdir=%{l_prefix}/libexec/openldap"
michael@174: ARGS="$ARGS --localstatedir=%{l_prefix}/var/openldap"
michael@174: ARGS="$ARGS --enable-syslog"
michael@174: ARGS="$ARGS --with-tls"
michael@174: ARGS="$ARGS --without-fetch"
michael@174: ARGS="$ARGS --disable-dynamic"
michael@174: ARGS="$ARGS --disable-shared"
michael@174: %if "%{with_server}" == "yes"
michael@174: ARGS="$ARGS --enable-slapd"
michael@174: ARGS="$ARGS --disable-modules"
michael@174: ARGS="$ARGS --enable-local"
michael@174: ARGS="$ARGS --enable-bdb"
michael@174: ARGS="$ARGS --enable-hdb"
michael@174: ARGS="$ARGS --enable-rewrite"
michael@174: ARGS="$ARGS --enable-ldap"
michael@174: ARGS="$ARGS --enable-meta"
michael@174: ARGS="$ARGS --enable-monitor"
michael@174: ARGS="$ARGS --enable-dnssrv"
michael@174: ARGS="$ARGS --enable-null"
michael@174: ARGS="$ARGS --enable-shell"
michael@587: ARGS="$ARGS --enable-proxycache"
michael@587: ARGS="$ARGS --disable-mdb"
michael@174: %else
michael@174: ARGS="$ARGS --disable-slapd"
michael@174: ARGS="$ARGS --disable-modules"
michael@174: %endif
michael@174:
michael@174: # configuration: force to use OSSP fsl
michael@174: %if "%{with_server}" == "yes"
michael@174: LDFLAGS="$LDFLAGS %{l_fsl_ldflags}"
michael@174: LIBS="$LIBS %{l_fsl_libs}"
michael@174: %endif
michael@174:
michael@174: # configuration: force to use GNU pth if enabled
michael@174: %if "%{with_server}" == "yes"
michael@174: %if "%{with_pth}" == "yes"
michael@174: CFLAGS="$CFLAGS `%{l_prefix}/bin/pth-config --cflags`"
michael@174: CPPFLAGS="$CPPFLAGS -I`%{l_prefix}/bin/pth-config --includedir`"
michael@174: LDFLAGS="$LDFLAGS `%{l_prefix}/bin/pth-config --ldflags`"
michael@174: LIBS="`%{l_prefix}/bin/pth-config --libs` $LIBS"
michael@174: ARGS="$ARGS --with-threads=pth"
michael@174: ( echo "ac_cv_header_sys_devpoll_h=no"
michael@174: echo "ac_cv_header_sys_epoll_h=no"
michael@174: ) >>config.cache
michael@174: %else
michael@174: %if "%{with_pthreads}" == "yes"
michael@174: ARGS="$ARGS --with-threads=posix"
michael@174: %else
michael@174: ARGS="$ARGS --with-threads=no"
michael@174: %endif
michael@174: %endif
michael@174: %endif
michael@174:
michael@174: # configuration: optional overlay support
michael@174: %if "%{with_server}" == "yes" && "%{with_overlays}" == "yes"
michael@174: ARGS="$ARGS --enable-overlays=yes"
michael@174: %endif
michael@174:
michael@174: # configuration: optional SASL support
michael@174: %if "%{with_sasl}" == "yes"
michael@174: ( echo "ac_cv_lib_sasl2_sasl_client_init=yes"
michael@174: ) >>config.cache
michael@174: CPPFLAGS="%{l_cppflags sasl} $CPPFLAGS"
michael@174: ARGS="$ARGS --with-cyrus-sasl --enable-spasswd"
michael@174: %else
michael@174: ARGS="$ARGS --without-cyrus-sasl --disable-spasswd"
michael@174: %endif
michael@174:
michael@174: # configuration: optional crypt(3) support
michael@174: %if "%{with_crypt}" == "yes"
michael@174: ARGS="$ARGS --enable-crypt"
michael@174: %endif
michael@174:
michael@174: # configuration: optional Perl support
michael@174: %if "%{with_server}" == "yes" && "%{with_perl}" == "yes"
michael@174: ARGS="$ARGS --enable-perl"
michael@174: %endif
michael@174:
michael@174: # configuration: optional ODBC-based RDBMS support
michael@174: %if "%{with_server}" == "yes" && "%{with_odbc}" == "yes"
michael@174: ARGS="$ARGS --enable-sql"
michael@174: %endif
michael@174:
michael@174: # configuration: special platform support
michael@174: case "%{l_platform -t}" in
michael@174: *-sunos* ) CFLAGS="$CFLAGS -D_AVL_H"; LIBS="$LIBS -lrt" ;;
michael@174: esac
michael@174:
michael@587: # configuration: use hard links and make sure our Berkeley DB is picked up first
michael@174: %{l_shtool} subst \
michael@174: -e 's;ln -s;ln;g' \
michael@174: -e 's;-ldb4[1-9];%{l_prefix}/lib/libdb.a;g' \
michael@174: -e 's;;"db.h";g' \
michael@174: configure
michael@174:
michael@174: # configuration
michael@174: ./configure --cache-file=./config.cache $ARGS
michael@174:
michael@174: # build toolkit
michael@587: %{l_make} %{l_mflags -O} depend
michael@587: %{l_make} %{l_mflags -O}
michael@174:
michael@174: %install
michael@174: # install toolkit
michael@174: %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
michael@174:
michael@174: # post adjustment: remove extra files
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*.default
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/*/*.default
michael@174:
michael@174: # post adjustment: move files
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/DB_CONFIG.example
michael@174: %if "%{with_server}" == "yes"
michael@174: mv $RPM_BUILD_ROOT%{l_prefix}/var/openldap/openldap-data/DB_CONFIG.example \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/var/openldap/openldap-data/DB_CONFIG
michael@174: %endif
michael@174:
michael@174: # post adjustment: enable and correct slapd.pid
michael@174: %if "%{with_server}" == "yes"
michael@174: %{l_shtool} subst \
michael@587: -e 's;^\(pidfile\).*$;\1 %{l_prefix}/var/openldap/run/slapd.pid;' \
michael@380: -e 's;^\(argsfile\).*$;\1 %{l_prefix}/var/openldap/run/slapd.args;' \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/slapd.conf
michael@174: %endif
michael@174:
michael@174: # post adjustment: remove OSSP fsl dependency from libtool files
michael@174: %if "%{with_server}" == "yes"
michael@174: %{l_shtool} subst \
michael@174: -e 's;-lfsl *;;' \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/lib/*.la
michael@174: %endif
michael@174:
michael@587: # install run command script
michael@174: %if "%{with_server}" == "yes"
michael@174: %{l_shtool} mkdir -f -p -m 755 \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
michael@174: %{l_shtool} install -c -m 755 %{l_value -s -a} \
michael@174: %{SOURCE rc.openldap} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
michael@174: %endif
michael@174:
michael@174: # install OSSP fsl configuration
michael@174: %if "%{with_server}" == "yes"
michael@174: %{l_shtool} mkdir -f -p -m 755 \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
michael@174: %{l_shtool} install -c -m 644 %{l_value -s -a} \
michael@174: %{SOURCE fsl.openldap} \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
michael@174: %endif
michael@174:
michael@174: # install pkg-config configuration
michael@174: %{l_shtool} mkdir -f -p -m 755 \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
michael@174: libs="-lldap -llber"
michael@587: libdir="-L\${libdir}"
michael@174: %if "%{with_sasl}" == "yes"
michael@174: libs="$libs -lsasl2"
michael@174: %endif
michael@587: %if "%{with_pth}" == "yes"
michael@587: libs="$libs -lpth"
michael@587: libdir="$libdir -L\${libdir}/pth"
michael@587: %endif
michael@174: %{l_shtool} install -c -m 644 %{l_value -s -a} \
michael@174: -e "s;@version@;%{version};" \
michael@174: -e "s;@libs@;$libs;" \
michael@587: -e "s;@libdir@;$libdir;" \
michael@174: %{SOURCE openldap.pc} \
michael@174: $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
michael@174:
michael@587: # optionally remove server components
michael@174: %if "%{with_server}" != "yes"
michael@174: rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/schema
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/openldap/slapd.conf
michael@174: rm -rf $RPM_BUILD_ROOT%{l_prefix}/sbin
michael@174: rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/openldap
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/include/slapi-plugin.h
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man5/slap*
michael@174: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/slap*
michael@174: %endif
michael@174:
michael@174: # determine installation files
michael@174: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
michael@174: %{l_files_std} \
michael@174: %if "%{with_server}" == "yes"
michael@174: '%config %{l_prefix}/etc/fsl/fsl.openldap' \
michael@174: '%config %{l_prefix}/etc/openldap/schema/*.schema' \
michael@174: '%config %{l_prefix}/etc/openldap/schema/*.ldif' \
michael@174: %endif
michael@174: '%config %{l_prefix}/etc/openldap/*.conf'
michael@174:
michael@174: %files -f files
michael@174:
michael@174: %clean
michael@174:
michael@174: %pre
michael@174: %if "%{with_server}" == "yes"
michael@174: # before upgrade, save status and stop service
michael@174: [ $1 -eq 2 ] || exit 0
michael@174: eval `%{l_rc} openldap status 2>/dev/null | tee %{l_tmpfile}`
michael@174: %{l_rc} openldap stop 2>/dev/null
michael@174: exit 0
michael@174: %endif
michael@174:
michael@174: %post
michael@174: # after upgrade, restore status
michael@174: %if "%{with_server}" == "yes"
michael@174: [ $1 -eq 2 ] || exit 0
michael@174: { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
michael@174: [ ".$openldap_active" = .yes ] && %{l_rc} openldap start
michael@174: exit 0
michael@174: %endif
michael@174:
michael@174: %preun
michael@174: # before erase, stop service and remove log files
michael@174: %if "%{with_server}" == "yes"
michael@174: [ $1 -eq 0 ] || exit 0
michael@174: %{l_rc} openldap stop 2>/dev/null
michael@174: rm -f $RPM_INSTALL_PREFIX/var/openldap/openldap.log* >/dev/null 2>&1 || true
michael@174: exit 0
michael@174: %endif
michael@174: