r11065: rename wr_eventlog to eventlogadm
[ira/wip.git] / packaging / RedHat / samba.spec.tmpl
1 ## grab the major and minor version of rpm 
2 %define rpm_version `rpm --version | awk '{print $3}' | awk -F. '{print $1$2}'`
3
4 Summary: Samba SMB client and server
5 Vendor: Samba Team
6 Name: samba
7 Version: PVERSION
8 Release: PRELEASE
9 License: GNU GPL version 2
10 Group: Networking
11 Source: http://download.samba.org/samba/ftp/samba-%{version}.tar.bz2
12
13 # Don't depend on Net::LDAP
14 # one filter for RH 8 and one for 9
15 Source998: filter-requires-samba_rh8.sh
16 Source999: filter-requires-samba_rh9.sh
17
18 Packager: Gerald Carter [Samba-Team] <jerry@samba.org>
19 Requires: pam openldap krb5-libs cups
20 BuildRequires: openldap-devel krb5-devel pam-devel cups-devel
21 Prereq: chkconfig fileutils /sbin/ldconfig
22 Provides: samba = %{version}
23 Obsoletes: samba-common, samba-client, samba-swat
24 BuildRoot: %{_tmppath}/%{name}-%{version}-root
25 Prefix: /usr
26
27 %description
28 Samba provides an SMB/CIFS server which can be used to provide
29 network file and print services to SMB/CIFS clients, including 
30 various versions of MS Windows, OS/2, and other Linux machines. 
31 Samba also provides some SMB clients, which complement the 
32 built-in SMB filesystem in Linux. Samba uses NetBIOS over TCP/IP 
33 (NetBT) protocols and does NOT need NetBEUI (Microsoft Raw NetBIOS 
34 frame) protocol.
35
36 Samba 3.0 also introduces UNICODE support and kerberos/ldap
37 integration as a member server in a Windows 2000 domain.
38
39 Please refer to the WHATSNEW.txt document for fixup information.
40 docs directory for implementation details.
41
42 %changelog
43 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
44   - removed change log entries since history
45     is being maintained in CVS
46
47 %prep
48 %setup
49
50 %build
51
52 # Working around perl dependency problem from docs
53 # Only > RH 8.0 seems to care here
54
55 echo "rpm_version == %{rpm_version}"
56 if [ "%{rpm_version}" == "42" ]; then
57    %define __perl_requires %{SOURCE999}
58    echo "%{__perl_requires}"
59 elif [ "%{rpm_version}" == "41" ]; then
60    %define __find_requires %{SOURCE998}
61    echo "%{__find_requires}"
62 fi
63
64 ## Build main Samba source
65 cd source
66
67 %ifarch ia64
68 libtoolize --copy --force     # get it to recognize IA-64
69 autoheader
70 autoconf
71 EXTRA="-D_LARGEFILE64_SOURCE"
72 %endif
73
74 ## Get number of cpu's, default for 1 cpu on error 
75 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
76 if [ $NUMCPU -eq 0 ]; then
77         NUMCPU=1;
78 fi 
79
80 ## run autogen if missing the configure script
81 if [ ! -f "configure" ]; then
82         ./autogen.sh
83 fi
84
85 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
86         --prefix=%{prefix} \
87         --localstatedir=/var \
88         --with-configdir=/etc/samba \
89         --with-privatedir=/etc/samba \
90         --with-fhs \
91         --with-quotas \
92         --with-smbmount \
93         --enable-cups \
94         --with-pam \
95         --with-pam_smbpass \
96         --with-syslog \
97         --with-utmp \
98         --with-sambabook=%{prefix}/share/swat/using_samba \
99         --with-swatdir=%{prefix}/share/swat \
100         --with-shared-modules=idmap_rid \
101         --with-libsmbclient 
102 make -j${NUMCPU} proto
103 make -j${NUMCPU} all modules nsswitch/libnss_wins.so 
104 make -j${NUMCPU} debug2html
105
106 # Remove some permission bits to avoid to many dependencies
107 find examples docs -type f | xargs -r chmod -x
108
109 %install
110 rm -rf $RPM_BUILD_ROOT
111 mkdir -p $RPM_BUILD_ROOT
112 mkdir -p $RPM_BUILD_ROOT/sbin
113 mkdir -p $RPM_BUILD_ROOT/etc/samba
114 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
115 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
116 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
117 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{images,help,include,using_samba}
118 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
119 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
120 mkdir -p $RPM_BUILD_ROOT/var/lib/samba
121 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
122 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
123 mkdir -p $RPM_BUILD_ROOT/lib/security
124 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
125 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
126
127 # Install standard binary files
128 for i in nmblookup smbclient smbpasswd smbstatus testparm \
129         rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt net \
130         smbcacls pdbedit tdbbackup smbtree ntlm_auth smbcquotas
131 do
132         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/bin
133 done
134
135 for i in mksmbpasswd.sh smbtar findsmb
136 do
137         install -m755 source/script/$i $RPM_BUILD_ROOT%{prefix}/bin
138 done
139
140 # Install secure binary files
141 for i in smbd nmbd swat smbmount smbumount debug2html winbindd 
142 do
143         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/sbin
144 done
145
146 # we need a symlink for mount to recognise the smb and smbfs filesystem types
147 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
148 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
149
150 # This allows us to get away without duplicating code that 
151 #  sombody else can maintain for us.  
152 cd source
153 make DESTDIR=$RPM_BUILD_ROOT \
154         BASEDIR=/usr \
155         CONFIGDIR=/etc/samba \
156         LIBDIR=%{prefix}/lib/samba \
157         VARDIR=/var \
158         SBINDIR=%{prefix}/sbin \
159         BINDIR=%{prefix}/bin \
160         MANDIR=MANDIR_MACRO \
161         SWATDIR=%{prefix}/share/swat \
162         SAMBABOOK=%{prefix}/share/swat/using_samba \
163         installman installswat installdat installmodules
164 cd ..
165
166 ## don't duplicate the docs.  These are installed with SWAT
167 rm -rf docs/htmldocs
168 rm -rf docs/manpages
169 ( cd docs; ln -s %{prefix}/share/swat/help htmldocs )
170
171
172
173 # Install the nsswitch wins library
174 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
175 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2 )
176
177 # Install winbind shared libraries
178 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
179 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_winbind.so libnss_winbind.so.2 )
180 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
181
182 # Install pam_smbpass.so
183 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
184
185 # libsmbclient
186 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
187 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
188 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
189
190 # Install the miscellany
191 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
192 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
193 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
194 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
195 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
196 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
197 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
198 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
199 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
200 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
201 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
202
203 # Remove "*.old" files
204 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
205
206 ##
207 ## Clean out man pages for tools not installed here
208 ##
209 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/editreg.1*
210 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
211 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
212 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbget.1*
213 rm -f $RPM_BUILD_ROOT/%{_mandir}/man8/mount.cifs.8*
214
215
216 %clean
217 rm -rf $RPM_BUILD_ROOT
218
219 %post
220 ## 
221 ## only needed if this is a new install (not an upgrade)
222 ##
223 if [ "$1" -eq "1" ]; then
224         /sbin/chkconfig --add smb
225         /sbin/chkconfig --add winbind
226         /sbin/chkconfig smb off
227         /sbin/chkconfig winbind off
228 fi
229
230 ##
231 ## we only have to wory about this if we are upgrading
232 ##
233 if [ "$1" -eq "2" ]; then
234         if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
235                 echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
236                 mv /etc/smb.conf /etc/samba/smb.conf
237         fi
238
239         if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
240                 echo "Moving old /etc/smbusers to /etc/samba/smbusers"
241                 mv /etc/smbusers /etc/samba/smbusers
242         fi
243
244         if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
245                 echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
246                 mv /etc/lmhosts /etc/samba/lmhosts
247         fi
248
249         if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
250                 echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
251                 mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
252         fi
253
254         if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
255                 echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
256                 mv /etc/smbpasswd /etc/samba/smbpasswd
257         fi
258
259         #
260         # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
261         # to preserve across reboots.
262         #
263         for i in /var/lock/samba/*.tdb; do
264                 if [ -f $i ]; then
265                         newname="/var/lib/samba/`basename $i`"
266                         echo "Moving $i to $newname"
267                         mv $i $newname
268                 fi
269         done
270
271         #
272         # For 3.0.1 we move the tdb files from /var/cache/samba to /var/lib/samba
273         #
274         echo "Moving tdb files in /var/cache/samba/*.tdb to /var/lib/samba/*.tdb"
275         for i in /var/cache/samba/*.tdb; do
276                 if [ -f $i ]; then
277                         newname="/var/lib/samba/`basename $i`"
278                         echo "Moving $i to $newname"
279                         mv $i $newname
280                 fi
281         done
282 fi
283
284 ##
285 ## New things
286 ##
287
288 # Add swat entry to /etc/services if not already there.
289 if [ ! "`grep ^\s**swat /etc/services`" ]; then
290         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
291 fi
292
293 # Add swat entry to /etc/inetd.conf if needed.
294 if [ -f /etc/inetd.conf ]; then
295         if [ ! "`grep ^\s*swat /etc/inetd.conf`" ]; then
296                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
297         killall -HUP inetd || :
298         fi
299 fi
300
301 # Add swat entry to xinetd.d if needed.
302 if [ -d /etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
303         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
304 else
305         rm -f /etc/samba/samba.xinetd
306 fi
307
308 # Install the correct version of the samba pam file
309 if [ -f /lib/security/pam_stack.so ]; then
310         echo "Installing stack version of /etc/pam.d/samba..."
311         mv /etc/samba/samba.stack /etc/pam.d/samba
312 else
313         echo "Installing non-stack version of /etc/pam.d/samba..."
314         rm -f /etc/samba/samba.stack
315 fi
316
317 ## call ldconfig to create the version symlink for libsmbclient.so
318 /sbin/ldconfig
319
320 %preun
321 if [ "$1" -eq "0" ] ; then
322         /sbin/chkconfig --del smb
323         /sbin/chkconfig --del winbind
324
325         # We want to remove the browse.dat and wins.dat files 
326         # so they can not interfer with a new version of samba!
327         if [ -e /var/lib/samba/browse.dat ]; then
328                 rm -f /var/lib/samba/browse.dat
329         fi
330         if [ -e /var/lib/samba/wins.dat ]; then
331                 rm -f /var/lib/samba/wins.dat
332         fi
333
334         # Remove the transient tdb files.
335         if [ -e /var/lib/samba/brlock.tdb ]; then
336                 rm -f /var/lib/samba/brlock.tdb
337         fi
338
339         if [ -e /var/lib/samba/unexpected.tdb ]; then
340                 rm -f /var/lib/samba/unexpected.tdb
341         fi
342
343         if [ -e /var/lib/samba/connections.tdb ]; then
344                 rm -f /var/lib/samba/connections.tdb
345         fi
346
347         if [ -e /var/lib/samba/locking.tdb ]; then
348                 rm -f /var/lib/samba/locking.tdb
349         fi
350
351         if [ -e /var/lib/samba/messages.tdb ]; then
352                 rm -f /var/lib/samba/messages.tdb
353         fi
354 fi
355
356 %postun
357 # Only delete remnants of samba if this is the final deletion.
358 if [ "$1" -eq  "0" ] ; then
359     if [ -x /etc/pam.d/samba ]; then
360       rm -f /etc/pam.d/samba
361     fi
362
363     if [ -e /var/log/samba ]; then
364       rm -rf /var/log/samba
365     fi
366
367     if [ -e /var/lib/samba ]; then
368       rm -rf /var/lib/samba
369     fi
370
371     # Remove swat entries from /etc/inetd.conf and /etc/services
372     cd /etc
373     tmpfile=/etc/tmp.$$
374     if [ -f /etc/inetd.conf ]; then
375       # preserve inetd.conf permissions.
376       cp -p /etc/inetd.conf $tmpfile
377       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
378       mv $tmpfile inetd.conf
379     fi
380
381     # preserve services permissions.
382     cp -p /etc/services $tmpfile
383     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
384     mv $tmpfile /etc/services
385
386     # Remove swat entry from /etc/xinetd.d
387     if [ -f /etc/xinetd.d/swat ]; then
388       rm -r /etc/xinetd.d/swat
389     fi
390 fi
391
392 /sbin/ldconfig
393
394 %files
395 %defattr(-,root,root)
396 %doc README COPYING Manifest Read-Manifest-Now
397 %doc WHATSNEW.txt Roadmap
398 %doc docs
399 %doc examples
400 %{prefix}/sbin/smbd
401 %{prefix}/sbin/nmbd
402 %{prefix}/sbin/swat
403 %{prefix}/bin/smbmnt
404 %{prefix}/sbin/smbmount
405 %{prefix}/sbin/smbumount
406 %{prefix}/sbin/winbindd
407 %{prefix}/sbin/samba
408 %{prefix}/sbin/debug2html
409 /sbin/mount.smbfs
410 /sbin/mount.smb
411 %{prefix}/bin/mksmbpasswd.sh
412 %{prefix}/bin/smbclient
413 %{prefix}/bin/smbspool
414 %{prefix}/bin/rpcclient
415 %{prefix}/bin/testparm
416 %{prefix}/bin/findsmb
417 %{prefix}/bin/smbstatus
418 %{prefix}/bin/nmblookup
419 %{prefix}/bin/smbpasswd
420 %{prefix}/bin/smbtar
421 %{prefix}/bin/smbprint
422 %{prefix}/bin/smbcontrol
423 %{prefix}/bin/wbinfo
424 %{prefix}/bin/net
425 %{prefix}/bin/ntlm_auth
426 %{prefix}/bin/smbcquotas
427 %{prefix}/bin/smbcacls
428 %{prefix}/bin/pdbedit
429 %{prefix}/bin/tdbbackup
430 %{prefix}/bin/smbtree
431 %attr(755,root,root) /lib/libnss_wins.s*
432 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
433 %attr(755,root,root) %{prefix}/lib/samba/charset/*.so
434 %attr(755,root,root) %{prefix}/lib/samba/idmap/*.so
435 #%attr(755,root,root) %{prefix}/lib/samba/pdb/*.so
436 %attr(755,root,root) %{prefix}/lib/samba/*.dat
437 %attr(755,root,root) %{prefix}/lib/samba/*.msg
438 %{prefix}/include/libsmbclient.h
439 %{prefix}/lib/libsmbclient.a
440 %{prefix}/lib/libsmbclient.so
441 %{prefix}/share/swat/help/*
442 %{prefix}/share/swat/images/*
443 %{prefix}/share/swat/include/*.html
444 %{prefix}/share/swat/lang/*/help/*
445 %{prefix}/share/swat/lang/*/images/*
446 %{prefix}/share/swat/using_samba/*
447 %config(noreplace) /etc/samba/lmhosts
448 %config(noreplace) /etc/samba/smb.conf
449 %config(noreplace) /etc/samba/smbusers
450 /etc/samba/samba.stack
451 /etc/samba/samba.xinetd
452 /etc/rc.d/init.d/smb
453 /etc/rc.d/init.d/winbind
454 /etc/logrotate.d/samba
455 %config(noreplace) /etc/pam.d/samba
456 MANDIR_MACRO/man1/*
457 MANDIR_MACRO/man5/*
458 MANDIR_MACRO/man7/*
459 MANDIR_MACRO/man8/*
460 %attr(755,root,root) %dir /var/lib/samba
461 %dir /var/log/samba
462 %dir /var/run/samba
463 %attr(1777,root,root) %dir /var/spool/samba
464 %attr(-,root,root) /lib/libnss_winbind.so*
465 %attr(-,root,root) /lib/security/pam_winbind.so
466 %attr(-,root,root) /lib/security/pam_smbpass.so