This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/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 swat/README $RPM_BUILD_ROOT%{prefix}/share/swat/README
162 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
163 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
164 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
165 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
166 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
167 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
168 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
169 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
170 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
171 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
172 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
173
174 # Remove "*.old" files
175 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
176
177 %clean
178 rm -rf $RPM_BUILD_ROOT
179
180 %post
181 /sbin/chkconfig --add smb
182 /sbin/chkconfig --add winbind
183 /sbin/chkconfig smb off
184 /sbin/chkconfig winbind off
185
186 echo "Looking for old /etc/smb.conf..."
187 if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
188         echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
189         mv /etc/smb.conf /etc/samba/smb.conf
190 fi
191
192 echo "Looking for old /etc/smbusers..."
193 if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
194         echo "Moving old /etc/smbusers to /etc/samba/smbusers"
195         mv /etc/smbusers /etc/samba/smbusers
196 fi
197
198 echo "Looking for old /etc/lmhosts..."
199 if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
200         echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
201         mv /etc/lmhosts /etc/samba/lmhosts
202 fi
203
204 echo "Looking for old /etc/MACHINE.SID..."
205 if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
206         echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
207         mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
208 fi
209
210 echo "Looking for old /etc/smbpasswd..."
211 if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
212         echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
213         mv /etc/smbpasswd /etc/samba/smbpasswd
214 fi
215
216 #
217 # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
218 # to preserve across reboots.
219 #
220 echo "Moving tdb files in /var/lock/samba/*.tdb to /var/cache/samba/*.tdb"
221 for i in /var/lock/samba/*.tdb
222 do
223 if [ -f $i ]; then
224         newname=`echo $i | sed -e's|var\/lock\/samba|var\/cache\/samba|'`
225         echo "Moving $i to $newname"
226         mv $i $newname
227 fi
228 done
229
230 # Remove the transient tdb files.
231 if [ -e /var/cache/samba/brlock.tdb ]; then
232         rm -f /var/cache/samba/brlock.tdb
233 fi
234
235 if [ -e /var/cache/samba/unexpected.tdb ]; then
236         rm -f /var/cache/samba/unexpected.tdb
237 fi
238
239 if [ -e /var/cache/samba/connections.tdb ]; then
240         rm -f /var/cache/samba/connections.tdb
241 fi
242
243 if [ -e /var/cache/samba/locking.tdb ]; then
244         rm -f /var/cache/samba/locking.tdb
245 fi
246
247 if [ -e /var/cache/samba/messages.tdb ]; then
248         rm -f /var/cache/samba/messages.tdb
249 fi
250
251 if [ -d /var/lock/samba ]; then
252         rm -rf /var/lock/samba
253 fi
254
255 # Add swat entry to /etc/services if not already there.
256 if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
257         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
258 fi
259
260 # Add swat entry to /etc/inetd.conf if needed.
261 if [ -f /etc/inetd.conf ]; then
262         if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
263                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
264         killall -1 inetd || :
265         fi
266 fi
267
268 # Add swat entry to xinetd.d if needed.
269 if [ -d $RPM_BUILD_ROOT/etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
270         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
271 else
272         rm -f /etc/samba/samba.xinetd
273 fi
274
275 # Install the correct version of the samba pam file, depending on pam version.
276 if [ -f /lib/security/pam_stack.so ]; then
277         echo "Installing stack version of /etc/pam.d/samba..."
278         mv /etc/samba/samba.stack /etc/pam.d/samba
279 else
280         echo "Installing non-stack version of /etc/pam.d/samba..."
281         rm -f /etc/samba/samba.stack
282 fi
283
284 # Create winbind nss client symlink
285
286 if [ -e /lib/libnss_winbind.so ]; then
287         ln -sf /lib/libnss_winbind.so /lib/libnss_winbind.so.2
288 fi
289
290 %preun
291 if [ $1 = 0 ] ; then
292         /sbin/chkconfig --del smb
293
294         # We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
295         if [ -e /var/cache/samba/browse.dat ]; then
296                 rm -f /var/cache/samba/browse.dat
297         fi
298         if [ -e /var/cache/samba/wins.dat ]; then
299                 rm -f /var/cache/samba/wins.dat
300         fi
301
302         # Remove the transient tdb files.
303         if [ -e /var/cache/samba/brlock.tdb ]; then
304                 rm -f /var/cache/samba/brlock.tdb
305         fi
306
307         if [ -e /var/cache/samba/unexpected.tdb ]; then
308                 rm -f /var/cache/samba/unexpected.tdb
309         fi
310
311         if [ -e /var/cache/samba/connections.tdb ]; then
312                 rm -f /var/cache/samba/connections.tdb
313         fi
314
315         if [ -e /var/cache/samba/locking.tdb ]; then
316                 rm -f /var/cache/samba/locking.tdb
317         fi
318
319         if [ -e /var/cache/samba/messages.tdb ]; then
320                 rm -f /var/cache/samba/messages.tdb
321         fi
322
323         # Remove winbind nss client symlink
324
325         if [ -L /lib/libnss_winbind.so.2 ]; then
326                 rm -f /lib/libnss_winbind.so.2
327         fi
328 fi
329
330 %postun
331 # Only delete remnants of samba if this is the final deletion.
332 if [ $1 = 0 ] ; then
333     if [ -x /etc/pam.d/samba ]; then
334       rm -f /etc/pam.d/samba
335     fi
336     if [ -e /var/log/samba ]; then
337       rm -rf /var/log/samba
338     fi
339         if [ -e /var/cache/samba ]; then
340                 rm -rf /var/cache/samba
341         fi
342
343     # Remove swat entries from /etc/inetd.conf and /etc/services
344     cd /etc
345     tmpfile=/etc/tmp.$$
346         if [ -f /etc/inetd.conf ]; then
347       # preserve inetd.conf permissions.
348       cp -p /etc/inetd.conf $tmpfile
349       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
350       mv $tmpfile inetd.conf
351         fi
352     # preserve services permissions.
353     cp -p /etc/services $tmpfile
354     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
355     mv $tmpfile /etc/services
356
357         # Remove swat entry from /etc/xinetd.d
358         if [ -f /etc/xinetd.d/swat ]; then
359                 rm -r /etc/xinetd.d/swat
360         fi
361 fi
362
363 %files
364 %defattr(-,root,root)
365 %doc README COPYING Manifest Read-Manifest-Now
366 %doc WHATSNEW.txt Roadmap
367 %doc docs
368 %doc swat/README
369 %doc examples
370 %{prefix}/sbin/smbd
371 %{prefix}/sbin/nmbd
372 %{prefix}/sbin/swat
373 %{prefix}/bin/smbmnt
374 %{prefix}/sbin/smbmount
375 %{prefix}/sbin/smbumount
376 %{prefix}/sbin/winbindd
377 %{prefix}/sbin/wrepld
378 %{prefix}/sbin/samba
379 %{prefix}/sbin/debug2html
380 /sbin/mount.smbfs
381 /sbin/mount.smb
382 %{prefix}/bin/mksmbpasswd.sh
383 %{prefix}/bin/smbclient
384 %{prefix}/bin/smbspool
385 %{prefix}/bin/rpcclient
386 %{prefix}/bin/testparm
387 %{prefix}/bin/testprns
388 %{prefix}/bin/findsmb
389 %{prefix}/bin/smbstatus
390 %{prefix}/bin/nmblookup
391 %{prefix}/bin/smbpasswd
392 %{prefix}/bin/smbtar
393 %{prefix}/bin/smbprint
394 %{prefix}/bin/smbcontrol
395 %{prefix}/bin/wbinfo
396 %{prefix}/bin/net
397 %{prefix}/bin/smbgroupedit
398 %{prefix}/bin/smbcacls
399 %{prefix}/bin/pdbedit
400 %{prefix}/bin/tdbbackup
401 %{prefix}/bin/smbtree
402 %attr(755,root,root) /lib/libnss_wins.s*
403 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
404 %attr(755,root,root) %{prefix}/lib/samba/*.dat
405 %{prefix}/include/libsmbclient.h
406 %{prefix}/lib/libsmbclient.a
407 %{prefix}/lib/libsmbclient.so
408 %{prefix}/share/swat/help/*
409 %{prefix}/share/swat/images/*
410 %{prefix}/share/swat/include/*.html
411 %{prefix}/share/swat/lang/*/help/*
412 %{prefix}/share/swat/lang/*/images/*
413 %{prefix}/share/swat/lang/*/include/*.html
414 %{prefix}/share/swat/using_samba/*
415 %{prefix}/share/swat/README
416 %config(noreplace) /etc/samba/lmhosts
417 %config(noreplace) /etc/samba/smb.conf
418 %config(noreplace) /etc/samba/smbusers
419 /etc/samba/samba.stack
420 /etc/samba/samba.xinetd
421 /etc/rc.d/init.d/smb
422 /etc/rc.d/init.d/winbind
423 /etc/logrotate.d/samba
424 %config(noreplace) /etc/pam.d/samba
425 MANDIR_MACRO/man1/*
426 MANDIR_MACRO/man5/*
427 MANDIR_MACRO/man7/*
428 MANDIR_MACRO/man8/*
429 %attr(755,root,root) %dir /var/cache/samba
430 %dir /var/log/samba
431 %dir /var/run/samba
432 %attr(1777,root,root) %dir /var/spool/samba
433 %attr(-,root,root) /lib/libnss_winbind.so
434 %attr(-,root,root) /lib/security/pam_winbind.so
435 %attr(-,root,root) /lib/security/pam_smbpass.so