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