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