r17444: put pam and nss libs in samba-common on RHEL for compatibility with system...
[ira/wip.git] / packaging / RHEL / samba.spec.tmpl
1 %define initdir %{_sysconfdir}/rc.d/init.d
2 %define auth %(test -f /etc/pam.d/system-auth && echo /etc/pam.d/system-auth || echo)
3
4 Summary: Samba SMB client and server
5 Vendor: Samba Team
6 Packager: Samba Team <samba@samba.org>
7 Name:         samba
8 Version:      PVERSION
9 Release:      PRELEASEPRPMREV
10 Epoch:        0
11 License: GNU GPL version 2
12 Group: System Environment/Daemons
13 URL: http://www.samba.org/
14
15 Source: samba-%{version}.tar.bz2
16
17 # Don't depend on Net::LDAP
18 Source998: filter-requires-samba.sh
19 Source999: setup.tar.bz2
20
21 Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall
22 Prereq: fileutils sed /etc/init.d
23
24 Requires: pam >= 0.64 %{auth} 
25 Requires: samba-common = %{version}-%{release}
26 Requires: logrotate >= 3.4 initscripts >= 5.54-1
27 Provides: samba = %{version}
28
29 Prefix: /usr
30 BuildRoot: %{_tmppath}/%{name}-%{version}-root
31 BuildRequires: pam-devel, readline-devel, fileutils, libacl-devel, openldap-devel, krb5-devel, cups-devel
32
33 # Working around perl dependency problem from docs
34 %define __perl_requires %{SOURCE998}
35
36
37 %description
38 Samba is the protocol by which a lot of PC-related machines share
39 files, printers, and other information (such as lists of available
40 files and printers). The Windows NT, OS/2, and Linux operating systems
41 support this natively, and add-on packages can enable the same thing
42 for DOS, Windows, VMS, UNIX of all kinds, MVS, and more. This package
43 provides an SMB server that can be used to provide network services to
44 SMB (sometimes called "Lan Manager") clients. Samba uses NetBIOS over
45 TCP/IP (NetBT) protocols and does NOT need the NetBEUI (Microsoft Raw
46 NetBIOS frame) protocol.
47
48
49 #######################################################################
50 %package client
51 Summary: Samba (SMB) client programs.
52 Group: Applications/System
53 Requires: samba-common = %{version}-%{release}
54 Obsoletes: smbfs
55 Provides: samba-client = %{version}-%{release}
56
57 %description client
58 The samba-client package provides some SMB clients to compliment the
59 built-in SMB filesystem in Linux. These clients allow access of SMB
60 shares and printing to SMB printers.
61
62
63 #######################################################################
64 %package common
65 Summary: Files used by both Samba servers and clients.
66 Group: Applications/System
67 Provides: samba-common = %{version}-%{release}
68
69 %description common
70 Samba-common provides files necessary for both the server and client
71 packages of Samba.
72
73
74 #######################################################################
75 %package swat
76 Summary: The Samba SMB server configuration program.
77 Group: Applications/System
78 Requires: samba = %{version} xinetd
79 Provides: samba-swat = %{version}-%{release}
80
81 %description swat
82 The samba-swat package includes the new SWAT (Samba Web Administration
83 Tool), for remotely managing Samba's smb.conf file using your favorite
84 Web browser.
85
86
87 #######################################################################
88 %package doc
89 Summary:      Samba Documentation
90 Group:        Documentation/Other
91 Provides:     samba-doc = %{version}-%{release}
92 Prereq:       /usr/bin/find /bin/rm /usr/bin/xargs
93
94 %description doc
95 The samba-doc package includes the HTML versions of the Samba manpages
96 utilized by SWAT as well as the HTML and PDF version of "Using Samba",
97 "Samba By Example", and "The Official Samba HOWTO and Reference Guide".
98
99
100 #######################################################################
101
102 %prep
103 %setup -q
104
105 # setup the vendor files (init scripts, etc...)
106 %setup -T -D -a 999 -n samba-%{version} -q
107
108 %build
109
110 /bin/cp setup/filter-requires-samba.sh %{SOURCE998}
111
112 cd source
113 # RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
114
115 ## check for ccache
116 # ccache -h 2>&1 > /dev/null
117 #if [ $? -eq 0 ]; then
118 #       CC="ccache gcc"
119 #else
120         CC="gcc"
121 #fi 
122
123 ## always run autogen.sh
124 ./autogen.sh
125
126 CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
127         --prefix=%{_prefix} \
128         --localstatedir=/var \
129         --with-configdir=%{_sysconfdir}/samba \
130         --with-libdir=%{_libdir}/samba \
131         --with-lockdir=/var/lib/samba \
132         --with-logfilebase=/var/log/samba \
133         --with-mandir=%{_mandir} \
134         --with-piddir=/var/run \
135         --with-privatedir=%{_sysconfdir}/samba \
136         --with-sambabook=%{_datadir}/swat/using_samba \
137         --with-swatdir=%{_datadir}/swat \
138         --enable-cups \
139         --with-acl-support \
140         --with-ads \
141         --with-automount \
142         --with-fhs \
143         --with-pam_smbpass \
144         --with-libsmbclient \
145         --with-libsmbsharemodes \
146         --without-smbwrapper \
147         --with-pam \
148         --with-quotas \
149         --with-shared-modules=idmap_rid,idmap_ad \
150         --with-smbmount \
151         --with-syslog \
152         --with-utmp 
153
154 make showlayout
155
156 make CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"  proto 
157
158 ## check for gcc 3.4 or later
159 CC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
160 CC_MAJOR=`echo ${CC_VERSION} | cut -d. -f 1`
161 CC_MINOR=`echo ${CC_VERSION} | cut -d. -f 2`
162 if [ ${CC_MAJOR} -ge 3 ]; then
163         if [ ${CC_MAJOR} -gt 3 -o ${CC_MINOR} -ge 4 ]; then
164                 make pch
165         fi
166 fi
167
168
169 make CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE" %{?_smp_mflags} \
170         all modules pam_smbpass
171
172 ## build the cifs fs mount helper
173 cd client
174 gcc  -o mount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE mount.cifs.c
175 gcc  -o umount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE umount.cifs.c
176 cd ..
177
178 # Remove some permission bits to avoid to many dependencies
179 cd ..
180 find examples docs -type f | xargs -r chmod -x
181
182 %install
183 # Clean up in case there is trash left from a previous build
184 rm -rf $RPM_BUILD_ROOT
185
186 # Create the target build directory hierarchy
187 mkdir -p $RPM_BUILD_ROOT%{_datadir}/swat/{help,include,using_samba/{figs,gifsa}}
188 mkdir -p $RPM_BUILD_ROOT%{_includedir}
189 mkdir -p $RPM_BUILD_ROOT%{_initrddir}
190 mkdir -p $RPM_BUILD_ROOT{%{_libdir},%{_includedir}}
191 mkdir -p $RPM_BUILD_ROOT%{_libdir}/samba/{auth,charset,idmap,vfs,pdb}
192 mkdir -p $RPM_BUILD_ROOT/%{_lib}/security
193 mkdir -p $RPM_BUILD_ROOT%{_mandir}
194 mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin}
195 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
196 mkdir -p $RPM_BUILD_ROOT/sbin
197 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{logrotate.d,pam.d,samba}
198 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{pam.d,logrotate.d}
199 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
200 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{samba,sysconfig}
201 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d
202 mkdir -p $RPM_BUILD_ROOT/var/lib/samba/winbindd_privileged
203 mkdir -p $RPM_BUILD_ROOT/var/{log,run/winbindd,spool}/samba
204
205 cd source
206 make DESTDIR=$RPM_BUILD_ROOT \
207         install
208 cd ..
209
210 # pam_smbpass
211 cp source/bin/pam_smbpass.so $RPM_BUILD_ROOT/%{_lib}/security/pam_smbpass.so
212
213 # NSS & PAM winbind support
214 install -m 755 source/bin/pam_winbind.so $RPM_BUILD_ROOT/%{_lib}/security/pam_winbind.so
215 install -m 755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/%{_lib}/libnss_winbind.so
216 install -m 755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/%{_lib}/libnss_wins.so
217 ( cd $RPM_BUILD_ROOT/%{_lib};
218   ln -sf libnss_winbind.so  libnss_winbind.so.2;
219   ln -sf libnss_wins.so  libnss_wins.so.2 )
220
221 # make install puts libsmbclient.so in the wrong place on x86_64
222 rm -f $RPM_BUILD_ROOT/usr/lib*/samba/libsmbclient.so $RPM_BUILD_ROOT/usr/lib*/samba/libsmbclient.a || true
223 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{_libdir}/libsmbclient.so
224 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{_libdir}/libsmbclient.a
225 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{_includedir}
226 ln -s %{_libdir}/libsmbclient.so $RPM_BUILD_ROOT%{_libdir}/libsmbclient.so.0
227
228 # make install puts libmsrpc.so in the wrong place on x86_64
229 rm -f $RPM_BUILD_ROOT/usr/lib*/samba/libmsrpc.so $RPM_BUILD_ROOT/usr/lib*/samba/libmsrpc.a || true
230 install -m 755 source/bin/libmsrpc.so $RPM_BUILD_ROOT%{_libdir}/libmsrpc.so
231 install -m 755 source/bin/libmsrpc.a $RPM_BUILD_ROOT%{_libdir}/libmsrpc.a
232 install -m 644 source/include/libmsrpc.h $RPM_BUILD_ROOT%{_includedir}
233 rm -f $RPM_BUILD_ROOT%{_libdir}/samba/libmsrpc.*
234 ln -s /%{_libdir}/libmsrpc.so $RPM_BUILD_ROOT%{_libdir}/libmsrpc.so.0
235
236 # Install pam_smbpass.so
237 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/%{_lib}/security/pam_smbpass.so
238
239 ## cleanup
240 /bin/rm -rf $RPM_BUILD_ROOT/usr/lib*/samba/security
241
242 # we need a symlink for mount to recognise the smb and smbfs filesystem types
243 ln -sf %{_prefix}/bin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
244 ln -sf %{_prefix}/bin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
245 /bin/rm -f $RPM_BUILD_ROOT/mount.smbfs
246
247 # Install the miscellany
248 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT%{_sysconfdir}/samba/lmhosts
249
250 install -m644 setup/samba.log $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/samba
251 install -m644 setup/swat $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/swat
252 install -m644 setup/samba.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/samba
253 install -m755 setup/smb.init $RPM_BUILD_ROOT%{initdir}/smb
254 install -m755 setup/winbind.init $RPM_BUILD_ROOT%{initdir}/winbind
255 install -m644 setup/samba.pamd $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/samba
256 install -m755 setup/smbprint $RPM_BUILD_ROOT%{_bindir}
257 install -m644 setup/smbusers $RPM_BUILD_ROOT%{_sysconfdir}/samba/smbusers
258 install -m644 setup/smb.conf $RPM_BUILD_ROOT%{_sysconfdir}/samba/smb.conf
259 install -m755 source/client/mount.cifs $RPM_BUILD_ROOT/sbin/mount.cifs
260 install -m755 source/client/umount.cifs $RPM_BUILD_ROOT/sbin/umount.cifs
261 install -m755 source/script/mksmbpasswd.sh $RPM_BUILD_ROOT%{_bindir}
262
263 /bin/rm $RPM_BUILD_ROOT%{_sbindir}/*mount.cifs
264
265 ln -s ../..%{initdir}/smb  $RPM_BUILD_ROOT%{_sbindir}/samba
266 ln -s ../..%{initdir}/winbind  $RPM_BUILD_ROOT%{_sbindir}/winbind
267
268 # Remove "*.old" files
269 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
270
271 ## don't duplicate the docs.  These are installed by/with SWAT
272 rm -rf docs/htmldocs
273 rm -rf docs/manpages
274 ( cd docs; ln -s %{_prefix}/share/swat/help htmldocs )
275
276 ##
277 ## Clean out man pages for tools not installed here
278 ##
279 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
280 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
281 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/vfstest.1*
282
283
284 %clean
285 rm -rf $RPM_BUILD_ROOT
286
287 %post
288 ## deal with an upgrade from a broken 3.0.21b RPM
289 if [ "$1" -eq "2" ]; then
290         if [ -d /var/cache/samba ]; then
291                 for file in `ls /var/cache/samba/*tdb`; do
292                         /bin/cp -up $file /var/lib/samba/`basename $file`
293                 done
294                 mkdir -p /var/lib/samba/eventlog
295                 for file in `ls /var/cache/samba/eventlog/*tdb`; do
296                         /bin/cp -up $file /var/lib/samba/eventlog/`basename $file`
297                 done
298                 /bin/mv /var/cache/samba /var/cache/samba.moved
299         fi
300 fi
301
302 %preun
303 if [ $1 = 0 ] ; then
304     /sbin/chkconfig --del smb
305     /sbin/chkconfig --del winbind
306     # rm -rf /var/log/samba/* /var/lib/samba/*
307     /sbin/service smb stop >/dev/null 2>&1
308 fi
309 exit 0
310
311 %postun
312 if [ "$1" -ge "1" ]; then
313         %{initdir}/smb restart >/dev/null 2>&1
314 fi      
315
316
317 %post swat
318 # Add swat entry to /etc/services if not already there.
319 if [ ! "`grep ^\s**swat /etc/services`" ]; then
320         echo 'swat        901/tcp     # Add swat service used via inetd' >> /etc/services
321 fi
322
323 %post common
324 /sbin/ldconfig
325
326 %postun common 
327 /sbin/ldconfig
328
329 #######################################################################
330 ## Files section                                                     ##
331 #######################################################################
332
333 %files
334 %defattr(-,root,root)
335
336 %config(noreplace) %{_sysconfdir}/sysconfig/samba
337 %config(noreplace) %{_sysconfdir}/samba/smbusers
338 %attr(755,root,root) %config %{initdir}/smb
339 %attr(755,root,root) %config %{initdir}/winbind
340 %config(noreplace) %{_sysconfdir}/logrotate.d/samba
341 %config(noreplace) %{_sysconfdir}/pam.d/samba
342
343 %attr(0755,root,root) %dir /var/log/samba
344 %attr(0755,root,root) %dir /var/lib/samba
345 %attr(1777,root,root) %dir /var/spool/samba
346
347 %{_sbindir}/samba
348 %{_sbindir}/winbind
349
350 %{_sbindir}/smbd
351 %{_sbindir}/nmbd
352 %{_sbindir}/winbindd
353
354 %{_bindir}/mksmbpasswd.sh
355 %{_bindir}/smbcontrol
356 %{_bindir}/smbstatus
357 %{_bindir}/tdbbackup
358 %{_bindir}/tdbtool
359 %{_bindir}/tdbdump
360 %{_bindir}/wbinfo
361 %{_bindir}/ntlm_auth
362 %{_bindir}/pdbedit
363 %{_bindir}/eventlogadm
364
365 %{_libdir}/samba/idmap/*.so
366 %{_libdir}/samba/vfs/*.so
367 %{_libdir}/samba/auth/*.so
368
369 %{_mandir}/man1/smbcontrol.1*
370 %{_mandir}/man1/smbstatus.1*
371 %{_mandir}/man1/vfstest.1*
372 %{_mandir}/man5/smbpasswd.5*
373 %{_mandir}/man7/samba.7*
374 %{_mandir}/man8/nmbd.8*
375 %{_mandir}/man8/pdbedit.8*
376 %{_mandir}/man8/smbd.8*
377 %{_mandir}/man8/tdbbackup.8*
378 %{_mandir}/man8/tdbdump.8*
379 %{_mandir}/man8/winbindd.8*
380 %{_mandir}/man1/ntlm_auth.1*
381 %{_mandir}/man1/wbinfo.1*
382
383
384 ##########
385
386 %files doc
387 %defattr(-,root,root)
388 %doc README COPYING Manifest 
389 %doc WHATSNEW.txt Roadmap
390 %doc docs
391 %doc examples/autofs examples/LDAP examples/libsmbclient examples/misc examples/printer-accounting
392 %doc examples/printing
393 %doc %{_datadir}/swat/help
394 %doc %{_datadir}/swat/using_samba
395
396 ##########
397
398 %files swat
399 %defattr(-,root,root)
400 %config(noreplace) %{_sysconfdir}/xinetd.d/swat
401 %dir %{_datadir}/swat
402 %{_datadir}/swat/include
403 %{_datadir}/swat/images
404 %{_datadir}/swat/lang
405 %{_sbindir}/swat
406 %{_mandir}/man8/swat.8*
407
408 ##########
409
410 %files client
411 %defattr(-,root,root)
412 /sbin/mount.smb
413 /sbin/mount.smbfs
414 /sbin/mount.cifs
415 /sbin/umount.cifs
416
417 %{_bindir}/rpcclient
418 %{_bindir}/smbcacls
419 %{_bindir}/smbmount
420 %{_bindir}/smbmnt
421 %{_bindir}/smbumount
422 %{_bindir}/findsmb
423 %{_bindir}/smbcquotas
424 %{_bindir}/nmblookup
425 %{_bindir}/smbget
426 %{_bindir}/smbclient
427 %{_bindir}/smbprint
428 %{_bindir}/smbspool
429 %{_bindir}/smbtar
430 %{_bindir}/net
431 %{_bindir}/smbtree
432
433 %{_mandir}/man8/smbmnt.8*
434 %{_mandir}/man8/smbmount.8*
435 %{_mandir}/man8/smbumount.8*
436 %{_mandir}/man8/mount.cifs.8.*
437 %{_mandir}/man8/umount.cifs.8.*
438 %{_mandir}/man8/smbspool.8*
439 %{_mandir}/man1/smbget.1*
440 %{_mandir}/man5/smbgetrc.5*
441 %{_mandir}/man1/findsmb.1*
442 %{_mandir}/man1/nmblookup.1*
443 %{_mandir}/man1/rpcclient.1*
444 %{_mandir}/man1/smbcacls.1*
445 %{_mandir}/man1/smbclient.1*
446 %{_mandir}/man1/smbtar.1*
447 %{_mandir}/man1/smbtree.1*
448 %{_mandir}/man8/net.8*
449 %{_mandir}/man1/smbcquotas.1*
450
451 ##########
452
453 %files common
454 %defattr(-,root,root)
455 %dir %{_sysconfdir}/samba
456 %config(noreplace) %{_sysconfdir}/samba/smb.conf
457 %config(noreplace) %{_sysconfdir}/samba/lmhosts
458
459 %attr(755,root,root) /%{_lib}/libnss_wins.so*
460 %attr(755,root,root) /%{_lib}/libnss_winbind.so*
461 %attr(755,root,root) /%{_lib}/security/pam_winbind.so
462 %attr(755,root,root) /%{_lib}/security/pam_smbpass.so
463
464 %{_includedir}/libsmbclient.h
465 %{_libdir}/libsmbclient.a
466 %{_libdir}/libsmbclient.so*
467 %{_includedir}/libmsrpc.h
468 %{_libdir}/libmsrpc.a
469 %{_libdir}/libmsrpc.so*
470
471 %{_libdir}/samba/*.dat
472 %{_libdir}/samba/*.msg
473 %{_libdir}/samba/charset/*.so
474
475 %{_bindir}/testparm
476 %{_bindir}/smbpasswd
477 %{_bindir}/profiles
478
479 %{_mandir}/man1/profiles.1*
480 %{_mandir}/man1/testparm.1*
481 %{_mandir}/man5/smb.conf.5*
482 %{_mandir}/man5/lmhosts.5*
483 %{_mandir}/man8/smbpasswd.8*
484 %{_mandir}/man7/libsmbclient.7*
485 %{_mandir}/man7/pam_winbind.7*
486
487 %changelog
488 * Fri Jan 16 2004 Gerald (Jerry) Carter <jerry@samba,org>
489 - Removed ChangeLog entries since they are kept in CVS
490
491
492