syncing packaging files with SAMBA_3_0
[Samba/gbeck.git] / packaging / RedHat / samba2.spec.tmpl
blob011626af07b0fbcf662307dba8f76b03e2b13df1
1 Summary: Samba SMB client and server
2 Name: samba
3 Version: PVERSION
4 Release: PRELEASE
5 Copyright: GNU GPL version 2
6 Group: Networking
7 Source: http://download.samba.org/samba/ftp/samba-%{version}.tar.bz2
8 Packager: Gerald Carter [Samba-Team] <jerry@samba.org>
9 Requires: pam >= 0.72 kernel >= 2.2.1 glibc >= 2.1.2
10 Prereq: chkconfig fileutils
11 Provides: samba = %{version}
12 Obsoletes: samba-common, samba-client, samba-swat
13 BuildRoot: /var/tmp/samba
14 Prefix: /usr
16 %description
17 Samba provides an SMB/CIFS server which can be used to provide
18 network file and print services to SMB/CIFS clients, including 
19 various versions of MS Windows, OS/2, and other Linux machines. 
20 Samba also provides some SMB clients, which complement the 
21 built-in SMB filesystem in Linux. Samba uses NetBIOS over TCP/IP 
22 (NetBT) protocols and does NOT need NetBEUI (Microsoft Raw NetBIOS 
23 frame) protocol.
25 Samba 3.0 also introduces UNICODE support and kerberos/ldap
26 integration as a member server in a Windows 2000 domain.
28 Please refer to the WHATSNEW.txt document for fixup information.
30 %changelog
31 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
32   - removed change log entries since history
33     is being maintained in CVS
35 %prep
36 %setup
38 %build
39 ## Build main Samba source
40 cd source
42 %ifarch ia64
43 libtoolize --copy --force     # get it to recognize IA-64
44 autoheader
45 autoconf
46 EXTRA="-D_LARGEFILE64_SOURCE"
47 %endif
48 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
49 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
50         --prefix=%{prefix} \
51         --localstatedir=/var \
52         --with-configdir=/etc/samba \
53         --with-privatedir=/etc/samba \
54         --with-fhs \
55         --with-quotas \
56         --with-smbmount \
57         --with-pam \
58         --with-pam_smbpass \
59         --with-syslog \
60         --with-utmp \
61         --with-sambabook=%{prefix}/share/swat/using_samba \
62         --with-swatdir=%{prefix}/share/swat \
63         --with-libsmbclient 
64 make -j${NUMCPU} proto
65 make -j${NUMCPU} all nsswitch/libnss_wins.so modules
66 make -j${NUMCPU} debug2html
67 make -j${NUMCPU} bin/smbspool
69 # Remove some permission bits to avoid to many dependencies
70 find examples docs -type f | xargs -r chmod -x
72 %install
73 rm -rf $RPM_BUILD_ROOT
74 mkdir -p $RPM_BUILD_ROOT
75 mkdir -p $RPM_BUILD_ROOT/sbin
76 mkdir -p $RPM_BUILD_ROOT/etc/samba
77 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
78 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
79 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
80 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{images,help,include,using_samba}
81 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
82 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
83 mkdir -p $RPM_BUILD_ROOT/var/cache/samba
84 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
85 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
86 mkdir -p $RPM_BUILD_ROOT/lib/security
87 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
88 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
90 # Install standard binary files
91 for i in nmblookup smbclient smbpasswd smbstatus testparm testprns \
92         rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt net smbgroupedit \
93         smbcacls pdbedit tdbbackup smbtree
95         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/bin
96 done
98 for i in mksmbpasswd.sh smbtar findsmb
100         install -m755 source/script/$i $RPM_BUILD_ROOT%{prefix}/bin
101 done
103 # Install secure binary files
104 for i in smbd nmbd swat smbmount smbumount debug2html winbindd wrepld
106         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/sbin
107 done
109 # we need a symlink for mount to recognise the smb and smbfs filesystem types
110 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
111 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
113 # This allows us to get away without duplicating code that 
114 #  sombody else can maintain for us.  
115 cd source
116 make BASEDIR=$RPM_BUILD_ROOT/usr \
117         CONFIGDIR=$RPM_BUILD_ROOT/etc/samba \
118         LIBDIR=$RPM_BUILD_ROOT%{prefix}/lib/samba \
119         VARDIR=$RPM_BUILD_ROOT/var \
120         SBINDIR=$RPM_BUILD_ROOT%{prefix}/sbin \
121         BINDIR=$RPM_BUILD_ROOT%{prefix}/bin \
122         MANDIR=$RPM_BUILD_ROOTMANDIR_MACRO \
123         SWATDIR=$RPM_BUILD_ROOT%{prefix}/share/swat \
124         SAMBABOOK=$RPM_BUILD_ROOT%{prefix}/share/swat/using_samba \
125         installman installswat installdat installmodules
126 cd ..
128 # Install the nsswitch wins library
129 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
131 # Make link for wins resolver
132 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2; )
134 # Install winbind shared libraries
135 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
136 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
138 # Install pam_smbpass.so
139 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
141 # libsmbclient
142 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
143 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
144 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
146 # Install SWAT helper files
147 #for i in swat/help/*.html docs/htmldocs/*.html
149 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/help
150 #done
151 #for i in swat/images/*.gif
153 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/images
154 #done
155 #for i in swat/include/*.html
157 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/include
158 #done
160 # Install the miscellany
161 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
162 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
163 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
164 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
165 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
166 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
167 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
168 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
169 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
170 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
171 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
173 %clean
174 rm -rf $RPM_BUILD_ROOT
176 %post
177 /sbin/chkconfig --add smb
178 /sbin/chkconfig --add winbind
179 /sbin/chkconfig smb off
180 /sbin/chkconfig winbind off
182 echo "Looking for old /etc/smb.conf..."
183 if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
184         echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
185         mv /etc/smb.conf /etc/samba/smb.conf
188 echo "Looking for old /etc/smbusers..."
189 if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
190         echo "Moving old /etc/smbusers to /etc/samba/smbusers"
191         mv /etc/smbusers /etc/samba/smbusers
194 echo "Looking for old /etc/lmhosts..."
195 if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
196         echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
197         mv /etc/lmhosts /etc/samba/lmhosts
200 echo "Looking for old /etc/MACHINE.SID..."
201 if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
202         echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
203         mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
206 echo "Looking for old /etc/smbpasswd..."
207 if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
208         echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
209         mv /etc/smbpasswd /etc/samba/smbpasswd
213 # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
214 # to preserve across reboots.
216 echo "Moving tdb files in /var/lock/samba/*.tdb to /var/cache/samba/*.tdb"
217 for i in /var/lock/samba/*.tdb
219 if [ -f $i ]; then
220         newname=`echo $i | sed -e's|var\/lock\/samba|var\/cache\/samba|'`
221         echo "Moving $i to $newname"
222         mv $i $newname
224 done
226 # Remove the transient tdb files.
227 if [ -e /var/cache/samba/brlock.tdb ]; then
228         rm -f /var/cache/samba/brlock.tdb
231 if [ -e /var/cache/samba/unexpected.tdb ]; then
232         rm -f /var/cache/samba/unexpected.tdb
235 if [ -e /var/cache/samba/connections.tdb ]; then
236         rm -f /var/cache/samba/connections.tdb
239 if [ -e /var/cache/samba/locking.tdb ]; then
240         rm -f /var/cache/samba/locking.tdb
243 if [ -e /var/cache/samba/messages.tdb ]; then
244         rm -f /var/cache/samba/messages.tdb
247 if [ -d /var/lock/samba ]; then
248         rm -rf /var/lock/samba
251 # Add swat entry to /etc/services if not already there.
252 if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
253         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
256 # Add swat entry to /etc/inetd.conf if needed.
257 if [ -f /etc/inetd.conf ]; then
258         if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
259                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
260         killall -1 inetd || :
261         fi
264 # Add swat entry to xinetd.d if needed.
265 if [ -d $RPM_BUILD_ROOT/etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
266         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
267 else
268         rm -f /etc/samba/samba.xinetd
271 # Install the correct version of the samba pam file, depending on pam version.
272 if [ -f /lib/security/pam_stack.so ]; then
273         echo "Installing stack version of /etc/pam.d/samba..."
274         mv /etc/samba/samba.stack /etc/pam.d/samba
275 else
276         echo "Installing non-stack version of /etc/pam.d/samba..."
277         rm -f /etc/samba/samba.stack
280 # Create winbind nss client symlink
282 if [ -e /lib/libnss_winbind.so ]; then
283         ln -sf /lib/libnss_winbind.so /lib/libnss_winbind.so.2
286 %preun
287 if [ $1 = 0 ] ; then
288         /sbin/chkconfig --del smb
290         # We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
291         if [ -e /var/cache/samba/browse.dat ]; then
292                 rm -f /var/cache/samba/browse.dat
293         fi
294         if [ -e /var/cache/samba/wins.dat ]; then
295                 rm -f /var/cache/samba/wins.dat
296         fi
298         # Remove the transient tdb files.
299         if [ -e /var/cache/samba/brlock.tdb ]; then
300                 rm -f /var/cache/samba/brlock.tdb
301         fi
303         if [ -e /var/cache/samba/unexpected.tdb ]; then
304                 rm -f /var/cache/samba/unexpected.tdb
305         fi
307         if [ -e /var/cache/samba/connections.tdb ]; then
308                 rm -f /var/cache/samba/connections.tdb
309         fi
311         if [ -e /var/cache/samba/locking.tdb ]; then
312                 rm -f /var/cache/samba/locking.tdb
313         fi
315         if [ -e /var/cache/samba/messages.tdb ]; then
316                 rm -f /var/cache/samba/messages.tdb
317         fi
319         # Remove winbind nss client symlink
321         if [ -L /lib/libnss_winbind.so.2 ]; then
322                 rm -f /lib/libnss_winbind.so.2
323         fi
326 %postun
327 # Only delete remnants of samba if this is the final deletion.
328 if [ $1 = 0 ] ; then
329     if [ -x /etc/pam.d/samba ]; then
330       rm -f /etc/pam.d/samba
331     fi
332     if [ -e /var/log/samba ]; then
333       rm -rf /var/log/samba
334     fi
335         if [ -e /var/cache/samba ]; then
336                 rm -rf /var/cache/samba
337         fi
339     # Remove swat entries from /etc/inetd.conf and /etc/services
340     cd /etc
341     tmpfile=/etc/tmp.$$
342         if [ -f /etc/inetd.conf ]; then
343       # preserve inetd.conf permissions.
344       cp -p /etc/inetd.conf $tmpfile
345       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
346       mv $tmpfile inetd.conf
347         fi
348     # preserve services permissions.
349     cp -p /etc/services $tmpfile
350     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
351     mv $tmpfile /etc/services
353         # Remove swat entry from /etc/xinetd.d
354         if [ -f /etc/xinetd.d/swat ]; then
355                 rm -r /etc/xinetd.d/swat
356         fi
359 %files
360 %defattr(-,root,root)
361 %doc README COPYING Manifest Read-Manifest-Now
362 %doc WHATSNEW.txt Roadmap
363 %doc docs
364 %doc swat/README
365 %doc examples
366 %{prefix}/sbin/smbd
367 %{prefix}/sbin/nmbd
368 %{prefix}/sbin/swat
369 %{prefix}/bin/smbmnt
370 %{prefix}/sbin/smbmount
371 %{prefix}/sbin/smbumount
372 %{prefix}/sbin/winbindd
373 %{prefix}/sbin/wrepld
374 %{prefix}/sbin/samba
375 %{prefix}/sbin/debug2html
376 /sbin/mount.smbfs
377 /sbin/mount.smb
378 %{prefix}/bin/mksmbpasswd.sh
379 %{prefix}/bin/smbclient
380 %{prefix}/bin/smbspool
381 %{prefix}/bin/rpcclient
382 %{prefix}/bin/testparm
383 %{prefix}/bin/testprns
384 %{prefix}/bin/findsmb
385 %{prefix}/bin/smbstatus
386 %{prefix}/bin/nmblookup
387 %{prefix}/bin/smbpasswd
388 %{prefix}/bin/smbtar
389 %{prefix}/bin/smbprint
390 %{prefix}/bin/smbcontrol
391 %{prefix}/bin/wbinfo
392 %{prefix}/bin/net
393 %{prefix}/bin/smbgroupedit
394 %{prefix}/bin/smbcacls
395 %{prefix}/bin/pdbedit
396 %{prefix}/bin/tdbbackup
397 %{prefix}/bin/smbtree
398 %attr(755,root,root) /lib/libnss_wins.s*
399 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
400 %attr(755,root,root) %{prefix}/lib/samba/*.dat
401 %{prefix}/include/libsmbclient.h
402 %{prefix}/lib/libsmbclient.a
403 %{prefix}/lib/libsmbclient.so
404 %{prefix}/share/swat/help/*
405 %{prefix}/share/swat/images/*
406 %{prefix}/share/swat/include/*.html
407 %{prefix}/share/swat/lang/*/help/*
408 %{prefix}/share/swat/lang/*/images/*
409 %{prefix}/share/swat/lang/*/include/*.html
410 %{prefix}/share/swat/using_samba/*
411 %config(noreplace) /etc/samba/lmhosts
412 %config(noreplace) /etc/samba/smb.conf
413 %config(noreplace) /etc/samba/smbusers
414 /etc/samba/samba.stack
415 /etc/samba/samba.xinetd
416 /etc/rc.d/init.d/smb
417 /etc/rc.d/init.d/winbind
418 /etc/logrotate.d/samba
419 %config(noreplace) /etc/pam.d/samba
420 MANDIR_MACRO/man1/*
421 MANDIR_MACRO/man5/*
422 MANDIR_MACRO/man7/*
423 MANDIR_MACRO/man8/*
424 %attr(755,root,root) %dir /var/cache/samba
425 %dir /var/log/samba
426 %dir /var/run/samba
427 %attr(1777,root,root) %dir /var/spool/samba
428 %attr(-,root,root) /lib/libnss_winbind.so
429 %attr(-,root,root) /lib/security/pam_winbind.so
430 %attr(-,root,root) /lib/security/pam_smbpass.so