janitor duty (merges from 3.0) and cleanup compiler warning on SuSE 9 in the end...
[gd/samba/.git] / packaging / RedHat / samba.spec.tmpl
1 ## grab the major and minor version of rpm 
2 %define rpm_version `rpm --version | awk '{print $3}' | awk -F. '{print $1$2}'`
3
4 Summary: Samba SMB client and server
5 Vendor: Samba Team
6 Name: samba
7 Version: PVERSION
8 Release: PRELEASE
9 License: GNU GPL version 2
10 Group: Networking
11 Source: http://download.samba.org/samba/ftp/samba-%{version}.tar.bz2
12
13 # Don't depend on Net::LDAP
14 # one filter for RH 8 and one for 9
15 Source998: filter-requires-samba_rh8.sh
16 Source999: filter-requires-samba_rh9.sh
17
18 Packager: Gerald Carter [Samba-Team] <jerry@samba.org>
19 Requires: pam >= 0.72 kernel >= 2.2.1 glibc >= 2.1.2
20 Prereq: chkconfig fileutils /sbin/ldconfig
21 Provides: samba = %{version}
22 Obsoletes: samba-common, samba-client, samba-swat
23 BuildRoot: %{_tmppath}/%{name}-%{version}-root
24 Prefix: /usr
25
26 %description
27 Samba provides an SMB/CIFS server which can be used to provide
28 network file and print services to SMB/CIFS clients, including 
29 various versions of MS Windows, OS/2, and other Linux machines. 
30 Samba also provides some SMB clients, which complement the 
31 built-in SMB filesystem in Linux. Samba uses NetBIOS over TCP/IP 
32 (NetBT) protocols and does NOT need NetBEUI (Microsoft Raw NetBIOS 
33 frame) protocol.
34
35 Samba 3.0 also introduces UNICODE support and kerberos/ldap
36 integration as a member server in a Windows 2000 domain.
37
38 Please refer to the WHATSNEW.txt document for fixup information.
39 docs directory for implementation details.
40
41 %changelog
42 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
43   - removed change log entries since history
44     is being maintained in CVS
45
46 %prep
47 %setup
48
49 %build
50
51 # Working around perl dependency problem from docs
52 # Only > RH 8.0 seems to care here
53
54 echo "rpm_version == %{rpm_version}"
55 if [ "%{rpm_version}" == "42" ]; then
56    %define __perl_requires %{SOURCE999}
57    echo "%{__perl_requires}"
58 elif [ "%{rpm_version}" == "41" ]; then
59    %define __find_requires %{SOURCE998}
60    echo "%{__find_requires}"
61 fi
62
63 ## Build main Samba source
64 cd source
65
66 %ifarch ia64
67 libtoolize --copy --force     # get it to recognize IA-64
68 autoheader
69 autoconf
70 EXTRA="-D_LARGEFILE64_SOURCE"
71 %endif
72
73 ## Get number of cpu's, default for 1 cpu on error 
74 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
75 if [ $NUMCPU -eq 0 ]; then
76         NUMCPU=1;
77 fi 
78
79 ## run autogen if missing the configure script
80 if [ ! -f "configure" ]; then
81         ./autogen.sh
82 fi
83
84 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
85         --prefix=%{prefix} \
86         --localstatedir=/var \
87         --with-configdir=/etc/samba \
88         --with-privatedir=/etc/samba \
89         --with-fhs \
90         --with-quotas \
91         --with-smbmount \
92         --with-pam \
93         --with-pam_smbpass \
94         --with-syslog \
95         --with-utmp \
96         --with-sambabook=%{prefix}/share/swat/using_samba \
97         --with-swatdir=%{prefix}/share/swat \
98         --with-libsmbclient 
99 make -j${NUMCPU} proto
100 make -j${NUMCPU} all nsswitch/libnss_wins.so 
101 make -j${NUMCPU} debug2html
102
103 # Remove some permission bits to avoid to many dependencies
104 find examples docs -type f | xargs -r chmod -x
105
106 %install
107 rm -rf $RPM_BUILD_ROOT
108 mkdir -p $RPM_BUILD_ROOT
109 mkdir -p $RPM_BUILD_ROOT/sbin
110 mkdir -p $RPM_BUILD_ROOT/etc/samba
111 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
112 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
113 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
114 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{images,help,include,using_samba}
115 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
116 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
117 mkdir -p $RPM_BUILD_ROOT/var/lib/samba
118 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
119 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
120 mkdir -p $RPM_BUILD_ROOT/lib/security
121 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
122 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
123
124 # Install standard binary files
125 for i in nmblookup smbclient smbpasswd smbstatus testparm testprns \
126         rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt net \
127         smbcacls pdbedit tdbbackup smbtree ntlm_auth smbcquotas
128 do
129         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/bin
130 done
131
132 for i in mksmbpasswd.sh smbtar findsmb
133 do
134         install -m755 source/script/$i $RPM_BUILD_ROOT%{prefix}/bin
135 done
136
137 # Install secure binary files
138 for i in smbd nmbd swat smbmount smbumount debug2html winbindd 
139 do
140         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/sbin
141 done
142
143 # we need a symlink for mount to recognise the smb and smbfs filesystem types
144 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
145 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
146
147 # This allows us to get away without duplicating code that 
148 #  sombody else can maintain for us.  
149 cd source
150 make DESTDIR=$RPM_BUILD_ROOT \
151         BASEDIR=/usr \
152         CONFIGDIR=/etc/samba \
153         LIBDIR=%{prefix}/lib/samba \
154         VARDIR=/var \
155         SBINDIR=%{prefix}/sbin \
156         BINDIR=%{prefix}/bin \
157         MANDIR=MANDIR_MACRO \
158         SWATDIR=%{prefix}/share/swat \
159         SAMBABOOK=%{prefix}/share/swat/using_samba \
160         installman installswat installdat installmodules
161 cd ..
162
163 # Install the nsswitch wins library
164 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
165 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2 )
166
167 # Install winbind shared libraries
168 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
169 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_winbind.so libnss_winbind.so.2 )
170 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
171
172 # Install pam_smbpass.so
173 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
174
175 # libsmbclient
176 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
177 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
178 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
179
180 # Install the miscellany
181 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
182 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
183 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
184 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
185 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
186 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
187 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
188 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
189 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
190 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
191 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
192
193 # Remove "*.old" files
194 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
195
196 ##
197 ## Clean out man pages for tools not installed here
198 ##
199 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/editreg.1*
200 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
201 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
202 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbget.1*
203 rm -f $RPM_BUILD_ROOT/%{_mandir}/man8/mount.cifs.8*
204
205
206 %clean
207 rm -rf $RPM_BUILD_ROOT
208
209 %post
210 ## 
211 ## only needed if this is a new install (not an upgrade)
212 ##
213 if [ "$1" -eq "1" ]; then
214         /sbin/chkconfig --add smb
215         /sbin/chkconfig --add winbind
216         /sbin/chkconfig smb off
217         /sbin/chkconfig winbind off
218 fi
219
220 ##
221 ## we only have to wory about this if we are upgrading
222 ##
223 if [ "$1" -eq "2" ]; then
224         if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
225                 echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
226                 mv /etc/smb.conf /etc/samba/smb.conf
227         fi
228
229         if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
230                 echo "Moving old /etc/smbusers to /etc/samba/smbusers"
231                 mv /etc/smbusers /etc/samba/smbusers
232         fi
233
234         if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
235                 echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
236                 mv /etc/lmhosts /etc/samba/lmhosts
237         fi
238
239         if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
240                 echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
241                 mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
242         fi
243
244         if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
245                 echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
246                 mv /etc/smbpasswd /etc/samba/smbpasswd
247         fi
248
249         #
250         # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
251         # to preserve across reboots.
252         #
253         for i in /var/lock/samba/*.tdb; do
254                 if [ -f $i ]; then
255                         newname="/var/lib/samba/`basename $i`"
256                         echo "Moving $i to $newname"
257                         mv $i $newname
258                 fi
259         done
260
261         #
262         # For 3.0.1 we move the tdb files from /var/cache/samba to /var/lib/samba
263         #
264         echo "Moving tdb files in /var/cache/samba/*.tdb to /var/lib/samba/*.tdb"
265         for i in /var/cache/samba/*.tdb; do
266                 if [ -f $i ]; then
267                         newname="/var/lib/samba/`basename $i`"
268                         echo "Moving $i to $newname"
269                         mv $i $newname
270                 fi
271         done
272 fi
273
274 ##
275 ## New things
276 ##
277
278 # Add swat entry to /etc/services if not already there.
279 if [ ! "`grep ^\s**swat /etc/services`" ]; then
280         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
281 fi
282
283 # Add swat entry to /etc/inetd.conf if needed.
284 if [ -f /etc/inetd.conf ]; then
285         if [ ! "`grep ^\s*swat /etc/inetd.conf`" ]; then
286                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
287         killall -HUP inetd || :
288         fi
289 fi
290
291 # Add swat entry to xinetd.d if needed.
292 if [ -d /etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
293         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
294 else
295         rm -f /etc/samba/samba.xinetd
296 fi
297
298 # Install the correct version of the samba pam file
299 if [ -f /lib/security/pam_stack.so ]; then
300         echo "Installing stack version of /etc/pam.d/samba..."
301         mv /etc/samba/samba.stack /etc/pam.d/samba
302 else
303         echo "Installing non-stack version of /etc/pam.d/samba..."
304         rm -f /etc/samba/samba.stack
305 fi
306
307 ## call ldconfig to create the version symlink for libsmbclient.so
308 /sbin/ldconfig
309
310 %preun
311 if [ "$1" -eq "0" ] ; then
312         /sbin/chkconfig --del smb
313         /sbin/chkconfig --del winbind
314
315         # We want to remove the browse.dat and wins.dat files 
316         # so they can not interfer with a new version of samba!
317         if [ -e /var/lib/samba/browse.dat ]; then
318                 rm -f /var/lib/samba/browse.dat
319         fi
320         if [ -e /var/lib/samba/wins.dat ]; then
321                 rm -f /var/lib/samba/wins.dat
322         fi
323
324         # Remove the transient tdb files.
325         if [ -e /var/lib/samba/brlock.tdb ]; then
326                 rm -f /var/lib/samba/brlock.tdb
327         fi
328
329         if [ -e /var/lib/samba/unexpected.tdb ]; then
330                 rm -f /var/lib/samba/unexpected.tdb
331         fi
332
333         if [ -e /var/lib/samba/connections.tdb ]; then
334                 rm -f /var/lib/samba/connections.tdb
335         fi
336
337         if [ -e /var/lib/samba/locking.tdb ]; then
338                 rm -f /var/lib/samba/locking.tdb
339         fi
340
341         if [ -e /var/lib/samba/messages.tdb ]; then
342                 rm -f /var/lib/samba/messages.tdb
343         fi
344 fi
345
346 %postun
347 # Only delete remnants of samba if this is the final deletion.
348 if [ "$1" -eq  "0" ] ; then
349     if [ -x /etc/pam.d/samba ]; then
350       rm -f /etc/pam.d/samba
351     fi
352
353     if [ -e /var/log/samba ]; then
354       rm -rf /var/log/samba
355     fi
356
357     if [ -e /var/lib/samba ]; then
358       rm -rf /var/lib/samba
359     fi
360
361     # Remove swat entries from /etc/inetd.conf and /etc/services
362     cd /etc
363     tmpfile=/etc/tmp.$$
364     if [ -f /etc/inetd.conf ]; then
365       # preserve inetd.conf permissions.
366       cp -p /etc/inetd.conf $tmpfile
367       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
368       mv $tmpfile inetd.conf
369     fi
370
371     # preserve services permissions.
372     cp -p /etc/services $tmpfile
373     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
374     mv $tmpfile /etc/services
375
376     # Remove swat entry from /etc/xinetd.d
377     if [ -f /etc/xinetd.d/swat ]; then
378       rm -r /etc/xinetd.d/swat
379     fi
380 fi
381
382 /sbin/ldconfig
383
384 %files
385 %defattr(-,root,root)
386 %doc README COPYING Manifest Read-Manifest-Now
387 %doc WHATSNEW.txt Roadmap
388 %doc docs
389 %doc examples
390 %{prefix}/sbin/smbd
391 %{prefix}/sbin/nmbd
392 %{prefix}/sbin/swat
393 %{prefix}/bin/smbmnt
394 %{prefix}/sbin/smbmount
395 %{prefix}/sbin/smbumount
396 %{prefix}/sbin/winbindd
397 %{prefix}/sbin/samba
398 %{prefix}/sbin/debug2html
399 /sbin/mount.smbfs
400 /sbin/mount.smb
401 %{prefix}/bin/mksmbpasswd.sh
402 %{prefix}/bin/smbclient
403 %{prefix}/bin/smbspool
404 %{prefix}/bin/rpcclient
405 %{prefix}/bin/testparm
406 %{prefix}/bin/testprns
407 %{prefix}/bin/findsmb
408 %{prefix}/bin/smbstatus
409 %{prefix}/bin/nmblookup
410 %{prefix}/bin/smbpasswd
411 %{prefix}/bin/smbtar
412 %{prefix}/bin/smbprint
413 %{prefix}/bin/smbcontrol
414 %{prefix}/bin/wbinfo
415 %{prefix}/bin/net
416 %{prefix}/bin/ntlm_auth
417 %{prefix}/bin/smbcquotas
418 %{prefix}/bin/smbcacls
419 %{prefix}/bin/pdbedit
420 %{prefix}/bin/tdbbackup
421 %{prefix}/bin/smbtree
422 %attr(755,root,root) /lib/libnss_wins.s*
423 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
424 %attr(755,root,root) %{prefix}/lib/samba/charset/*.so
425 #%attr(755,root,root) %{prefix}/lib/samba/pdb/*.so
426 %attr(755,root,root) %{prefix}/lib/samba/*.dat
427 %attr(755,root,root) %{prefix}/lib/samba/*.msg
428 %{prefix}/include/libsmbclient.h
429 %{prefix}/lib/libsmbclient.a
430 %{prefix}/lib/libsmbclient.so
431 %{prefix}/share/swat/help/*
432 %{prefix}/share/swat/images/*
433 %{prefix}/share/swat/include/*.html
434 %{prefix}/share/swat/lang/*/help/*
435 %{prefix}/share/swat/lang/*/images/*
436 %{prefix}/share/swat/lang/*/include/*.html
437 %{prefix}/share/swat/using_samba/*
438 %config(noreplace) /etc/samba/lmhosts
439 %config(noreplace) /etc/samba/smb.conf
440 %config(noreplace) /etc/samba/smbusers
441 /etc/samba/samba.stack
442 /etc/samba/samba.xinetd
443 /etc/rc.d/init.d/smb
444 /etc/rc.d/init.d/winbind
445 /etc/logrotate.d/samba
446 %config(noreplace) /etc/pam.d/samba
447 MANDIR_MACRO/man1/*
448 MANDIR_MACRO/man5/*
449 MANDIR_MACRO/man7/*
450 MANDIR_MACRO/man8/*
451 %attr(755,root,root) %dir /var/lib/samba
452 %dir /var/log/samba
453 %dir /var/run/samba
454 %attr(1777,root,root) %dir /var/spool/samba
455 %attr(-,root,root) /lib/libnss_winbind.so*
456 %attr(-,root,root) /lib/security/pam_winbind.so
457 %attr(-,root,root) /lib/security/pam_smbpass.so