This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[jra/samba/.git] / packaging / RedHat / samba2.spec.tmpl
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
15
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.
24
25 Samba 3.0 also introduces UNICODE support and kerberos/ldap
26 integration as a member server in a Windows 2000 domain.
27
28 Please refer to the WHATSNEW.txt document for fixup information.
29 docs directory for implementation details.
30
31 %changelog
32 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
33   - removed change log entries since history
34     is being maintained in CVS
35
36 %prep
37 %setup
38
39 %build
40 ## Build main Samba source
41 cd source
42
43 %ifarch ia64
44 libtoolize --copy --force     # get it to recognize IA-64
45 autoheader
46 autoconf
47 EXTRA="-D_LARGEFILE64_SOURCE"
48 %endif
49 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
50 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
51         --prefix=%{prefix} \
52         --localstatedir=/var \
53         --with-configdir=/etc/samba \
54         --with-privatedir=/etc/samba \
55         --with-fhs \
56         --with-quotas \
57         --with-smbmount \
58         --with-pam \
59         --with-pam_smbpass \
60         --with-syslog \
61         --with-utmp \
62         --with-sambabook=%{prefix}/share/swat/using_samba \
63         --with-swatdir=%{prefix}/share/swat \
64         --with-libsmbclient 
65 make -j${NUMCPU} proto
66 make -j${NUMCPU} all nsswitch/libnss_wins.so modules
67 make -j${NUMCPU} debug2html
68 make -j${NUMCPU} bin/smbspool
69
70 # Remove some permission bits to avoid to many dependencies
71 find examples docs -type f | xargs -r chmod -x
72
73 %install
74 rm -rf $RPM_BUILD_ROOT
75 mkdir -p $RPM_BUILD_ROOT
76 mkdir -p $RPM_BUILD_ROOT/sbin
77 mkdir -p $RPM_BUILD_ROOT/etc/samba
78 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
79 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
80 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
81 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{images,help,include,using_samba}
82 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
83 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
84 mkdir -p $RPM_BUILD_ROOT/var/cache/samba
85 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
86 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
87 mkdir -p $RPM_BUILD_ROOT/lib/security
88 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
89 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
90
91 # Install standard binary files
92 for i in nmblookup smbclient smbpasswd smbstatus testparm testprns \
93         rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt net smbgroupedit \
94         smbcacls pdbedit tdbbackup smbtree
95 do
96         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/bin
97 done
98
99 for i in mksmbpasswd.sh smbtar findsmb
100 do
101         install -m755 source/script/$i $RPM_BUILD_ROOT%{prefix}/bin
102 done
103
104 # Install secure binary files
105 for i in smbd nmbd swat smbmount smbumount debug2html winbindd wrepld
106 do
107         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/sbin
108 done
109
110 # we need a symlink for mount to recognise the smb and smbfs filesystem types
111 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
112 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
113
114 # This allows us to get away without duplicating code that 
115 #  sombody else can maintain for us.  
116 cd source
117 make BASEDIR=$RPM_BUILD_ROOT/usr \
118         CONFIGDIR=$RPM_BUILD_ROOT/etc/samba \
119         LIBDIR=$RPM_BUILD_ROOT%{prefix}/lib/samba \
120         VARDIR=$RPM_BUILD_ROOT/var \
121         SBINDIR=$RPM_BUILD_ROOT%{prefix}/sbin \
122         BINDIR=$RPM_BUILD_ROOT%{prefix}/bin \
123         MANDIR=$RPM_BUILD_ROOTMANDIR_MACRO \
124         SWATDIR=$RPM_BUILD_ROOT%{prefix}/share/swat \
125         SAMBABOOK=$RPM_BUILD_ROOT%{prefix}/share/swat/using_samba \
126         installman installswat installdat installmodules
127 cd ..
128
129 # Install the nsswitch wins library
130 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
131 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2; )
132
133 # Install winbind shared libraries
134 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
135 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_winbind.so libnss_winbind.so.2; )
136 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
137
138 # Install pam_smbpass.so
139 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
140
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/
145
146 # Install SWAT helper files
147 #for i in swat/help/*.html docs/htmldocs/*.html
148 #do
149 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/help
150 #done
151 #for i in swat/images/*.gif
152 #do
153 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/images
154 #done
155 #for i in swat/include/*.html
156 #do
157 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/include
158 #done
159
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
172
173 # Remove "*.old" files
174 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
175
176 %clean
177 rm -rf $RPM_BUILD_ROOT
178
179 %post
180 /sbin/chkconfig --add smb
181 /sbin/chkconfig --add winbind
182 /sbin/chkconfig smb off
183 /sbin/chkconfig winbind off
184
185 echo "Looking for old /etc/smb.conf..."
186 if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
187         echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
188         mv /etc/smb.conf /etc/samba/smb.conf
189 fi
190
191 echo "Looking for old /etc/smbusers..."
192 if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
193         echo "Moving old /etc/smbusers to /etc/samba/smbusers"
194         mv /etc/smbusers /etc/samba/smbusers
195 fi
196
197 echo "Looking for old /etc/lmhosts..."
198 if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
199         echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
200         mv /etc/lmhosts /etc/samba/lmhosts
201 fi
202
203 echo "Looking for old /etc/MACHINE.SID..."
204 if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
205         echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
206         mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
207 fi
208
209 echo "Looking for old /etc/smbpasswd..."
210 if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
211         echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
212         mv /etc/smbpasswd /etc/samba/smbpasswd
213 fi
214
215 #
216 # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
217 # to preserve across reboots.
218 #
219 echo "Moving tdb files in /var/lock/samba/*.tdb to /var/cache/samba/*.tdb"
220 for i in /var/lock/samba/*.tdb
221 do
222 if [ -f $i ]; then
223         newname=`echo $i | sed -e's|var\/lock\/samba|var\/cache\/samba|'`
224         echo "Moving $i to $newname"
225         mv $i $newname
226 fi
227 done
228
229 # Remove the transient tdb files.
230 if [ -e /var/cache/samba/brlock.tdb ]; then
231         rm -f /var/cache/samba/brlock.tdb
232 fi
233
234 if [ -e /var/cache/samba/unexpected.tdb ]; then
235         rm -f /var/cache/samba/unexpected.tdb
236 fi
237
238 if [ -e /var/cache/samba/connections.tdb ]; then
239         rm -f /var/cache/samba/connections.tdb
240 fi
241
242 if [ -e /var/cache/samba/locking.tdb ]; then
243         rm -f /var/cache/samba/locking.tdb
244 fi
245
246 if [ -e /var/cache/samba/messages.tdb ]; then
247         rm -f /var/cache/samba/messages.tdb
248 fi
249
250 if [ -d /var/lock/samba ]; then
251         rm -rf /var/lock/samba
252 fi
253
254 # Add swat entry to /etc/services if not already there.
255 if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
256         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
257 fi
258
259 # Add swat entry to /etc/inetd.conf if needed.
260 if [ -f /etc/inetd.conf ]; then
261         if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
262                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
263         killall -1 inetd || :
264         fi
265 fi
266
267 # Add swat entry to xinetd.d if needed.
268 if [ -d $RPM_BUILD_ROOT/etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
269         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
270 else
271         rm -f /etc/samba/samba.xinetd
272 fi
273
274 # Install the correct version of the samba pam file, depending on pam version.
275 if [ -f /lib/security/pam_stack.so ]; then
276         echo "Installing stack version of /etc/pam.d/samba..."
277         mv /etc/samba/samba.stack /etc/pam.d/samba
278 else
279         echo "Installing non-stack version of /etc/pam.d/samba..."
280         rm -f /etc/samba/samba.stack
281 fi
282
283 # Create winbind nss client symlink
284
285 if [ -e /lib/libnss_winbind.so ]; then
286         ln -sf /lib/libnss_winbind.so /lib/libnss_winbind.so.2
287 fi
288
289 %preun
290 if [ $1 = 0 ] ; then
291         /sbin/chkconfig --del smb
292
293         # We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
294         if [ -e /var/cache/samba/browse.dat ]; then
295                 rm -f /var/cache/samba/browse.dat
296         fi
297         if [ -e /var/cache/samba/wins.dat ]; then
298                 rm -f /var/cache/samba/wins.dat
299         fi
300
301         # Remove the transient tdb files.
302         if [ -e /var/cache/samba/brlock.tdb ]; then
303                 rm -f /var/cache/samba/brlock.tdb
304         fi
305
306         if [ -e /var/cache/samba/unexpected.tdb ]; then
307                 rm -f /var/cache/samba/unexpected.tdb
308         fi
309
310         if [ -e /var/cache/samba/connections.tdb ]; then
311                 rm -f /var/cache/samba/connections.tdb
312         fi
313
314         if [ -e /var/cache/samba/locking.tdb ]; then
315                 rm -f /var/cache/samba/locking.tdb
316         fi
317
318         if [ -e /var/cache/samba/messages.tdb ]; then
319                 rm -f /var/cache/samba/messages.tdb
320         fi
321
322         # Remove winbind nss client symlink
323
324         if [ -L /lib/libnss_winbind.so.2 ]; then
325                 rm -f /lib/libnss_winbind.so.2
326         fi
327 fi
328
329 %postun
330 # Only delete remnants of samba if this is the final deletion.
331 if [ $1 = 0 ] ; then
332     if [ -x /etc/pam.d/samba ]; then
333       rm -f /etc/pam.d/samba
334     fi
335     if [ -e /var/log/samba ]; then
336       rm -rf /var/log/samba
337     fi
338         if [ -e /var/cache/samba ]; then
339                 rm -rf /var/cache/samba
340         fi
341
342     # Remove swat entries from /etc/inetd.conf and /etc/services
343     cd /etc
344     tmpfile=/etc/tmp.$$
345         if [ -f /etc/inetd.conf ]; then
346       # preserve inetd.conf permissions.
347       cp -p /etc/inetd.conf $tmpfile
348       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
349       mv $tmpfile inetd.conf
350         fi
351     # preserve services permissions.
352     cp -p /etc/services $tmpfile
353     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
354     mv $tmpfile /etc/services
355
356         # Remove swat entry from /etc/xinetd.d
357         if [ -f /etc/xinetd.d/swat ]; then
358                 rm -r /etc/xinetd.d/swat
359         fi
360 fi
361
362 %files
363 %defattr(-,root,root)
364 %doc README COPYING Manifest Read-Manifest-Now
365 %doc WHATSNEW.txt Roadmap
366 %doc docs
367 %doc swat/README
368 %doc examples
369 %{prefix}/sbin/smbd
370 %{prefix}/sbin/nmbd
371 %{prefix}/sbin/swat
372 %{prefix}/bin/smbmnt
373 %{prefix}/sbin/smbmount
374 %{prefix}/sbin/smbumount
375 %{prefix}/sbin/winbindd
376 %{prefix}/sbin/wrepld
377 %{prefix}/sbin/samba
378 %{prefix}/sbin/debug2html
379 /sbin/mount.smbfs
380 /sbin/mount.smb
381 %{prefix}/bin/mksmbpasswd.sh
382 %{prefix}/bin/smbclient
383 %{prefix}/bin/smbspool
384 %{prefix}/bin/rpcclient
385 %{prefix}/bin/testparm
386 %{prefix}/bin/testprns
387 %{prefix}/bin/findsmb
388 %{prefix}/bin/smbstatus
389 %{prefix}/bin/nmblookup
390 %{prefix}/bin/smbpasswd
391 %{prefix}/bin/smbtar
392 %{prefix}/bin/smbprint
393 %{prefix}/bin/smbcontrol
394 %{prefix}/bin/wbinfo
395 %{prefix}/bin/net
396 %{prefix}/bin/smbgroupedit
397 %{prefix}/bin/smbcacls
398 %{prefix}/bin/pdbedit
399 %{prefix}/bin/pam_smbpass.so
400 %{prefix}/bin/smbmount
401 %{prefix}/bin/smbumount
402 %{prefix}/bin/tdbbackup
403 %{prefix}/bin/smbtree
404 %attr(755,root,root) /lib/libnss_wins.s*
405 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
406 %attr(755,root,root) %{prefix}/lib/samba/*.dat
407 %{prefix}/include/libsmbclient.h
408 %{prefix}/lib/libsmbclient.a
409 %{prefix}/lib/libsmbclient.so
410 %{prefix}/share/swat/help/*
411 %{prefix}/share/swat/images/*
412 %{prefix}/share/swat/include/*.html
413 %{prefix}/share/swat/lang/*/help/*
414 %{prefix}/share/swat/lang/*/images/*
415 %{prefix}/share/swat/lang/*/include/*.html
416 %{prefix}/share/swat/include/header.html
417 %{prefix}/share/swat/include/footer.html
418 %{prefix}/share/swat/using_samba/*
419 %{prefix}/share/swat/README
420 %config(noreplace) /etc/samba/lmhosts
421 %config(noreplace) /etc/samba/smb.conf
422 %config(noreplace) /etc/samba/smbusers
423 /etc/samba/samba.stack
424 /etc/samba/samba.xinetd
425 /etc/rc.d/init.d/smb
426 /etc/rc.d/init.d/winbind
427 /etc/logrotate.d/samba
428 %config(noreplace) /etc/pam.d/samba
429 MANDIR_MACRO/man1/*
430 MANDIR_MACRO/man5/*
431 MANDIR_MACRO/man7/*
432 MANDIR_MACRO/man8/*
433 %attr(755,root,root) %dir /var/cache/samba
434 %dir /var/log/samba
435 %dir /var/run/samba
436 %attr(1777,root,root) %dir /var/spool/samba
437 %attr(-,root,root) /lib/libnss_winbind.so
438 %attr(-,root,root) /lib/security/pam_winbind.so
439 %attr(-,root,root) /lib/security/pam_smbpass.so