1 |
|
2 |
%global pkgname dirsrv |
3 |
# for a pre-release, define the prerel field e.g. .a1 .rc2 - comment out for official release |
4 |
# also remove the space between % and global - this space is needed because |
5 |
# fedpkg verrel stupidly ignores comment lines |
6 |
#% global prerel .rc3 |
7 |
# also need the relprefix field for a pre-release e.g. .0 - also comment out for official release |
8 |
#% global relprefix 0. |
9 |
|
10 |
%global use_openldap 1 |
11 |
%global use_db4 0 |
12 |
# If perl-Socket-2.000 or newer is available, set 0 to use_Socket6. |
13 |
%global use_Socket6 0 |
14 |
|
15 |
# (cg) NB the --with-tmpfiles_d argument below is for user generated config files |
16 |
# created via DSCreate.pm script - i.e. it should be the /etc/ path, NOT %_tmpfilesdir |
17 |
|
18 |
# Mageia 3 and later uses tmpfiles.d |
19 |
# otherwise, comment this out |
20 |
%{!?with_tmpfiles_d: %global with_tmpfiles_d %{_sysconfdir}/tmpfiles.d} |
21 |
|
22 |
# systemd support |
23 |
%global groupname %{pkgname}.target |
24 |
|
25 |
Summary: 389 Directory Server (base) |
26 |
Name: 389-ds-base |
27 |
Version: 1.3.0.5 |
28 |
%define subrel 1 |
29 |
Release: %mkrel 2 |
30 |
License: GPLv2 with exceptions |
31 |
URL: http://port389.org/ |
32 |
Group: System/Servers |
33 |
Requires: %{name}-libs = %{version}-%{release} |
34 |
Provides: ldif2ldbm |
35 |
|
36 |
BuildRequires: nspr-devel |
37 |
BuildRequires: nss-devel |
38 |
BuildRequires: krb5-devel |
39 |
BuildRequires: svrcore-devel |
40 |
%if %{use_openldap} |
41 |
BuildRequires: openldap-devel |
42 |
%else |
43 |
BuildRequires: mozldap-devel |
44 |
%endif |
45 |
%if %{use_db4} |
46 |
BuildRequires: db4-devel |
47 |
%else |
48 |
BuildRequires: db-devel |
49 |
%endif |
50 |
BuildRequires: libsasl-devel |
51 |
BuildRequires: icu |
52 |
BuildRequires: libicu-devel |
53 |
BuildRequires: pcre-devel |
54 |
BuildRequires: gcc-c++ |
55 |
# The following are needed to build the snmp ldap-agent |
56 |
BuildRequires: net-snmp-devel |
57 |
BuildRequires: bzip2-devel |
58 |
BuildRequires: zlib-devel |
59 |
BuildRequires: openssl-devel |
60 |
BuildRequires: tcp_wrappers |
61 |
# the following is for the pam passthru auth plug-in |
62 |
BuildRequires: pam-devel |
63 |
BuildRequires: systemd-units |
64 |
|
65 |
# this is needed for using semanage from our setup scripts |
66 |
Requires: policycoreutils-python |
67 |
|
68 |
Requires(post): rpm-helper >= %{rpmhelper_required_version} |
69 |
Requires(preun): rpm-helper >= %{rpmhelper_required_version} |
70 |
|
71 |
# the following are needed for some of our scripts |
72 |
%if %{use_openldap} |
73 |
Requires: openldap-clients |
74 |
%else |
75 |
Requires: mozldap-tools |
76 |
%endif |
77 |
# use_openldap assumes perl-Mozilla-LDAP is built with openldap support |
78 |
Requires: perl-Mozilla-LDAP |
79 |
|
80 |
# this is needed to setup SSL if you are not using the |
81 |
# administration server package |
82 |
Requires: nss |
83 |
|
84 |
# these are not found by the auto-dependency method |
85 |
# they are required to support the mandatory LDAP SASL mechs |
86 |
Requires: sasl-plug-gssapi |
87 |
Requires: sasl-plug-digestmd5 |
88 |
|
89 |
# this is needed for verify-db.pl |
90 |
%if %{use_db4} |
91 |
Requires: db4-utils |
92 |
%else |
93 |
Requires: db5-utils |
94 |
%endif |
95 |
|
96 |
# This picks up libperl.so as a Requires, so we add this versioned one |
97 |
# We don't pack this virtual package in Mageia and it doesn't look it's needed anymore in mdern perl. |
98 |
# Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) |
99 |
|
100 |
# for the init script |
101 |
Requires(post): systemd-units |
102 |
Requires(preun): systemd-units |
103 |
Requires(postun): systemd-units |
104 |
|
105 |
# for setup-ds.pl to support ipv6 |
106 |
%if %{use_Socket6} |
107 |
Requires: perl-Socket6 |
108 |
%else |
109 |
Requires: perl-Socket |
110 |
%endif |
111 |
Requires: perl-NetAddr-IP |
112 |
|
113 |
Source0: http://port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2 |
114 |
# 389-ds-git.sh should be used to generate the source tarball from git |
115 |
Source1: %{name}-git.sh |
116 |
Source2: %{name}-devel.README |
117 |
Patch0: mageia-nogroup.patch |
118 |
|
119 |
%description |
120 |
389 Directory Server is an LDAPv3 compliant server. The base package includes |
121 |
the LDAP server and command line utilities for server administration. |
122 |
|
123 |
%package libs |
124 |
Summary: Core libraries for 389 Directory Server |
125 |
Group: System/Servers |
126 |
BuildRequires: nspr-devel |
127 |
BuildRequires: nss-devel |
128 |
BuildRequires: svrcore-devel |
129 |
%if %{use_openldap} |
130 |
BuildRequires: openldap-devel |
131 |
%else |
132 |
BuildRequires: mozldap-devel |
133 |
%endif |
134 |
%if %{use_db4} |
135 |
BuildRequires: db4-devel |
136 |
%else |
137 |
BuildRequires: db-devel |
138 |
%endif |
139 |
BuildRequires: libsasl-devel |
140 |
BuildRequires: libicu-devel |
141 |
BuildRequires: pcre-devel |
142 |
|
143 |
%description libs |
144 |
Core libraries for the 389 Directory Server base package. These libraries |
145 |
are used by the main package and the -devel package. This allows the -devel |
146 |
package to be installed with just the -libs package and without the main package. |
147 |
|
148 |
%package devel |
149 |
Summary: Development libraries for 389 Directory Server |
150 |
Group: System/Libraries |
151 |
Requires: %{name}-libs = %{version}-%{release} |
152 |
Requires: pkgconfig |
153 |
Requires: nspr-devel |
154 |
Requires: nss-devel |
155 |
Requires: svrcore-devel |
156 |
%if %{use_openldap} |
157 |
Requires: openldap-devel |
158 |
%else |
159 |
Requires: mozldap-devel |
160 |
%endif |
161 |
|
162 |
%description devel |
163 |
Development Libraries and headers for the 389 Directory Server base package. |
164 |
|
165 |
%prep |
166 |
%setup -q -n %{name}-%{version}%{?prerel} |
167 |
cp %{SOURCE2} README.devel |
168 |
%patch0 -p1 -b .mageia-nogroup |
169 |
|
170 |
%build |
171 |
|
172 |
%if %{use_openldap} |
173 |
OPENLDAP_FLAG="--with-openldap" |
174 |
%endif |
175 |
%{?with_tmpfiles_d: TMPFILES_FLAG="--with-tmpfiles-d=%{with_tmpfiles_d}"} |
176 |
# hack hack hack https://bugzilla.redhat.com/show_bug.cgi?id=833529 |
177 |
NSSARGS="--with-svrcore-inc=%{_includedir} --with-svrcore-lib=%{_libdir} --with-nss-lib=%{_libdir} --with-nss-inc=%{_includedir}/nss" |
178 |
%configure2_5x --enable-autobind \ |
179 |
--with-selinux $OPENLDAP_FLAG $TMPFILES_FLAG \ |
180 |
--with-systemdsystemunitdir=%{_unitdir} \ |
181 |
--with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \ |
182 |
--with-systemdgroupname=%{groupname} $NSSARGS |
183 |
|
184 |
# Generate symbolic info for debuggers |
185 |
export XCFLAGS=$RPM_OPT_FLAGS |
186 |
|
187 |
%ifarch x86_64 |
188 |
export USE_64=1 |
189 |
%endif |
190 |
|
191 |
|
192 |
%make |
193 |
|
194 |
|
195 |
%install |
196 |
make DESTDIR="%{buildroot}" install |
197 |
|
198 |
mkdir -p %{buildroot}/var/log/%{pkgname} |
199 |
mkdir -p %{buildroot}/var/lib/%{pkgname} |
200 |
mkdir -p %{buildroot}/var/lock/%{pkgname} |
201 |
|
202 |
# for systemd |
203 |
mkdir -p %{buildroot}%{_sysconfdir}/systemd/system/%{groupname}.wants |
204 |
|
205 |
#remove libtool and static libs |
206 |
rm -f %{buildroot}%{_libdir}/%{pkgname}/*.a |
207 |
rm -f %{buildroot}%{_libdir}/%{pkgname}/*.la |
208 |
rm -f %{buildroot}%{_libdir}/%{pkgname}/plugins/*.a |
209 |
rm -f %{buildroot}%{_libdir}/%{pkgname}/plugins/*.la |
210 |
|
211 |
# make sure perl scripts have a proper shebang |
212 |
sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' %{buildroot}%{_datadir}/%{pkgname}/script-templates/template-*.pl |
213 |
|
214 |
%post |
215 |
output=/dev/null |
216 |
%_post_service %{pkgname}-snmp |
217 |
# reload to pick up any changes to systemd files |
218 |
/bin/systemctl daemon-reload >/dev/null 2>&1 || : |
219 |
# reload to pick up any shared lib changes |
220 |
/sbin/ldconfig |
221 |
# restart the snmp subagent if needed |
222 |
/bin/systemctl try-restart %{pkgname}-snmp.service > $output 2>&1 || : |
223 |
# find all instances |
224 |
instances="" # instances that require a restart after upgrade |
225 |
ninst=0 # number of instances found in total |
226 |
if [ -n "$DEBUGPOSTTRANS" ] ; then |
227 |
output=$DEBUGPOSTTRANS |
228 |
fi |
229 |
echo looking for services in %{_sysconfdir}/systemd/system/%{groupname}.wants/* > $output 2>&1 || : |
230 |
for service in %{_sysconfdir}/systemd/system/%{groupname}.wants/* ; do |
231 |
if [ ! -f "$service" ] ; then continue ; fi # in case nothing matches |
232 |
inst=`echo $service | sed -e 's,%{_sysconfdir}/systemd/system/%{groupname}.wants/,,'` |
233 |
echo found instance $inst - getting status > $output 2>&1 || : |
234 |
if /bin/systemctl -q is-active $inst ; then |
235 |
echo instance $inst is running > $output 2>&1 || : |
236 |
instances="$instances $inst" |
237 |
else |
238 |
echo instance $inst is not running > $output 2>&1 || : |
239 |
fi |
240 |
ninst=`expr $ninst + 1` |
241 |
done |
242 |
if [ $ninst -eq 0 ] ; then |
243 |
echo no instances to upgrade > $output 2>&1 || : |
244 |
exit 0 # have no instances to upgrade - just skip the rest |
245 |
fi |
246 |
# shutdown all instances |
247 |
echo shutting down all instances . . . > $output 2>&1 || : |
248 |
/bin/systemctl stop %{groupname} > $output 2>&1 || : |
249 |
echo remove pid files . . . > $output 2>&1 || : |
250 |
/bin/rm -f /var/run/%{pkgname}*.pid /var/run/%{pkgname}*.startpid |
251 |
# do the upgrade |
252 |
echo upgrading instances . . . > $output 2>&1 || : |
253 |
%{_sbindir}/setup-ds.pl -l $output -u -s General.UpdateMode=offline > $output 2>&1 || : |
254 |
# restart instances that require it |
255 |
for inst in $instances ; do |
256 |
echo restarting instance $inst > $output 2>&1 || : |
257 |
/bin/systemctl start $inst > $output 2>&1 || : |
258 |
done |
259 |
exit 0 |
260 |
|
261 |
%preun |
262 |
if [ $1 -eq 0 ]; then # Final removal |
263 |
# Package removal, not upgrade |
264 |
%systemd_preun %{pkgname}-snmp.service %{groupname} |
265 |
# remove instance specific service files/links |
266 |
rm -rf %{_sysconfdir}/systemd/system/%{groupname}.wants/* > /dev/null 2>&1 || : |
267 |
fi |
268 |
|
269 |
%postun |
270 |
/sbin/ldconfig |
271 |
if [ $1 = 0 ]; then # Final removal |
272 |
rm -rf /var/run/%{pkgname} |
273 |
fi |
274 |
|
275 |
%files |
276 |
%doc LICENSE EXCEPTION LICENSE.GPLv2 |
277 |
%dir %{_sysconfdir}/%{pkgname} |
278 |
%dir %{_sysconfdir}/%{pkgname}/schema |
279 |
%config(noreplace)%{_sysconfdir}/%{pkgname}/schema/*.ldif |
280 |
%dir %{_sysconfdir}/%{pkgname}/config |
281 |
%dir %{_sysconfdir}/systemd/system/%{groupname}.wants |
282 |
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/slapd-collations.conf |
283 |
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/certmap.conf |
284 |
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/ldap-agent.conf |
285 |
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/template-initconfig |
286 |
%config(noreplace)%{_sysconfdir}/sysconfig/%{pkgname} |
287 |
%config(noreplace)%{_sysconfdir}/sysconfig/%{pkgname}.systemd |
288 |
%{_datadir}/%{pkgname} |
289 |
%{_unitdir} |
290 |
%{_bindir}/* |
291 |
%{_sbindir}/* |
292 |
%{_libdir}/%{pkgname}/libns-dshttpd.so* |
293 |
%{_libdir}/%{pkgname}/perl |
294 |
%{_libdir}/%{pkgname}/plugins/*.so |
295 |
%dir %{_localstatedir}/lib/%{pkgname} |
296 |
%dir %{_logdir}/%{pkgname} |
297 |
%{_mandir}/man1/* |
298 |
%{_mandir}/man8/* |
299 |
|
300 |
%files devel |
301 |
%doc LICENSE EXCEPTION LICENSE.GPLv2 README.devel |
302 |
%{_includedir}/%{pkgname} |
303 |
%{_libdir}/%{pkgname}/libslapd.so |
304 |
%{_libdir}/pkgconfig/* |
305 |
|
306 |
%files libs |
307 |
%doc LICENSE EXCEPTION LICENSE.GPLv2 README.devel |
308 |
%{_libdir}/%{pkgname}/libslapd.so.* |