bad date string in specfile
[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 Users are advised to use Samba-2.2 as a Windows NT4
18 Samba provides an SMB/CIFS server which can be used to provide
19 network file and print services to SMB/CIFS clients, including 
20 various versions of MS Windows, OS/2, and other Linux machines. 
21 Samba also provides some SMB clients, which complement the 
22 built-in SMB filesystem in Linux. Samba uses NetBIOS over TCP/IP 
23 (NetBT) protocols and does NOT need NetBEUI (Microsoft Raw NetBIOS 
24 frame) protocol.
25
26 Please refer to the WHATSNEW.txt document for fixup information.
27
28 %changelog
29 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
30   - removed change log entries since history
31     is being maintained in CVS
32
33 %prep
34 %setup
35
36 %build
37 ## Build main Samba source
38 cd source
39
40 %ifarch ia64
41 libtoolize --copy --force     # get it to recognize IA-64
42 autoheader
43 autoconf
44 EXTRA="-D_LARGEFILE64_SOURCE"
45 %endif
46 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
47 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
48         --prefix=%{prefix} \
49         --localstatedir=/var \
50         --with-configdir=/etc/samba \
51         --with-privatedir=/etc/samba \
52         --with-fhs \
53         --with-quotas \
54         --with-msdfs \
55         --with-smbmount \
56         --with-pam \
57         --with-pam_smbpass \
58         --with-syslog \
59         --with-utmp \
60         --with-sambabook=%{prefix}/share/swat/using_samba \
61         --with-swatdir=%{prefix}/share/swat \
62         --with-libsmbclient 
63 make -j${NUMCPU} proto
64 make -j${NUMCPU} all nsswitch/libnss_wins.so
65 make -j${NUMCPU} debug2html
66 make -j${NUMCPU} bin/smbspool
67
68 ## Build VFS modules
69 #cd ../examples/VFS
70 #make
71
72
73
74 %install
75 rm -rf $RPM_BUILD_ROOT
76 mkdir -p $RPM_BUILD_ROOT
77 mkdir -p $RPM_BUILD_ROOT/sbin
78 mkdir -p $RPM_BUILD_ROOT/etc/samba
79 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
80 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
81 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
82 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{images,help,include,using_samba}
83 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
84 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
85 mkdir -p $RPM_BUILD_ROOT/var/cache/samba
86 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
87 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
88 mkdir -p $RPM_BUILD_ROOT/lib/security
89 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
90 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
91
92 # Install standard binary files
93 for i in nmblookup smbclient smbpasswd smbstatus testparm testprns \
94       rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt
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
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         LIBDIR=$RPM_BUILD_ROOT/etc/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/usr/share/swat \
124         SAMBABOOK=$RPM_BUILD_ROOT/usr/share/swat/using_samba \
125         installman installswat
126 cd ..
127
128 # Install the nsswitch wins library
129 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
130
131 # Make link for wins resolver
132 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2; )
133
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
137
138 # Install pam_smbpass.so
139 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
140
141 # Install the VFS modules
142 #install -m755 examples/VFS/recycle.so $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
143 #install -m755 examples/VFS/audit.so $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
144 #install -m755 examples/VFS/netatalk.so $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
145
146 # clean out VFS directory since it will get installed as documentation later
147 #(cd examples/VFS; make clean)
148
149 # libsmbclient
150 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
151 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
152 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
153
154 # Install SWAT helper files
155 for i in swat/help/*.html docs/htmldocs/*.html
156 do
157         install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/help
158 done
159 for i in swat/images/*.gif
160 do
161         install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/images
162 done
163 for i in swat/include/*.html
164 do
165         install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/include
166 done
167
168 # Install the miscellany
169 install -m644 swat/README $RPM_BUILD_ROOT%{prefix}/share/swat
170 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
171 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
172 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
173 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
174 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
175 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
176 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
177 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
178 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
179 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
180 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
181
182 %clean
183 rm -rf $RPM_BUILD_ROOT
184
185 %post
186 /sbin/chkconfig --add smb
187 /sbin/chkconfig --add winbind
188 /sbin/chkconfig smb off
189 /sbin/chkconfig winbind off
190
191 echo "Looking for old /etc/smb.conf..."
192 if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
193         echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
194         mv /etc/smb.conf /etc/samba/smb.conf
195 fi
196
197 echo "Looking for old /etc/smbusers..."
198 if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
199         echo "Moving old /etc/smbusers to /etc/samba/smbusers"
200         mv /etc/smbusers /etc/samba/smbusers
201 fi
202
203 echo "Looking for old /etc/lmhosts..."
204 if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
205         echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
206         mv /etc/lmhosts /etc/samba/lmhosts
207 fi
208
209 echo "Looking for old /etc/MACHINE.SID..."
210 if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
211         echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
212         mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
213 fi
214
215 echo "Looking for old /etc/smbpasswd..."
216 if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
217         echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
218         mv /etc/smbpasswd /etc/samba/smbpasswd
219 fi
220
221 #
222 # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
223 # to preserve across reboots.
224 #
225 echo "Moving tdb files in /var/lock/samba/*.tdb to /var/cache/samba/*.tdb"
226 for i in /var/lock/samba/*.tdb
227 do
228 if [ -f $i ]; then
229         newname=`echo $i | sed -e's|var\/lock\/samba|var\/cache\/samba|'`
230         echo "Moving $i to $newname"
231         mv $i $newname
232 fi
233 done
234
235 # Remove the transient tdb files.
236 if [ -e /var/cache/samba/brlock.tdb ]; then
237         rm -f /var/cache/samba/brlock.tdb
238 fi
239
240 if [ -e /var/cache/samba/unexpected.tdb ]; then
241         rm -f /var/cache/samba/unexpected.tdb
242 fi
243
244 if [ -e /var/cache/samba/connections.tdb ]; then
245         rm -f /var/cache/samba/connections.tdb
246 fi
247
248 if [ -e /var/cache/samba/locking.tdb ]; then
249         rm -f /var/cache/samba/locking.tdb
250 fi
251
252 if [ -e /var/cache/samba/messages.tdb ]; then
253         rm -f /var/cache/samba/messages.tdb
254 fi
255
256 if [ -d /var/lock/samba ]; then
257         rm -rf /var/lock/samba
258 fi
259
260 # Add swat entry to /etc/services if not already there.
261 if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
262         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
263 fi
264
265 # Add swat entry to /etc/inetd.conf if needed.
266 if [ -f /etc/inetd.conf ]; then
267         if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
268                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
269         killall -1 inetd || :
270         fi
271 fi
272
273 # Add swat entry to xinetd.d if needed.
274 if [ -d $RPM_BUILD_ROOT/etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
275         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
276 else
277         rm -f /etc/samba/samba.xinetd
278 fi
279
280 # Install the correct version of the samba pam file, depending on pam version.
281 if [ -f /lib/security/pam_stack.so ]; then
282         echo "Installing stack version of /etc/pam.d/samba..."
283         mv /etc/samba/samba.stack /etc/pam.d/samba
284 else
285         echo "Installing non-stack version of /etc/pam.d/samba..."
286         rm -f /etc/samba/samba.stack
287 fi
288
289 # Create winbind nss client symlink
290
291 if [ -e /lib/libnss_winbind.so ]; then
292         ln -sf /lib/libnss_winbind.so /lib/libnss_winbind.so.2
293 fi
294
295 %preun
296 if [ $1 = 0 ] ; then
297         /sbin/chkconfig --del smb
298
299         # We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
300         if [ -e /var/cache/samba/browse.dat ]; then
301                 rm -f /var/cache/samba/browse.dat
302         fi
303         if [ -e /var/cache/samba/wins.dat ]; then
304                 rm -f /var/cache/samba/wins.dat
305         fi
306
307         # Remove the transient tdb files.
308         if [ -e /var/cache/samba/brlock.tdb ]; then
309                 rm -f /var/cache/samba/brlock.tdb
310         fi
311
312         if [ -e /var/cache/samba/unexpected.tdb ]; then
313                 rm -f /var/cache/samba/unexpected.tdb
314         fi
315
316         if [ -e /var/cache/samba/connections.tdb ]; then
317                 rm -f /var/cache/samba/connections.tdb
318         fi
319
320         if [ -e /var/cache/samba/locking.tdb ]; then
321                 rm -f /var/cache/samba/locking.tdb
322         fi
323
324         if [ -e /var/cache/samba/messages.tdb ]; then
325                 rm -f /var/cache/samba/messages.tdb
326         fi
327
328         # Remove winbind nss client symlink
329
330         if [ -L /lib/libnss_winbind.so.2 ]; then
331                 rm -f /lib/libnss_winbind.so.2
332         fi
333 fi
334
335 %postun
336 # Only delete remnants of samba if this is the final deletion.
337 if [ $1 = 0 ] ; then
338     if [ -x /etc/pam.d/samba ]; then
339       rm -f /etc/pam.d/samba
340     fi
341     if [ -e /var/log/samba ]; then
342       rm -rf /var/log/samba
343     fi
344         if [ -e /var/cache/samba ]; then
345                 rm -rf /var/cache/samba
346         fi
347
348     # Remove swat entries from /etc/inetd.conf and /etc/services
349     cd /etc
350     tmpfile=/etc/tmp.$$
351         if [ -f /etc/inetd.conf ]; then
352       # preserve inetd.conf permissions.
353       cp -p /etc/inetd.conf $tmpfile
354       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
355       mv $tmpfile inetd.conf
356         fi
357     # preserve services permissions.
358     cp -p /etc/services $tmpfile
359     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
360     mv $tmpfile /etc/services
361
362         # Remove swat entry from /etc/xinetd.d
363         if [ -f /etc/xinetd.d/swat ]; then
364                 rm -r /etc/xinetd.d/swat
365         fi
366 fi
367
368 %triggerpostun -- samba < samba-2.0.0
369 if [ $0 != 0 ]; then
370     /sbin/chkconfig --add smb
371 fi
372
373 %files
374 %defattr(-,root,root)
375 %doc README COPYING Manifest Read-Manifest-Now
376 %doc WHATSNEW.txt Roadmap
377 %doc docs
378 %doc swat/README
379 %doc examples
380 %{prefix}/sbin/smbd
381 %{prefix}/sbin/nmbd
382 %{prefix}/sbin/swat
383 %{prefix}/bin/smbmnt
384 %{prefix}/sbin/smbmount
385 %{prefix}/sbin/smbumount
386 %{prefix}/sbin/winbindd
387 /sbin/mount.smbfs
388 /sbin/mount.smb
389 %{prefix}/bin/mksmbpasswd.sh
390 %{prefix}/bin/smbclient
391 %{prefix}/bin/smbspool
392 %{prefix}/bin/rpcclient
393 %{prefix}/bin/testparm
394 %{prefix}/bin/testprns
395 %{prefix}/bin/findsmb
396 %{prefix}/bin/smbstatus
397 %{prefix}/bin/nmblookup
398 %{prefix}/bin/smbpasswd
399 %{prefix}/bin/smbtar
400 %{prefix}/bin/smbprint
401 %{prefix}/bin/smbcontrol
402 %{prefix}/bin/smbcacls
403 %{prefix}/bin/wbinfo
404 %attr(755,root,root) /lib/libnss_wins.s*
405 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
406 %{prefix}/include/libsmbclient.h
407 %{prefix}/lib/libsmbclient.a
408 %{prefix}/lib/libsmbclient.so
409 %{prefix}/share/swat/help/*
410 %{prefix}/share/swat/images/*
411 %{prefix}/share/swat/include/header.html
412 %{prefix}/share/swat/include/footer.html
413 %{prefix}/share/swat/using_samba/*
414 %config(noreplace) /etc/samba/lmhosts
415 %config(noreplace) /etc/samba/smb.conf
416 %config(noreplace) /etc/samba/smbusers
417 /etc/samba/samba.stack
418 /etc/samba/samba.xinetd
419 /etc/rc.d/init.d/smb
420 /etc/rc.d/init.d/winbind
421 /etc/logrotate.d/samba
422 %config(noreplace) /etc/pam.d/samba
423 MANDIR_MACRO/man1/*
424 MANDIR_MACRO/man5/*
425 MANDIR_MACRO/man7/*
426 MANDIR_MACRO/man8/*
427 %attr(755,root,root) %dir /var/cache/samba
428 %dir /var/log/samba
429 %dir /var/run/samba
430 %attr(1777,root,root) %dir /var/spool/samba
431 %attr(-,root,root) /lib/libnss_winbind.so
432 %attr(-,root,root) /lib/security/pam_winbind.so
433 %attr(-,root,root) /lib/security/pam_smbpass.so