restore structures from previous erroneous commit
[Samba/ekacnet.git] / packaging / RedHat / samba2.spec.tmpl
blob638df4f2cce90e733d4fddb37b2902ba573325d5
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
130 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2; )
132 # Install winbind shared libraries
133 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
134 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_winbind.so libnss_winbind.so.2; )
135 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
137 # Install pam_smbpass.so
138 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
140 # libsmbclient
141 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
142 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
143 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
145 # Install SWAT helper files
146 #for i in swat/help/*.html docs/htmldocs/*.html
148 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/help
149 #done
150 #for i in swat/images/*.gif
152 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/images
153 #done
154 #for i in swat/include/*.html
156 #       install -m644 $i $RPM_BUILD_ROOT%{prefix}/share/swat/include
157 #done
159 # Install the miscellany
160 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
161 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
162 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
163 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
164 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
165 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
166 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
167 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
168 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
169 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
170 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
172 %clean
173 rm -rf $RPM_BUILD_ROOT
175 %post
176 /sbin/chkconfig --add smb
177 /sbin/chkconfig --add winbind
178 /sbin/chkconfig smb off
179 /sbin/chkconfig winbind off
181 echo "Looking for old /etc/smb.conf..."
182 if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
183         echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
184         mv /etc/smb.conf /etc/samba/smb.conf
187 echo "Looking for old /etc/smbusers..."
188 if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
189         echo "Moving old /etc/smbusers to /etc/samba/smbusers"
190         mv /etc/smbusers /etc/samba/smbusers
193 echo "Looking for old /etc/lmhosts..."
194 if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
195         echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
196         mv /etc/lmhosts /etc/samba/lmhosts
199 echo "Looking for old /etc/MACHINE.SID..."
200 if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
201         echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
202         mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
205 echo "Looking for old /etc/smbpasswd..."
206 if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
207         echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
208         mv /etc/smbpasswd /etc/samba/smbpasswd
212 # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
213 # to preserve across reboots.
215 echo "Moving tdb files in /var/lock/samba/*.tdb to /var/cache/samba/*.tdb"
216 for i in /var/lock/samba/*.tdb
218 if [ -f $i ]; then
219         newname=`echo $i | sed -e's|var\/lock\/samba|var\/cache\/samba|'`
220         echo "Moving $i to $newname"
221         mv $i $newname
223 done
225 # Remove the transient tdb files.
226 if [ -e /var/cache/samba/brlock.tdb ]; then
227         rm -f /var/cache/samba/brlock.tdb
230 if [ -e /var/cache/samba/unexpected.tdb ]; then
231         rm -f /var/cache/samba/unexpected.tdb
234 if [ -e /var/cache/samba/connections.tdb ]; then
235         rm -f /var/cache/samba/connections.tdb
238 if [ -e /var/cache/samba/locking.tdb ]; then
239         rm -f /var/cache/samba/locking.tdb
242 if [ -e /var/cache/samba/messages.tdb ]; then
243         rm -f /var/cache/samba/messages.tdb
246 if [ -d /var/lock/samba ]; then
247         rm -rf /var/lock/samba
250 # Add swat entry to /etc/services if not already there.
251 if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
252         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
255 # Add swat entry to /etc/inetd.conf if needed.
256 if [ -f /etc/inetd.conf ]; then
257         if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
258                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
259         killall -1 inetd || :
260         fi
263 # Add swat entry to xinetd.d if needed.
264 if [ -d $RPM_BUILD_ROOT/etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
265         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
266 else
267         rm -f /etc/samba/samba.xinetd
270 # Install the correct version of the samba pam file, depending on pam version.
271 if [ -f /lib/security/pam_stack.so ]; then
272         echo "Installing stack version of /etc/pam.d/samba..."
273         mv /etc/samba/samba.stack /etc/pam.d/samba
274 else
275         echo "Installing non-stack version of /etc/pam.d/samba..."
276         rm -f /etc/samba/samba.stack
279 # Create winbind nss client symlink
281 if [ -e /lib/libnss_winbind.so ]; then
282         ln -sf /lib/libnss_winbind.so /lib/libnss_winbind.so.2
285 %preun
286 if [ $1 = 0 ] ; then
287         /sbin/chkconfig --del smb
289         # We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
290         if [ -e /var/cache/samba/browse.dat ]; then
291                 rm -f /var/cache/samba/browse.dat
292         fi
293         if [ -e /var/cache/samba/wins.dat ]; then
294                 rm -f /var/cache/samba/wins.dat
295         fi
297         # Remove the transient tdb files.
298         if [ -e /var/cache/samba/brlock.tdb ]; then
299                 rm -f /var/cache/samba/brlock.tdb
300         fi
302         if [ -e /var/cache/samba/unexpected.tdb ]; then
303                 rm -f /var/cache/samba/unexpected.tdb
304         fi
306         if [ -e /var/cache/samba/connections.tdb ]; then
307                 rm -f /var/cache/samba/connections.tdb
308         fi
310         if [ -e /var/cache/samba/locking.tdb ]; then
311                 rm -f /var/cache/samba/locking.tdb
312         fi
314         if [ -e /var/cache/samba/messages.tdb ]; then
315                 rm -f /var/cache/samba/messages.tdb
316         fi
318         # Remove winbind nss client symlink
320         if [ -L /lib/libnss_winbind.so.2 ]; then
321                 rm -f /lib/libnss_winbind.so.2
322         fi
325 %postun
326 # Only delete remnants of samba if this is the final deletion.
327 if [ $1 = 0 ] ; then
328     if [ -x /etc/pam.d/samba ]; then
329       rm -f /etc/pam.d/samba
330     fi
331     if [ -e /var/log/samba ]; then
332       rm -rf /var/log/samba
333     fi
334         if [ -e /var/cache/samba ]; then
335                 rm -rf /var/cache/samba
336         fi
338     # Remove swat entries from /etc/inetd.conf and /etc/services
339     cd /etc
340     tmpfile=/etc/tmp.$$
341         if [ -f /etc/inetd.conf ]; then
342       # preserve inetd.conf permissions.
343       cp -p /etc/inetd.conf $tmpfile
344       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
345       mv $tmpfile inetd.conf
346         fi
347     # preserve services permissions.
348     cp -p /etc/services $tmpfile
349     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
350     mv $tmpfile /etc/services
352         # Remove swat entry from /etc/xinetd.d
353         if [ -f /etc/xinetd.d/swat ]; then
354                 rm -r /etc/xinetd.d/swat
355         fi
358 %files
359 %defattr(-,root,root)
360 %doc README COPYING Manifest Read-Manifest-Now
361 %doc WHATSNEW.txt Roadmap
362 %doc docs
363 %doc swat/README
364 %doc examples
365 %{prefix}/sbin/smbd
366 %{prefix}/sbin/nmbd
367 %{prefix}/sbin/swat
368 %{prefix}/bin/smbmnt
369 %{prefix}/sbin/smbmount
370 %{prefix}/sbin/smbumount
371 %{prefix}/sbin/winbindd
372 %{prefix}/sbin/wrepld
373 %{prefix}/sbin/samba
374 %{prefix}/sbin/debug2html
375 /sbin/mount.smbfs
376 /sbin/mount.smb
377 %{prefix}/bin/mksmbpasswd.sh
378 %{prefix}/bin/smbclient
379 %{prefix}/bin/smbspool
380 %{prefix}/bin/rpcclient
381 %{prefix}/bin/testparm
382 %{prefix}/bin/testprns
383 %{prefix}/bin/findsmb
384 %{prefix}/bin/smbstatus
385 %{prefix}/bin/nmblookup
386 %{prefix}/bin/smbpasswd
387 %{prefix}/bin/smbtar
388 %{prefix}/bin/smbprint
389 %{prefix}/bin/smbcontrol
390 %{prefix}/bin/wbinfo
391 %{prefix}/bin/net
392 %{prefix}/bin/smbgroupedit
393 %{prefix}/bin/smbcacls
394 %{prefix}/bin/pdbedit
395 %{prefix}/bin/tdbbackup
396 %{prefix}/bin/smbtree
397 %attr(755,root,root) /lib/libnss_wins.s*
398 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
399 %attr(755,root,root) %{prefix}/lib/samba/*.dat
400 %{prefix}/include/libsmbclient.h
401 %{prefix}/lib/libsmbclient.a
402 %{prefix}/lib/libsmbclient.so
403 %{prefix}/share/swat/help/*
404 %{prefix}/share/swat/images/*
405 %{prefix}/share/swat/include/*.html
406 %{prefix}/share/swat/lang/*/help/*
407 %{prefix}/share/swat/lang/*/images/*
408 %{prefix}/share/swat/lang/*/include/*.html
409 %{prefix}/share/swat/using_samba/*
410 %config(noreplace) /etc/samba/lmhosts
411 %config(noreplace) /etc/samba/smb.conf
412 %config(noreplace) /etc/samba/smbusers
413 /etc/samba/samba.stack
414 /etc/samba/samba.xinetd
415 /etc/rc.d/init.d/smb
416 /etc/rc.d/init.d/winbind
417 /etc/logrotate.d/samba
418 %config(noreplace) /etc/pam.d/samba
419 MANDIR_MACRO/man1/*
420 MANDIR_MACRO/man5/*
421 MANDIR_MACRO/man7/*
422 MANDIR_MACRO/man8/*
423 %attr(755,root,root) %dir /var/cache/samba
424 %dir /var/log/samba
425 %dir /var/run/samba
426 %attr(1777,root,root) %dir /var/spool/samba
427 %attr(-,root,root) /lib/libnss_winbind.so
428 %attr(-,root,root) /lib/security/pam_winbind.so
429 %attr(-,root,root) /lib/security/pam_smbpass.so