Import Debian changes 0.69.0-2
[hcoop/debian/courier-authlib.git] / courier-authlib.spec.in
CommitLineData
d9898ee8 1#
0e333c05 2# Copyright 1998 - 2017 Double Precision, Inc. See COPYING for
d9898ee8 3# distribution information.
4
5# No dist tag from mock; detect mandrake, redhat, etc. the old fashioned way
6%if 0%{!?dist:1}
7%define courier_release %(test -e /etc/mandrake-release -o -e /etc/mandriva-release && release="mdk" ; if test $? != 0; then release="`rpm -q --queryformat='.rh%{VERSION}' redhat-release 2>/dev/null`" ; if test $? != 0 ; then release="`rpm -q --queryformat='.fc%{VERSION}' fedora-release 2>/dev/null`" ; if test $? != 0 ; then release="" ; fi ; fi ; fi ; echo "$release")
dd184caf 8%else
9%define courier_release %{nil}
d9898ee8 10%endif
11
b0322a85
CE
12%define using_systemd %(test -d /etc/systemd && echo 1 || echo 0)
13
d9898ee8 14################################################################################
15
16Name: courier-authlib
17Version: @VERSION@
18Release: 1%{?dist}%{?courier_release}
19Summary: Courier authentication library
20
21Group: System Environment/Daemons
b0322a85 22License: GPLv3
d9898ee8 23URL: http://www.courier-mta.org
24
25################################################################################
26
0e333c05 27Source: http://downloads.sourceforge.net/courier/%{name}-%{version}.tar.bz2
d9898ee8 28
29BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
30
31################################################################################
32
33BuildRequires: libtool
34BuildRequires: openldap-devel
b0322a85 35BuildRequires: mysql-devel zlib-devel sqlite-devel
d9898ee8 36BuildRequires: postgresql-devel
37BuildRequires: gdbm-devel
38BuildRequires: pam-devel
39BuildRequires: expect
40BuildRequires: gcc-c++
dd184caf 41BuildRequires: redhat-rpm-config
d50284c4 42BuildRequires: courier-unicode-devel
d9898ee8 43
44BuildRequires: %{_includedir}/ltdl.h
45
46%if 0%(rpm -q redhat-release >/dev/null 2>&1 || rpm -q fedora-release >/dev/null 2>&1 || exit 0; echo "1")
47BuildRequires: redhat-rpm-config
0e333c05 48BuildRequires: /usr/bin/ps
d9898ee8 49%endif
50
b0322a85 51%if %using_systemd
d50284c4
CE
52Requires(post): systemd
53Requires(preun): systemd
54Requires(postun): systemd
b0322a85 55%else
d9898ee8 56Requires(post): /sbin/chkconfig
57Requires(preun): /sbin/chkconfig
b0322a85 58%endif
ac40fd9e 59
0e333c05
CE
60%define need_perl_generators %(if rpm -q fedora-release >/dev/null 2>/dev/null; then echo "1"; exit 0; fi; echo "1"; exit 1)
61
62%if %need_perl_generators
63BuildRequires: perl-generators
64%endif
65
d9898ee8 66################################################################################
67
68%description
69The Courier authentication library provides authentication services for
70other Courier applications.
71
72################################################################################
73
74%package devel
75Summary: Development libraries for the Courier authentication library
76Group: Development/Libraries
77Requires: courier-authlib = 0:%{version}-%{release}
78
79%description devel
80This package contains the development libraries and files needed to compile
81Courier packages that use this authentication library. Install this
82package in order to build the rest of the Courier packages. After they are
83built and installed this package can be removed. Files in this package
84are not needed at runtime.
85
86################################################################################
87
88%package userdb
89
b0322a85 90Summary: Userdb support for the Courier authentication library
d9898ee8 91Group: System Environment/Daemons
92Requires: courier-authlib = 0:%{version}-%{release}
93
94%description userdb
95This package installs the userdb support for the Courier authentication
96library. Userdb is a simple way to manage virtual mail accounts using
97a GDBM-based database file.
98Install this package in order to be able to authenticate with userdb.
99
100################################################################################
101
102%package ldap
103
104Summary: LDAP support for the Courier authentication library
105Group: System Environment/Daemons
106Requires: courier-authlib = 0:%{version}-%{release}
107
108%description ldap
109This package installs LDAP support for the Courier authentication library.
110Install this package in order to be able to authenticate using LDAP.
111
112################################################################################
113
114%package mysql
115
116Summary: MySQL support for the Courier authentication library
117Group: System Environment/Daemons
118Requires: courier-authlib = 0:%{version}-%{release}
119
120%description mysql
121This package installs MySQL support for the Courier authentication library.
122Install this package in order to be able to authenticate using MySQL.
123
b0322a85
CE
124%package sqlite
125
126Summary: SQLite support for the Courier authentication library
127Group: System Environment/Daemons
128Requires: courier-authlib = 0:%{version}-%{release}
129
130%description sqlite
131This package installs SQLite support for the Courier authentication library.
132Install this package in order to be able to authenticate using an SQLite-based
133database file.
134
d9898ee8 135################################################################################
136
137%package pgsql
138
b0322a85 139Summary: PostgreSQL support for the Courier authentication library
d9898ee8 140Group: System Environment/Daemons
141Requires: courier-authlib = 0:%{version}-%{release}
142
143%description pgsql
144This package installs PostgreSQL support for the Courier authentication
145library.
146Install this package in order to be able to authenticate using PostgreSQL.
147
148################################################################################
149
150%package pipe
151
152Summary: External authentication module that communicates via pipes
153Group: System Environment/Daemons
154Requires: courier-authlib = 0:%{version}-%{release}
155
156%description pipe
157This package installs the authpipe module, which is a generic plugin
158that enables authentication requests to be serviced by an external
159program, then communicates through messages on stdin and stdout.
160
161################################################################################
162
163%prep
164%setup -q
b0322a85 165PATH=/usr/bin:$PATH %configure -C --with-redhat
d9898ee8 166
167%build
dd184caf 168%{__make} -s %{_smp_mflags}
d9898ee8 169
170%install
171rm -rf $RPM_BUILD_ROOT
172MAKEFLAGS= %{__make} -j 1 install DESTDIR=$RPM_BUILD_ROOT
173%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/courier-authlib/*.a
174%{__install} -m 555 sysconftool $RPM_BUILD_ROOT%{_libexecdir}/courier-authlib
d9898ee8 175
176./courierauthconfig --configfiles >configtmp
8d138742 177. ./configtmp
d9898ee8 178
8d138742
CE
179d=`pwd`
180cd $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon || exit 1
181$d/authmksock ./socket || exit 1
182cd $d || exit 1
d9898ee8 183touch $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/pid.lock || exit 1
184touch $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/pid || exit 1
185%{__chmod} 777 $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/socket || exit 1
186
187cat >configfiles.base <<EOF
188%defattr(-,$mailuser,$mailgroup,-)
189%{_sysconfdir}/authlib
190%{_libexecdir}/courier-authlib
191%dir %{_libdir}/courier-authlib
192%dir %attr(750,$mailuser,$mailgroup) %{_localstatedir}/spool/authdaemon
193EOF
194
195echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.mysql
b0322a85 196echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.sqlite
d9898ee8 197echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.ldap
198echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.pgsql
199echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.userdb
200echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.pipe
201echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.devel
202
203for f in $RPM_BUILD_ROOT%{_sbindir}/*
204do
205 fn=`basename $f`
206 case "$fn" in
207 *userdb*)
208 echo "%{_sbindir}/$fn" >>configfiles.userdb
209 ;;
210 *)
211 echo "%{_sbindir}/$fn" >>configfiles.base
212 ;;
213 esac
214done
215
216for f in $RPM_BUILD_ROOT%{_libdir}/courier-authlib/*
217do
218 fn=`basename $f`
b0322a85
CE
219
220 # Remove *.la for authentication modules, keep the ones
221 # for client libraries. Do this before we sort them into buckets,
222 # below.
223
224 case "$fn" in
225 *.la)
226 case "$fn" in
227 libcourierauth*)
228 ;;
229 *)
230 rm -f "$f"
231 ;;
232 esac
233 continue
234 ;;
235 esac
236
d9898ee8 237 case "$fn" in
238 libauthpipe*)
239 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.pipe
240 ;;
241 libauthldap*)
242 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
243 ;;
244 libauthmysql*)
245 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.mysql
246 ;;
b0322a85
CE
247 libauthsqlite*)
248 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.sqlite
249 ;;
d9898ee8 250 libauthpgsql*)
251 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.pgsql
252 ;;
253 libauthldap*)
254 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
255 ;;
256 libauthuserdb*)
257 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.userdb
258 ;;
259 *)
260 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.base
261 ;;
262 esac
263done
b0322a85
CE
264%if %using_systemd
265%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}
266%{__install} -m 555 courier-authlib.sysvinit $RPM_BUILD_ROOT%{_datadir}
267
268%{__mkdir_p} $RPM_BUILD_ROOT/lib/systemd/system
269%{__install} -m 644 courier-authlib.service $RPM_BUILD_ROOT/lib/systemd/system
270%else
d9898ee8 271%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
272%{__install} -m 555 courier-authlib.sysvinit \
b0322a85
CE
273 $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/courier-authlib
274%endif
d9898ee8 275
276%post
d9898ee8 277%{_libexecdir}/courier-authlib/sysconftool %{_sysconfdir}/authlib/*.dist >/dev/null
b0322a85
CE
278%if %using_systemd
279if test -f /etc/init.d/courier-authlib
280then
281# Upgrade to systemd
282
283 /sbin/chkconfig --del courier-authlib
284 /bin/systemctl stop courier-authlib.service || :
285fi
d50284c4 286%systemd_post courier-authlib.service
0e333c05
CE
287if [ $1 -eq 1 ]
288then
289 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
290fi
b0322a85 291%else
d9898ee8 292/sbin/chkconfig --del courier-authlib
293/sbin/chkconfig --add courier-authlib
b0322a85 294%endif
d9898ee8 295%preun
d9898ee8 296if test "$1" = "0"
297then
b0322a85 298%if %using_systemd
d50284c4 299%systemd_preun courier-authlib.service
b0322a85
CE
300%else
301 /sbin/chkconfig --del courier-authlib
302%endif
d9898ee8 303fi
304
b0322a85
CE
305%postun
306%if %using_systemd
0e333c05
CE
307if [ $1 -eq 0 ]
308then
309 /bin/systemctl daemon-reload
310fi
d50284c4 311%systemd_postun_with_restart courier-authlib.service
b0322a85
CE
312%endif
313
d9898ee8 314%clean
315rm -rf $RPM_BUILD_ROOT
316
317
318%files -f configfiles.base
319%defattr(-,root,root,-)
320%doc README README*html README.authmysql.myownquery README.ldap
8d138742 321%doc NEWS COPYING* AUTHORS ChangeLog
b0322a85
CE
322%if %using_systemd
323/lib/systemd/system/*
324%attr(755, bin, bin) %{_datadir}/courier-authlib.sysvinit
325%else
d9898ee8 326/etc/rc.d/init.d/*
b0322a85 327%endif
d9898ee8 328%ghost %attr(600, root, root) %{_localstatedir}/spool/authdaemon/pid.lock
329%ghost %attr(644, root, root) %{_localstatedir}/spool/authdaemon/pid
330%ghost %attr(-, root, root) %{_localstatedir}/spool/authdaemon/socket
331%{_mandir}/man1/*
332
333%files -f configfiles.userdb userdb
334%{_mandir}/man8/*userdb*
335
336%files -f configfiles.devel devel
337%defattr(-,root,root,-)
338%{_bindir}/courierauthconfig
339%{_includedir}/*
340%{_mandir}/man3/*
b0322a85 341%{_libdir}/courier-authlib/*.la
d9898ee8 342%doc authlib.html auth_*.html
343
344%files -f configfiles.ldap ldap
345%defattr(-,root,root,-)
8d138742 346%doc authldap.schema authldap.ldif
d9898ee8 347
348%files -f configfiles.mysql mysql
349
b0322a85
CE
350%files -f configfiles.sqlite sqlite
351
d9898ee8 352%files -f configfiles.pgsql pgsql
353
354%files -f configfiles.pipe pipe
355
356%changelog
357
358* Thu Sep 7 2006 Chris Petersen <rpm@forevermore.net> 0.58-2
359- Make the spec a little prettier
360- Replace BuildPreReq with BuildRequires
361- Remove period from summaries (rpmlint)
362- Fix release tag to use %{?dist} macro if it's present
363- Change distro-detection to use "rh" and "fc" for version detection, and add support for mandriva
364
365* Sun Oct 3 2004 Mr. Sam <sam@email-scan.com> 0.50-1
366- Initial build.