r3778: BUG 2023: patch from Buchan Milne <bgmilne@mandrake.org> fix mandrake packagin...
[ira/wip.git] / packaging / Mandrake / samba2.spec.tmpl
index c55da187de83d96b51c3d3ee55e8f28632e1a8e2..7b6bc2c49bc9c898ed539ffeb8dff15d4f186838 100644 (file)
@@ -1,4 +1,4 @@
-# Note that this file exists in Mandrake packaging cvs (as samba3.spec)
+# Note that this file exists in Mandrake packaging cvs (as samba.spec)
 # and samba cvs (as packaging/Mandrake/samba2.spec.tmpl).
 # Keep in mind that any changes should take both locations into account
 # Considerable effort has gone into making this possible, so that only
 # cvs should be submitted for inclusion in samba cvs.
 
 %define pkg_name       samba
-%define ver            3.0.0beta3
-%define rel            3mdk
-%define vscanver       0.3.3beta1
+%define ver            3.0.8
+%define drel           1
+%define        subrel          1
+%define vscanver       0.3.5
 %define libsmbmajor    0
+%{?!mdkversion: %define mdkversion %(perl -pe '/(\d+)\.(\d)\.?(\d)?/; $_="$1$2".($3||0)' /etc/mandrake-release)}
+%define rel            %(case `hostname` in (n?.mandrakesoft.com) echo %drel;;(*) echo $[%drel-1].%subrel.$[%mdkversion/10];;esac)mdk
+%{?_with_stable_on_cluster: %define rel %(echo $[%{drel}-1].%subrel.$[%{mdkversion}/10]mdk)}
+%{?_with_official: %define rel %drel}
+
+%{!?lib: %global lib lib}
+%{!?mklibname: %global mklibname(ds) %lib%{1}%{?2:%{2}}%{?3:_%{3}}%{-s:-static}%{-d:-devel}}
+
+%define libname %mklibname smbclient %libsmbmajor
 
 # Version and release replaced by samba-team at release from samba cvs
 %define pversion PVERSION
@@ -28,6 +38,7 @@
 
 %if %have_pversion
 %define source_ver     %{pversion}
+# Don't abort for stupid reasons on builds from tarballs:
 %global        _unpackaged_files_terminate_build       0
 %global        _missing_doc_files_terminate_build      0
 %else
 %endif
 
 # We now do detection of the Mandrake release we are building on:
-#%define build_cooker %(if [ `awk '{print $3}' /etc/mandrake-release` = "Cooker" ];then echo 1; else echo 0; fi)
-#%define build_cooker %(if [[ `cat /etc/mandrake-release|grep Cooker` ]];then echo 1; else echo 0; fi)
-%define build_mdk92 %(if [ `awk '{print $4}' /etc/mandrake-release` = 9.2 ];then echo 1; else echo 0; fi)
-%define build_mdk91 %(if [ `awk '{print $4}' /etc/mandrake-release` = 9.1 ];then echo 1; else echo 0; fi)
-%define build_mdk90 %(if [ `awk '{print $4}' /etc/mandrake-release` = 9.0 ];then echo 1; else echo 0; fi)
 %define build_mdk82 %(if [ `awk '{print $4}' /etc/mandrake-release` = 8.2 ];then echo 1; else echo 0; fi)
 %define build_mdk81 %(if [ `awk '{print $4}' /etc/mandrake-release` = 8.1 ];then echo 1; else echo 0; fi)
 %define build_mdk80 %(if [ `awk '{print $4}' /etc/mandrake-release` = 8.0 ];then echo 1; else echo 0; fi)
@@ -63,6 +69,7 @@
 %define build_non_default 0
 
 # Default options
+%define build_alternatives     0
 %define build_system   0
 %define build_acl      1
 %define build_winbind  1
 %define build_scanners 0
 # CUPS supports functionality for 'printcap name = cups' (9.0 and later):
 %define build_cupspc   0
-# releases that have chrpath available in main
-%define build_chrpath  0
+# %_{pre,postun}_service are provided by rpm-helper in 9.0 and later
+%define have_rpmhelper 1
 
 # Set defaults for each version
-%if %build_mdk92
-%define build_cupspc   1
-%define build_chrpath  1
+%if %mdkversion >= 1000
+%define build_system   1
 %endif
 
-%if %build_mdk91
-%define build_cupspc   1
-%define build_chrpath  1
+%if %mdkversion >= 920
+%define build_alternatives     1
 %endif
 
-%if %build_mdk90
-%define build_chrpath  1
+%if %mdkversion >= 910
+%define build_cupspc   1
 %endif
 
 %if %build_mdk82
+%define have_rpmhelper 0
 %endif
 
 %if %build_mdk81
 %define build_winbind  0
 %define build_wins     0
+%define have_rpmhelper 0
 %endif
 
 %if %build_mdk80
 %define build_winbind  0
 %define build_wins     0
 %define build_ads      0
+%define have_rpmhelper 1
 %endif
 
 %if %build_mdk72
 %define build_winbind  0
 %define build_wins     0
 %define build_ads      0
+%define have_rpmhelper 1
 %endif
 
 
 # To use it, do rpm [-ba|--rebuild] --with 'xxx'
 # Check if the rpm was built with the defaults, otherwise we inform the user
 %define build_non_default 0
-%{?_with_system: %{expand: %%global build_system 1}}
-%{?_without_system: %{expand: %%global build_system 0}}
-%{?_with_acl: %{expand: %%global build_acl 1}}
-%{?_with_acl: %{expand: %%global build_non_default 1}}
-%{?_without_acl: %{expand: %%global build_acl 0}}
-%{?_without_acl: %{expand: %%global build_non_default 1}}
-%{?_with_winbind: %{expand: %%global build_winbind 1}}
-%{?_with_winbind: %{expand: %%global build_non_default 1}}
-%{?_without_winbind: %{expand: %%global build_winbind 0}}
-%{?_without_winbind: %{expand: %%global build_non_default 1}}
-%{?_with_wins: %{expand: %%global build_wins 1}}
-%{?_with_wins: %{expand: %%global build_non_default 1}}
-%{?_without_wins: %{expand: %%global build_wins 0}}
-%{?_without_wins: %{expand: %%global build_non_default 1}}
-%{?_with_ldap: %{expand: %%global build_ldap 1}}
-%{?_with_ldap: %{expand: %%global build_non_default 1}}
-%{?_without_ldap: %{expand: %%global build_ldap 0}}
-%{?_without_ldap: %{expand: %%global build_non_default 1}}
-%{?_with_ads: %{expand: %%global build_ads 1}}
-%{?_with_ads: %{expand: %%global build_non_default 1}}
-%{?_without_ads: %{expand: %%global build_ads 0}}
-%{?_without_ads: %{expand: %%global build_non_default 1}}
-%{?_with_scanners: %{expand: %%global build_scanners 1}}
-%{?_with_scanners: %{expand: %%global build_non_default 1}}
+%{?_with_system: %global build_system 1}
+%{?_without_system: %global build_system 0}
+%{?_with_acl: %global build_acl 1}
+%{?_with_acl: %global build_non_default 1}
+%{?_without_acl: %global build_acl 0}
+%{?_without_acl: %global build_non_default 1}
+%{?_with_winbind: %global build_winbind 1}
+%{?_with_winbind: %global build_non_default 1}
+%{?_without_winbind: %global build_winbind 0}
+%{?_without_winbind: %global build_non_default 1}
+%{?_with_wins: %global build_wins 1}
+%{?_with_wins: %global build_non_default 1}
+%{?_without_wins: %global build_wins 0}
+%{?_without_wins: %global build_non_default 1}
+%{?_with_ldap: %global build_ldap 1}
+%{?_with_ldap: %global build_non_default 1}
+%{?_without_ldap: %global build_ldap 0}
+%{?_without_ldap: %global build_non_default 1}
+%{?_with_ads: %global build_ads 1}
+%{?_with_ads: %global build_non_default 1}
+%{?_without_ads: %global build_ads 0}
+%{?_without_ads: %global build_non_default 1}
+%{?_with_scanners: %global build_scanners 1}
+%{?_with_scanners: %global build_non_default 1}
+%{?_without_scanners: %global build_scanners 0}
+%{?_without_scanners: %global build_non_default 1}
+%{?_with_vscan: %global build_vscan 1}
+%{?_with_vscan: %global build_non_default 1}
+%{?_without_vscan: %global build_vscan 0}
+%{?_without_vscan: %global build_non_default 1}
 
 # As if that weren't enough, we're going to try building with antivirus
 # support as an option also
-%define build_fprot    0
-%define build_kaspersky 0
-%define build_mks      0
-%define build_openav   0
-%define build_sophos   0
-%define build_symantec         0
-%define build_trend 0
+%global build_clamav   0
+%global build_fprot    0
+%global build_fsav     0
+%global build_icap     0
+%global build_kaspersky 0
+%global build_mks      0
+%global build_nai      0
+%global build_openav   0
+%global build_sophos   0
+%global build_symantec         0
+%global build_trend    0
+%if %build_vscan
+# These we build by default
+%global build_clamav   1
+%global build_icap     1
+%endif
 %if %build_vscan && %build_scanners
-#These can be enabled here by default
-# (kaspersky requires their library present)
-%define build_fprot    1
-%define build_mks      1
-%define build_openav   1
-%define build_sophos   1
-%define build_trend    1
+# These scanners are built if scanners are selected
+# symantec requires their library present and must be selected 
+# individually
+%global build_fprot    1
+%global build_fsav     1
+%global build_kaspersky 1
+%global build_mks      1
+%global build_nai      1
+%global build_openav   1
+%global build_sophos   1
+%global build_trend    1
 %endif
 %if %build_vscan
 %{?_with_fprot: %{expand: %%global build_fprot 1}}
 
 #Standard texts for descriptions:
 %define message_bugzilla() %(echo -e -n "Please file bug reports for this package at Mandrake bugzilla \\n(http://qa.mandrakesoft.com) under the product name %{1}")
-%define message_system %(echo -e -n "NOTE: This is a prerelease of samba-%{samba_major}, not intended for production\\n use. Rather these packages are provided, parallel installable\\nwith samba-2.2.x, for testing purposes")
+%define message_system %(echo -e -n "NOTE: These packages of samba-%{version}, are provided, parallel installable\\nwith samba-2.2.x, to allow easy migration from samba-2.2.x to samba-%{version},\\nbut are not officially supported")
 
 #check gcc version to disable some optimisations on gcc-3.3.1
 %define gcc331 %(gcc -dumpversion|awk '{if ($1>3.3) print 1; else print 0}')
 
+#Define sets of binaries that we can use in globs and loops:
+%global commonbin net,ntlm_auth,rpcclient,smbcacls,smbcquotas,smbpasswd,smbtree,testparm,testprns
+
+%global serverbin      editreg,pdbedit,profiles,smbcontrol,smbstatus,tdbbackup,tdbdump
+%global serversbin nmbd,samba,smbd,mkntpwd
+
+%global clientbin      findsmb,nmblookup,smbclient,smbmnt,smbmount,smbprint,smbspool,smbtar,smbumount,smbget
+%global client_bin     mount.cifs
+%global client_sbin    mount.smb,mount.smbfs
+
+%global testbin        debug2html,smbtorture,msgtest,masktest,locktest,locktest2,nsstest,vfstest
+
 %ifarch alpha
 %define build_expsam xml
 %else
-%define build_expsam mysql,xml
+%define build_expsam mysql,xml,pgsql
 %endif
 
 #Workaround missing macros in 8.x:
 %else
 %define samba_major    3
 %endif
+# alternatives_major is %{nil} if we aren't system and not using alternatives
+%if !%build_system || %build_alternatives
+%define alternative_major 3
+%else
+%define alternative_major %{nil}
+%endif
 
 Summary: Samba SMB server.
 Name: %{pkg_name}%{samba_major}
@@ -205,10 +251,10 @@ Version: %{source_ver}
 %endif
 
 %if %have_prelease && !%have_pre
-Release: 1.%{prelease}mdk
+Release: 0.%{prelease}.%{rel}
 %endif
 %if %have_prelease && %have_pre
-Release: 0.%{pre_pre}.%{prelease}mdk
+Release: 0.%{pre_pre}.%{rel}
 %endif
 %if !%have_prelease && !%have_pre
 Release: %{rel}
@@ -230,15 +276,22 @@ Source7: README.%{name}-mandrake-rpm
 %if %build_vscan
 Source8: samba-vscan-%{vscanver}.tar.bz2
 %endif
+%if %build_vscan && %mdkversion >= 920
+BuildRequires: file-devel
+%endif
 Source10: samba-print-pdf.sh.bz2
-Source11: mount.cifs.8.bz2
+Source11: smb-migrate.bz2
 Patch1: smbw.patch.bz2
-Patch3: samba-2.2.0-buildroot.patch.bz2
 Patch4: samba-3.0-smbmount-sbin.patch.bz2
+Patch5:        samba-3.0.2a-smbldap-config.patch.bz2
 %if !%have_pversion
 # Version specific patches: current version
+Patch7: samba-3.0.5-lib64.patch.bz2
+Patch9:        samba-3.0.6-smbmount-unixext.patch.bz2
+Patch11: samba-3.0.7-mandrake-packaging.patch.bz2
 %else
 # Version specific patches: upcoming version
+Patch8:        samba-3.0.6-revert-libsmbclient-move.patch.bz2
 %endif
 # Limbo patches (applied to prereleases, but not preleases, ie destined for
 # samba CVS)
@@ -246,7 +299,7 @@ Patch4: samba-3.0-smbmount-sbin.patch.bz2
 %endif
 Requires: pam >= 0.64, samba-common = %{version}
 BuildRequires: pam-devel readline-devel libncurses-devel popt-devel
-BuildRequires: libxml2-devel
+BuildRequires: libxml2-devel postgresql-devel
 %ifnarch alpha
 BuildRequires: mysql-devel
 %endif
@@ -262,10 +315,7 @@ BuildRequires: libldap-devel
 %if %build_ads
 BuildRequires: libldap-devel krb5-devel
 %endif
-%if %build_chrpath
-BuildRequires: chrpath
-%endif
-BuildRoot: %{_tmppath}/%{name}-root
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
 Prefix: /usr
 Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall
 Prereq: fileutils sed /bin/grep
@@ -308,7 +358,9 @@ more information.
 URL:   http://www.samba.org
 Summary: Samba (SMB) server programs.
 Requires: %{name}-common = %{version}
+%if %have_rpmhelper
 PreReq:                rpm-helper
+%endif
 Group: Networking/Other
 %if %build_system
 Provides: samba
@@ -352,6 +404,9 @@ URL:        http://www.samba.org
 Summary: Samba (SMB) client programs.
 Group: Networking/Other
 Requires: %{name}-common = %{version}
+%if %build_alternatives
+#Conflicts:    samba-client < 2.2.8a-9mdk
+%endif
 %if %build_system
 Provides:  samba3-client
 Obsoletes: samba3-client
@@ -359,6 +414,9 @@ Obsoletes: smbfs
 %else
 #Provides: samba-client
 %endif
+%if !%build_system && %build_alternatives
+Provides: samba-client
+%endif
 
 %description client
 Samba-client provides some SMB clients, which complement the built-in
@@ -453,6 +511,11 @@ URL:       http://www.samba.org
 Summary: Samba-winbind daemon, utilities and documentation
 Group: System/Servers
 Requires: %{name}-common = %{version}
+%endif
+%if %build_winbind && !%build_system
+Conflicts: samba-winbind
+%endif
+%if %build_winbind
 %description winbind
 Provides the winbind daemon and testing tools to allow authentication 
 and group/user enumeration from a Windows or Samba domain controller.
@@ -471,6 +534,11 @@ Summary: Name Service Switch service for WINS
 Group: System/Servers
 Requires: %{name}-common = %{version}
 PreReq: glibc
+%endif
+%if %build_wins && !%build_system
+Conflicts: nss_wins
+%endif
+%if %build_wins
 %description -n nss_wins%{samba_major}
 Provides the libnss_wins shared library which resolves NetBIOS names to 
 IP addresses.
@@ -482,21 +550,22 @@ IP addresses.
 %message_system
 %endif
 
-%if %{?_without_test:0}%{!?_without_test:1}
+%if %{?_with_test:1}%{!?_with_test:0}
 %package test
 URL:   http://www.samba.org
 Summary: Debugging and benchmarking tools for samba
 Group: System/Servers
 Requires: %{name}-common = %{version}
 %endif
-%if %build_system && %{?_without_test:0}%{!?_without_test:1}
+%if %build_system && %{?_with_test:1}%{!?_with_test:0}
 Provides:  samba3-test samba3-debug
 Obsoletes: samba3-test samba3-debug
-%else
+%endif
+%if !%build_system && %{?_with_test:1}%{!?_with_test:0}
 Provides: samba-test samba3-debug
 Obsoletes: samba3-debug
 %endif
-%if %{?_without_test:0}%{!?_without_test:1}
+%if %{?_with_test:1}%{!?_with_test:0}
 
 %description test
 This package provides tools for benchmarking samba, and debugging
@@ -504,57 +573,58 @@ the correct operation of tools against smb servers.
 %endif
 
 %if %build_system
-%package -n libsmbclient%{libsmbmajor}
+%package -n %{libname}
 URL:           http://www.samba.org
 Summary:       SMB Client Library
 Group:         System/Libraries
 Provides:      libsmbclient
 
-%description -n libsmbclient%{libsmbmajor}
+%description -n %{libname}
 This package contains the SMB client library, part of the samba
 suite of networking software, allowing other software to access
 SMB shares.
 %endif
 %if %have_pversion && %build_system
-%message_bugzilla libsmbclient%{libsmbmajor}
+%message_bugzilla %{libname}
 %endif
 
 %if %build_system
-%package -n libsmbclient%{libsmbmajor}-devel
+%package -n %{libname}-devel
 URL:           http://www.samba.org
 Summary:       SMB Client Library Development files
-Group:         System/Libraries
+Group:         Development/C
 Provides:      libsmbclient-devel
+Requires:       %{libname} = %{version}-%{release}
 
-%description -n libsmbclient%{libsmbmajor}-devel
+%description -n %{libname}-devel
 This package contains the development files for the SMB client
 library, part of the samba suite of networking software, allowing
 the development of other software to access SMB shares.
 %endif
 %if %have_pversion && %build_system
-%message_bugzilla libsmbclient%{libsmbmajor}-devel
+%message_bugzilla %{libname}-devel
 %endif
 
 %if %build_system
-%package -n libsmbclient%{libsmbmajor}-static-devel
+%package -n %{libname}-static-devel
 URL:            http://www.samba.org
 Summary:        SMB Client Static Library Development files
 Group:          System/Libraries
 Provides:       libsmbclient-static-devel = %{version}-%{release}
-Requires:       libsmbclient%{libsmbmajor}-devel = %{version}-%{release}
+Requires:       %{libname}-devel = %{version}-%{release}
 
-%description -n libsmbclient%{libsmbmajor}-static-devel
+%description -n %{libname}-static-devel
 This package contains the static development files for the SMB
 client library, part of the samba suite of networking software,
 allowing the development of other software to access SMB shares.
 %endif
 %if %have_pversion && %build_system
-%message_bugzilla libsmbclient%{libsmbmajor}-devel
+%message_bugzilla %{libname}-devel
 %endif
 
 #%package passdb-ldap
 #URL:          http://www.samba.org
-#Summary:      Samba password database plugin for MySQL
+#Summary:      Samba password database plugin for LDAP
 #Group:                System/Libraries
 #
 #%description passdb-ldap
@@ -573,23 +643,50 @@ allowing the development of other software to access SMB shares.
 URL:           http://www.samba.org
 Summary:       Samba password database plugin for MySQL
 Group:         System/Libraries
+Requires:      %{name}-server = %{version}-%{release}
+%endif
+%ifnarch alpha && %build_system
+Obsoletes:     samba3-passdb-mysql 
+Provides:      samba3-passdb-mysql 
+%endif
+%ifnarch alpha
 
 %description passdb-mysql
 The passdb-mysql package for samba provides a password database
 backend allowing samba to store account details in a MySQL
 database
 %endif
-%ifnarch alpha && %have_pversion
-%message_bugzilla samba3-passdb-mysql
-%endif
-%ifnarch alpha && !%build_system
-%message_system
+
+#does postgresql build on alpha?
+#ifnarch alpha
+%package passdb-pgsql
+URL:           http://www.samba.org
+Summary:       Samba password database plugin for PostgreSQL
+Group:         System/Libraries
+Requires:      %{name}-server = %{version}-%{release}
+#endif
+#ifnarch alpha && %build_system
+%if %build_system
+Obsoletes:     samba3-passdb-pgsql
+Provides:      samba3-passdb-pgsql
 %endif
+#ifnarch alpha
+
+%description passdb-pgsql
+The passdb-pgsql package for samba provides a password database
+backend allowing samba to store account details in a PostgreSQL
+database
+#endif
 
 %package passdb-xml
 URL:           http://www.samba.org
 Summary:       Samba password database plugin for XML files
 Group:         System/Libraries
+Requires:      %{name}-server = %{version}-%{release}
+%if %build_system
+Obsoletes:     samba3-passdb-xml 
+Provides:      samba3-passdb-xml 
+%endif
 
 %description passdb-xml
 The passdb-xml package for samba provides a password database
@@ -602,25 +699,57 @@ backend allowing samba to store account details in XML files.
 %endif
 
 #Antivirus packages:
+%if %build_clamav
+%package vscan-clamav
+Summary: On-access virus scanning for samba using Clam Antivirus
+Group: System/Servers
+Requires: %{name}-server = %{version}
+Provides: %{name}-vscan
+Requires: clamd
+%description vscan-clamav
+A vfs-module for samba to implement on-access scanning using the
+Clam antivirus scanner daemon.
+%endif
+
 %if %build_fprot
 %package vscan-fprot
 Summary: On-access virus scanning for samba using FPROT
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-fprot
 A vfs-module for samba to implement on-access scanning using the
 FPROT antivirus software (which must be installed to use this).
 %endif
 
+%if %build_fsav
+%package vscan-fsecure
+Summary: On-access virus scanning for samba using F-Secure
+Group: System/Servers
+Requires: %{name}-server = %{version}
+Provides: %{name}-vscan
+%description vscan-fsecure
+A vfs-module for samba to implement on-access scanning using the
+F-Secure antivirus software (which must be installed to use this).
+%endif
+
+%if %build_icap
+%package vscan-icap
+Summary: On-access virus scanning for samba using Clam Antivirus
+Group: System/Servers
+Requires: %{name}-server = %{version}
+Provides: %{name}-icap
+%description vscan-icap
+A vfs-module for samba to implement on-access scanning using
+ICAP-capable antivirus software.
+%endif
+
 %if %build_kaspersky
 %package vscan-kaspersky
 Summary: On-access virus scanning for samba using Kaspersky
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-kaspersky
 A vfs-module for samba to implement on-access scanning using the
 Kaspersky antivirus software (which must be installed to use this).
@@ -632,19 +761,28 @@ Summary: On-access virus scanning for samba using MKS
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-mks
 A vfs-module for samba to implement on-access scanning using the
 MKS antivirus software (which must be installed to use this).
 %endif
 
+%if %build_nai
+%package vscan-nai
+Summary: On-access virus scanning for samba using NAI McAfee
+Group: System/Servers
+Requires: %{name}-server = %{version}
+Provides: %{name}-vscan
+%description vscan-nai
+A vfs-module for samba to implement on-access scanning using the
+NAI McAfee antivirus software (which must be installed to use this).
+%endif
+
 %if %build_openav
 %package vscan-openav
 Summary: On-access virus scanning for samba using OpenAntivirus
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-openav
 A vfs-module for samba to implement on-access scanning using the
 OpenAntivirus antivirus software (which must be installed to use this).
@@ -656,7 +794,6 @@ Summary: On-access virus scanning for samba using Sophos
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-sophos
 A vfs-module for samba to implement on-access scanning using the
 Sophos antivirus software (which must be installed to use this).
@@ -674,13 +811,13 @@ A vfs-module for samba to implement on-access scanning using the
 Symantec antivirus software (which must be installed to use this).
 %endif
 
+
 %if %build_trend
 %package vscan-trend
 Summary: On-access virus scanning for samba using Trend
 Group: System/Servers
 Requires: %{name}-server = %{version}
 Provides: %{name}-vscan
-Autoreq: 0
 %description vscan-trend
 A vfs-module for samba to implement on-access scanning using the
 Trend antivirus software (which must be installed to use this).
@@ -710,10 +847,11 @@ Trend antivirus software (which must be installed to use this).
 %endif
 
 %if %{?_with_options:1}%{!?_with_options:0} && %build_scanners
-%{error:--with scanners enables fprot,mks,openav,sophos and trend by default}
+#{error:--with scanners enables the following:%{?build_clamav:clamav,}%{?build_icap:icap,}%{?build_fprot:fprot,}%{?build_mks:mks,}%{?build_openav:openav,}%{?build_sophos:sophos,}%{?build_symantec:symantec,}%{?build_trend:trend}}
+%{error:--with scanners enables the following: clamav,icap,fprot,fsav,mks,nai,openav,sophos,trend}
 %{error: }
 %{error:To enable others (requires development libraries for the scanner):}
-%{error:--with kaspersky     Enable on-access scanning with Kaspersky  - %opt_status %build_kaspersky}
+%{error:--with symantec           Enable on-access scanning with Symantec        - %opt_status %build_symantec}
 %{error: }
 %endif
 
@@ -758,14 +896,19 @@ echo -e "\n%{name}-%{version}-%{release}\n">>%{SOURCE7}
 %endif
 #%patch111 -p1
 %patch1 -p1 -b .smbw
-%patch3 -p1 -b .buildroot
 %patch4 -p1 -b .sbin
+%patch5 -p1
 # Version specific patches: current version
 %if !%have_pversion
 echo "Applying patches for current version: %{ver}"
+#%patch7 -p1 -b .lib64
+%patch9 -p1 -b .unixext
+#%patch10 -p1 -b .rpcclient-libs
+%patch11 -p1 -b .mdk
 %else
 # Version specific patches: upcoming version
 echo "Applying patches for new versions: %{pversion}"
+%patch8 -p1 -b .libsmbdir
 %endif
 
 # Limbo patches
@@ -774,7 +917,7 @@ echo "Appling patches which should only be applied to prereleases"
 %endif
 
 # Fix quota compilation in glibc>2.3
-%if %build_mdk91 || %build_mdk92
+%if %mdkversion >= 910 && %mdkversion < 1000
 #grep "<linux/quota.h>" source/smbd/quotas.c >/dev/null && \
 perl -pi -e 's@<linux/quota.h>@<sys/quota.h>@' source/smbd/quotas.c
 %endif
@@ -787,16 +930,17 @@ cp -a examples examples.bin
 %if %build_vscan
 cp -a %{vscandir} %{vfsdir}
 #fix stupid directory names:
-mv %{vfsdir}/%{vscandir}/openantivirus %{vfsdir}/%{vscandir}/oav
-%endif
+#mv %{vfsdir}/%{vscandir}/openantivirus %{vfsdir}/%{vscandir}/oav
 # Inline replacement of config dir
-for av in fprot kaspersky mks oav sophos trend; do
-       [ -e %{vfsdir}/%{vscandir}/$av/vscan-$av.h ] && perl -pi -e \
+for av in clamav fprotd fsav icap kavp mksd mcdaemon oav sophos symantec trend
+ do
+       [ -e %{vfsdir}/%{vscandir}/*/vscan-$av.h ] && perl -pi -e \
        's,^#define PARAMCONF "/etc/samba,#define PARAMCONF "/etc/%{name},' \
-       %{vfsdir}/%{vscandir}/$av/vscan-$av.h
+       %{vfsdir}/%{vscandir}/*/vscan-$av.h
 done
 #Inline edit vscan header:
-perl -pi -e 's/^# define SAMBA_VERSION_MAJOR 2/# define SAMBA_VERSION_MAJOR 3/g' %{vfsdir}/%{vscandir}/include/vscan-global.h
+perl -pi -e 's/^# define SAMBA_VERSION_MAJOR 2/# define SAMBA_VERSION_MAJOR 3/g;s/# define SAMBA_VERSION_MINOR 2/# define SAMBA_VERSION_MINOR 0/g' %{vfsdir}/%{vscandir}/include/vscan-global.h
+%endif
 
 # Edit some files when not building system samba:
 %if !%build_system
@@ -806,22 +950,32 @@ perl -pi -e 's/%{pkg_name}/%{name}/g' source/auth/pampass.c
 #remove cvs internal files from docs:
 find docs examples -name '.cvsignore' -exec rm -f {} \;
 
+#make better doc trees:
+chmod -R a+rX examples docs *Manifest* README  Roadmap COPYING
+mkdir -p clean-docs/samba-doc
+cp -a examples docs clean-docs/samba-doc
+mv -f clean-docs/samba-doc/examples/libsmbclient clean-docs/
+rm -Rf clean-docs/samba-doc/docs/{docbook,manpages,htmldocs,using_samba}
+ln -s %{_datadir}/swat%{samba_major}/using_samba/ clean-docs/samba-doc/docs/using_samba
+ln -sf %{_datadir}/swat%{samba_major}/help/ clean-docs/samba-doc/docs/htmldocs
+
 %build
 #%serverbuild
 (cd source
 CFLAGS=`echo "$RPM_OPT_FLAGS"|sed -e 's/-g//g'`
 %if %gcc331
-#CFLAGS=`echo "$CFLAGS"|sed -e 's/-O2/-Os/g'`
+CFLAGS=`echo "$CFLAGS"|sed -e 's/-O2/-O/g'`
 %endif
+./autogen.sh
 # Don't use --with-fhs now, since it overrides libdir, it sets configdir, 
 # lockdir,piddir logfilebase,privatedir and swatdir
 %configure      --prefix=%{_prefix} \
                 --sysconfdir=%{_sysconfdir}/%{name} \
                 --localstatedir=/var \
-                --libdir=%{_libdir}/%{name} \
+                --with-libdir=%{_libdir}/%{name} \
                 --with-privatedir=%{_sysconfdir}/%{name} \
                --with-lockdir=/var/cache/%{name} \
-               --with-piddir=/var/run/%{name} \
+               --with-piddir=/var/run \
                 --with-swatdir=%{_datadir}/swat%{samba_major} \
                 --with-configdir=%{_sysconfdir}/%{name} \
                --with-logfilebase=/var/log/%{name} \
@@ -855,61 +1009,34 @@ CFLAGS=`echo "$RPM_OPT_FLAGS"|sed -e 's/-g//g'`
 #                --with-fhs \
 
 #Fix the make file so we don't create debug information on 9.2
-%if %build_mdk92
+%if %mdkversion == 920
 perl -pi -e 's/-g //g' Makefile
 %endif
 
-make proto_exists
-%make  all libsmbclient smbfilter wins modules %{!?_without_test: torture debug2html} bin/editreg client/mount.cifs
+perl -pi -e 's|-Wl,-rpath,%{_libdir}||g;s|-Wl,-rpath -Wl,%{_libdir}||g' Makefile
 
+make proto_exists
+%make all libsmbclient smbfilter wins modules %{?_with_test: torture debug3html bin/log2pcap} bin/editreg bin/smbget client/mount.cifs
 
-# Build VFS modules (experimental)
-#cd ../%vfsdir
-#_configure    --prefix=%{prefix} \
-#              --mandir=%{prefix}/share/man
-#make
-#make CFLAGS="$RPM_OPT_FLAGS -I../../source -I../../source/include -I../../source/ubiqx \
-#      -I../../source/smbwrapper -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
 )
 
 # Build mkntpasswd in examples/LDAP/ for smbldaptools
-#(
-#cd examples.bin/LDAP/smbldap-tools/mkntpwd
-#make
-#)
+make -C examples.bin/LDAP/smbldap-tools/mkntpwd
 
-# Build antivirus vfs objects:
-%if %build_fprot
+%if %build_vscan
 echo -e "\n\nBuild antivirus VFS modules\n\n"
-echo "Building fprot"
-(cd %{vfsdir}/%{vscandir}/fprot;make)
-%endif
-%if %build_kaspersky
-echo "Building Kaspersky"
-(cd %{vfsdir}/%{vscandir}/kavp
-    perl -p -i -e "s|/usr/local/|/usr/|g" Makefile.KAV4
-    make -f Makefile.KAV4
-)
-%endif
-%if %build_mks
-echo "Building mks"
-(cd %{vfsdir}/%{vscandir}/mks;make)
-%endif
-%if %build_openav
-echo "Building OpenAntivirus"
-(cd %{vfsdir}/%{vscandir}/oav;make)
-%endif
-%if %build_sophos
-echo "building sophos"
-(cd %{vfsdir}/%{vscandir}/sophos;make)
+pushd %{vfsdir}/%{vscandir}
+%configure
+#sed -i -e 's,openantivirus,oav,g' Makefile
+sed -i -e 's,^\(.*clamd socket name.*=\).*,\1 /var/lib/clamav/clamd.socket,g' clamav/vscan-clamav.conf
+make
+popd
 %endif
+
+# Build antivirus vfs objects
 %if %build_symantec
-echo "Building symantec"
-(cd %{vfsdir}/%{vscandir}/symantec;make)
-%endif
-%if %build_trend
-echo "Building Trend"
-(cd %{vfsdir}/%{vscandir}/trend;make)
+echo "Building Symantec"
+make -C %{vfsdir}/%{vscandir} symantec
 %endif
 
 %install
@@ -925,12 +1052,12 @@ mkdir -p $RPM_BUILD_ROOT/%{_datadir}
 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}/vfs
 
 (cd source
-make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir}/%{name} install installclientlib installmodules)
+make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir}/%{name} MANDIR=%{_mandir} install installclientlib installmodules)
 
-install -m755 source/bin/editreg %{buildroot}/%{_bindir}
+install -m755 source/bin/{editreg,smbget} %{buildroot}/%{_bindir}
 
 #need to stay
-mkdir -p $RPM_BUILD_ROOT/sbin
+mkdir -p $RPM_BUILD_ROOT/{sbin,bin}
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{logrotate.d,pam.d,xinetd.d}
 mkdir -p $RPM_BUILD_ROOT/%{_initrddir}
 mkdir -p $RPM_BUILD_ROOT/var/cache/%{name}
@@ -948,42 +1075,33 @@ mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}/scripts
 #smbwrapper and pam_winbind not handled by make, pam_smbpass.so doesn't build
 #install -m 755 source/bin/smbwrapper.so $RPM_BUILD_ROOT%{_libdir}/smbwrapper%{samba_major}.so
 install -m 755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/%{_lib}/security/pam_smbpass%{samba_major}.so
-install -m 755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/%{_lib}/security/pam_winbind%{samba_major}.so
+install -m 755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/%{_lib}/security/pam_winbind.so
 
 install -m755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{_libdir}/libsmbclient.a
+pushd $RPM_BUILD_ROOT/%{_libdir}
+[ -f libsmbclient.so ] && mv -f libsmbclient.so libsmbclient.so.%{libsmbmajor}
+ln -sf libsmbclient.so.%{libsmbmajor} libsmbclient.so
+popd
 
 # smbsh forgotten
 #install -m 755 source/bin/smbsh $RPM_BUILD_ROOT%{_bindir}/
 
-# Install VFS modules
-#install -m755 %vfsdir/audit.so $RPM_BUILD_ROOT/%{_libdir}/samba/vfs
-#for i in block recycle
-#do
-# install -m755 %vfsdir/$i/$i.so $RPM_BUILD_ROOT/%{_libdir}/samba/vfs
-#done
-
-# Antivirus support:
-#      mkdir -p $RPM_BUILD_ROOT%{_libdir}/samba/vfs/vscan
-       for av in fprot kavp mks oav sophos symantec trend; do
-               if [ -d %{vfsdir}/%{vscandir}/$av -a -e %{vfsdir}/%{vscandir}/$av/vscan-$av*.so ];then
-                       cp %{vfsdir}/%{vscandir}/$av/vscan-$av*.so \
-                               $RPM_BUILD_ROOT%{_libdir}/%{name}/vfs/
-                       cp %{vfsdir}/%{vscandir}/$av/vscan-$av*.conf \
-                               $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
-               fi
-       done
+%if %build_vscan
+%makeinstall_std -C %{vfsdir}/%{vscandir}
+install -m 644 %{vfsdir}/%{vscandir}/*/vscan-*.conf %{buildroot}/%{_sysconfdir}/%{name}
+%endif
        
 #libnss_* not handled by make:
 # Install the nsswitch library extension file
 for i in wins winbind; do
-  install -m755 source/nsswitch/libnss_${i}.so $RPM_BUILD_ROOT/%{_lib}/libnss_${i}%{samba_major}.so
+  install -m755 source/nsswitch/libnss_${i}.so $RPM_BUILD_ROOT/%{_lib}/libnss_${i}.so
 done
 # Make link for wins and winbind resolvers
-( cd $RPM_BUILD_ROOT/%{_lib}; ln -s libnss_wins%{samba_major}.so libnss_wins%{samba_major}.so.2; ln -s libnss_winbind%{samba_major}.so libnss_winbind%{samba_major}.so.2)
+( cd $RPM_BUILD_ROOT/%{_lib}; ln -s libnss_wins.so libnss_wins.so.2; ln -s libnss_winbind.so libnss_winbind.so.2)
 
-%if %{?_without_test:0}%{!?_without_test:1}
-for i in smbtorture msgtest masktest locktest locktest2 nsstest vfstest debug2html;do
-  install -m755 source/bin/$i $RPM_BUILD_ROOT/%{_bindir}
+%if %{?_with_test:1}%{!?_with_test:0}
+for i in {%{testbin}};do
+  install -m755 source/bin/${i} $RPM_BUILD_ROOT/%{_bindir}/${i}%{samba_major}
 done
 %endif
 
@@ -996,40 +1114,46 @@ done
         install -m755 packaging/Mandrake/findsmb $RPM_BUILD_ROOT/%{_bindir}
         install -m755 packaging/Mandrake/smb.init $RPM_BUILD_ROOT/%{_initrddir}/smb%{samba_major}
         install -m755 packaging/Mandrake/smb.init $RPM_BUILD_ROOT/%{_sbindir}/%{name}
-       install -m755 packaging/Mandrake/winbind.init $RPM_BUILD_ROOT/%{_initrddir}/winbind%{samba_major}
+       install -m755 packaging/Mandrake/winbind.init $RPM_BUILD_ROOT/%{_initrddir}/winbind
 #      install -m755 packaging/Mandrake/wrepld.init $RPM_BUILD_ROOT/%{_initrddir}/wrepld%{samba_major}
-       install -m755 packaging/Mandrake/winbind.init $RPM_BUILD_ROOT/%{_sbindir}/winbind%{samba_major}
+       install -m755 packaging/Mandrake/winbind.init $RPM_BUILD_ROOT/%{_sbindir}/winbind
         install -m644 packaging/Mandrake/samba.pamd $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/%{name}
-       install -m644 packaging/Mandrake/system-auth-winbind.pamd $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/system-auth-winbind%{samba_major}
+       install -m644 packaging/Mandrake/system-auth-winbind.pamd $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/system-auth-winbind
 #
         install -m644 %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/%{name}
 #      install -m644 packaging/Mandrake/samba-slapd-include.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/samba-slapd.include
 
 # Install smbldap-tools scripts:
-#for i in examples/LDAP/smbldap-tools/*.pl; do
-#      install -m 750 $i $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
-#done
+for i in examples/LDAP/smbldap-tools/*.pl; do
+       install -m 750 $i $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
+       ln -s %{_datadir}/%{name}/scripts/`basename $i` $RPM_BUILD_ROOT/%{_bindir}/`basename $i|sed -e 's/\.pl//g'`%{samba_major}
+done
 
-#install -m 750 examples/LDAP/smbldap-tools/smbldap_tools.pm $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
+install -m 750 examples/LDAP/smbldap-tools/smbldap_tools.pm $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
 
 # The conf file        
-#install -m 640 examples/LDAP/smbldap-tools/smbldap_conf.pm $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}
+install -m 640 examples/LDAP/smbldap-tools/smbldap_conf.pm $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}
 
-# Link both smbldap*.pm into vendor-perl (any better ideas?)
-#mkdir -p %{buildroot}/%{perl_vendorlib}
-#ln -s %{_sysconfdir}/%{name}/smbldap_conf.pm $RPM_BUILD_ROOT/%{perl_vendorlib}
-#ln -s %{_datadir}/%{name}/scripts/smbldap_tools.pm $RPM_BUILD_ROOT/%{perl_vendorlib}
+#Fix the smbldap-tools when not system samba:
+%if !%build_system
+perl -pi -e 's/^(use|package)(\s+)smbldap_(\w+);$/${1}${2}smbldap_${3}%{samba_major};/g' \
+%{buildroot}/%{_sysconfdir}/%{name}/smbldap_conf.pm \
+%{buildroot}/%{_datadir}/%{name}/scripts/smbldap*.p?
+perl -pi -e 's,/usr/local/sbin/mkntpwd,/usr/sbin/mkntpwd%{samba_major},g;s,553,421,g' %{buildroot}/%{_sysconfdir}/%{name}/smbldap_conf.pm
+perl -pi -e 's,\$smbldap_conf::SID,\$smbldap_conf3::SID,g' %{buildroot}/%{_datadir}/%{name}/scripts/smbldap*.p?
+%endif
+perl -pi -e 's,/usr/local/sbin/smbldap-passwd.pl,%{_datadir}/%{name}/scripts/smbldap-passwd.pl,g' %{buildroot}/%{_datadir}/%{name}/scripts/smbldap-useradd.pl 
 
+# Link both smbldap*.pm into vendor-perl (any better ideas?)
+mkdir -p %{buildroot}/%{perl_vendorlib}
+ln -s %{_sysconfdir}/%{name}/smbldap_conf.pm $RPM_BUILD_ROOT/%{perl_vendorlib}/smbldap_conf%{samba_major}.pm
+ln -s %{_datadir}/%{name}/scripts/smbldap_tools.pm $RPM_BUILD_ROOT/%{perl_vendorlib}/smbldap_tools%{samba_major}.pm
 #mkntpwd
-#install -m750 examples.bin/LDAP/smbldap-tools/mkntpwd/mkntpwd %{buildroot}/%{_sbindir}
+install -m750 examples.bin/LDAP/smbldap-tools/mkntpwd/mkntpwd %{buildroot}/%{_sbindir}/mkntpwd%{samba_major}
 
 # Samba smbpasswd migration script:
-install -m700 examples/LDAP/export_smbpasswd.pl $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
-install -m700 examples/LDAP/import_smbpasswd.pl $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
 install -m755 examples/LDAP/convertSambaAccount $RPM_BUILD_ROOT/%{_datadir}/%{name}/scripts/
 
-
-
 # make a conf file for winbind from the default one:
        cat packaging/Mandrake/smb.conf|sed -e  's/^;  winbind/  winbind/g;s/^;  obey pam/  obey pam/g; s/^;   printer admin = @"D/   printer admin = @"D/g;s/^;   password server = \*/   password server = \*/g;s/^;  template/  template/g; s/^   security = user/   security = domain/g' > packaging/Mandrake/smb-winbind.conf
         install -m644 packaging/Mandrake/smb-winbind.conf $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/smb-winbind.conf
@@ -1043,23 +1167,21 @@ perl -pi -e 's/printcap name = lpstat/printcap name = cups/g' $RPM_BUILD_ROOT/%{
 perl -pi -e 's/printcap name = lpstat/printcap name = cups/g' $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/smb-winbind.conf
 %endif
 
-# Link smbmount to /sbin/mount.smb and /sbin/mount.smbfs
-#I don't think it's possible for make to do this ...
-(cd $RPM_BUILD_ROOT/sbin
-        ln -s ..%{_bindir}/smbmount%{samba_major} mount.smb%{samba_major}
-        ln -s ..%{_bindir}/smbmount%{samba_major} mount.smbfs%{samba_major}
-)
+#%if !%build_system
+# Fix script paths in smb.conf
+#perl -pi -e 's,%{_datadir}/samba,%{_datadir}/%{name},g' %{buildroot}/%{_sysconfdir}/%{name}/smb*.conf
+#%endif
+
 
 #install mount.cifs
-install -m755 source/client/mount.cifs %{buildroot}/sbin
-bzcat %{SOURCE11} > %{buildroot}/%{_mandir}/man8/mount.cifs.8
+install -m755 source/client/mount.cifs %{buildroot}/bin/mount.cifs%{samba_major}
 
         echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/lmhosts
 
 # Link smbspool to CUPS (does not require installed CUPS)
 
         mkdir -p $RPM_BUILD_ROOT/%{_libdir}/cups/backend
-        ln -s %{_bindir}/smbspool $RPM_BUILD_ROOT/%{_libdir}/cups/backend/smb%{samba_major}
+        ln -s %{_bindir}/smbspool%{alternative_major} $RPM_BUILD_ROOT/%{_libdir}/cups/backend/smb%{alternative_major}
 
 # xinetd support
 
@@ -1093,38 +1215,62 @@ bzcat %{SOURCE5} > $RPM_BUILD_ROOT%{_iconsdir}/swat%{samba_major}.png
 bzcat %{SOURCE6} > $RPM_BUILD_ROOT%{_miconsdir}/swat%{samba_major}.png
 
 bzcat %{SOURCE10}> $RPM_BUILD_ROOT%{_datadir}/%{name}/scripts/print-pdf
-
-%if %build_chrpath
-find %{buildroot}/%{_lib} %{buildroot}/%{_bindir} %{buildroot}/%{_sbindir} %{buildroot}/%{_libdir} -type f -exec chrpath -d {} \;
-%endif
+bzcat %{SOURCE11}> $RPM_BUILD_ROOT%{_datadir}/%{name}/scripts/smb-migrate
 
 # Fix configs when not building system samba:
-%if !%build_system
-# Work around non-existent but claimed --program-suffix support :-(
-for dir in %{_sbindir} %{_bindir};do
-    FILES=`find %{buildroot}$dir -type f |grep -v "\."|grep -v %{samba_major}$`
-    for OLD in $FILES; do
-        NEW=`echo ${OLD}%{samba_major}`
+
+#Client binaries will have suffixes while we use alternatives, even
+# if we are system samba
+%if !%build_system || %build_alternatives
+for OLD in %{buildroot}/%{_bindir}/{%{clientbin}} %{buildroot}/bin/%{client_bin} %{buildroot}/%{_libdir}/cups/backend/smb
+do
+    NEW=`echo ${OLD}%{alternative_major}`
+    [ -e $OLD ] && mv -f $OLD $NEW
+done
+for OLD in %{buildroot}/%{_mandir}/man?/{%{clientbin}}* %{buildroot}/%{_mandir}/man?/%{client_bin}*
+do
+    if [ -e $OLD ]
+    then
+        BASE=`perl -e '$_="'${OLD}'"; m,(%buildroot)(.*?)(\.[0-9]),;print "$1$2\n";'`
+        EXT=`echo $OLD|sed -e 's,'${BASE}',,g'`
+        NEW=`echo ${BASE}%{alternative_major}${EXT}`
         mv $OLD $NEW
-    done
+    fi
+done           
+%endif
+rm -f %{buildroot}/sbin/mount.smbfs
+# Link smbmount to /sbin/mount.smb and /sbin/mount.smbfs
+#I don't think it's possible for make to do this ...
+(cd $RPM_BUILD_ROOT/sbin
+        ln -s ..%{_bindir}/smbmount%{alternative_major} mount.smb%{alternative_major}
+        ln -s ..%{_bindir}/smbmount%{alternative_major} mount.smbfs%{alternative_major}
+)
+# Server/common binaries are versioned only if not system samba:
+%if !%build_system
+for OLD in %{buildroot}/%{_bindir}/{%{commonbin}} %{buildroot}/%{_bindir}/{%{serverbin}} %{buildroot}/%{_sbindir}/{%{serversbin},swat}
+do
+    NEW=`echo ${OLD}%{alternative_major}`
+    mv $OLD $NEW -f ||:
 done
 # And the man pages too:
-FILES=`find %{buildroot}%{_mandir} -type f `
-for OLD in $FILES; do
-    BASE=`perl -e '$name="'${OLD}'"; print "",($name =~ /(.*?)\.[0-9]/), "\n";'`
-    EXT=`echo $OLD|sed -e 's,'${BASE}',,g'`
-    NEW=`echo ${BASE}%{samba_major}${EXT}`
-    mv $OLD $NEW
+for OLD in %{buildroot}/%{_mandir}/man?/{%{commonbin},%{serverbin},%{serversbin},swat,{%testbin},smb.conf,lmhosts}*
+do
+    if [ -e $OLD ]
+    then
+        BASE=`perl -e '$_="'${OLD}'"; m,(%buildroot)(.*?)(\.[0-9]),;print "$1$2\n";'`
+#        BASE=`perl -e '$name="'${OLD}'"; print "",($name =~ /(.*?)\.[0-9]/), "\n";'`
+       EXT=`echo $OLD|sed -e 's,'${BASE}',,g'`
+       NEW=`echo ${BASE}%{samba_major}${EXT}`
+       mv $OLD $NEW
+    fi
 done           
 # Replace paths in config files and init scripts:
-for i in smb winbind;do
+for i in smb ;do
        perl -pi -e 's,/subsys/'$i',/subsys/'$i'%{samba_major},g' $RPM_BUILD_ROOT/%{_initrddir}/${i}%{samba_major}
 done
-for i in %{_sysconfdir}/%{name}/smb.conf %{_initrddir}/smb%{samba_major} %{_sbindir}/%{name} %{_initrddir}/winbind%{samba_major} %{_sbindir}/winbind%{samba_major} /%{_sysconfdir}/logrotate.d/%{name} /%{_sysconfdir}/xinetd.d/swat%{samba_major} %{_initrddir}/wrepld%{samba_major}; do
-       perl -pi -e 's,/%{pkg_name},/%{name},g; s,smbd,%{_sbindir}/smbd%{samba_major},g; s,nmbd,%{_sbindir}/nmbd%{samba_major},g; s,winbindd,%{_sbindir}/winbindd%{samba_major},g; s,/usr/sbin/swat,%{_sbindir}/swat%{samba_major},g;s,wrepld,%{_sbindir}/wrepld%{samba_major},g' $RPM_BUILD_ROOT/$i;
+for i in %{_sysconfdir}/%{name}/smb.conf %{_initrddir}/smb%{samba_major} %{_sbindir}/%{name} %{_initrddir}/winbind /%{_sysconfdir}/logrotate.d/%{name} /%{_sysconfdir}/xinetd.d/swat%{samba_major} %{_initrddir}/wrepld%{samba_major}; do
+       perl -pi -e 's,/%{pkg_name},/%{name},g; s,smbd,%{_sbindir}/smbd%{samba_major},g; s,nmbd,%{_sbindir}/nmbd%{samba_major},g; s,/usr/sbin/swat,%{_sbindir}/swat%{samba_major},g;s,wrepld,%{_sbindir}/wrepld%{samba_major},g' $RPM_BUILD_ROOT/$i;
 done
-# Fix pam files
-perl -pi -e 's/winbind/winbind%{samba_major}/g' $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/system-auth-winbind%{samba_major}
 # Fix xinetd file for swat:
 perl -pi -e 's,/usr/sbin,%{_sbindir},g' $RPM_BUILD_ROOT/%{_sysconfdir}/xinetd.d/swat%{samba_major}
 %endif
@@ -1134,6 +1280,33 @@ for i in %{_bindir}/pam_smbpass.so %{_bindir}/smbwrapper.so;do
 rm -f %{buildroot}/$i
 done
 
+# (sb) make a smb.conf.clean we can use for the merge, since an existing
+# smb.conf won't get overwritten
+cp $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/smb.conf $RPM_BUILD_ROOT/%{_datadir}/%{name}/smb.conf.clean
+
+# (sb) leave a README.mdk.conf to explain what has been done
+cat << EOF > $RPM_BUILD_ROOT/%{_datadir}/%{name}/README.mdk.conf
+In order to facilitate upgrading an existing samba install, and merging
+previous configuration data with any new syntax used by samba3, a merge
+script has attempted to combine your local configuration data with the
+new conf file format.  The merged data is in smb.conf, with comments like
+
+       # *** merged from original smb.conf: ***
+
+near the additional entries.  Any local shares should have been appended to
+smb.conf.  A log of what took place should be in: 
+
+       /var/log/samba/smb-migrate.log
+
+A clean samba3 smb.conf is in /usr/share/samba, named smb.conf.clean.
+Your original conf should be /etc/samba/smb.conf.tomerge.
+
+The actual merge script is /usr/share/samba/scripts/smb-migrate.
+
+Questions/issues: sbenedict@mandrakesoft.com
+
+EOF
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -1155,17 +1328,6 @@ if [ -f $i ]; then
 fi
 done
 
-# Remove the transient tdb files (modified from version in off. samba spec:
-for TDB in brlock unexpected locking messages; do
-        if [ -e /var/cache/%{name}/$TDB.tdb ]; then
-                rm -f /var/cache/%{name}/$TDB.tdb;
-        fi;
-done
-
-if [ -d /var/lock/samba ]; then
-        rm -rf /var/lock/samba
-fi
-
 %post common
 # Basic migration script for pre-2.2.1 users,
 # since smb config moved from /etc to %{_sysconfdir}/samba
@@ -1184,12 +1346,6 @@ fi
 # Let's define the proper paths for config files
 perl -pi -e 's/(\/etc\/)(smb)/\1%{name}\/\2/' %{_sysconfdir}/%{name}/smb.conf
 
-# Let's replace lpstat with cups in older smb.conf:
-%if %build_cupspc
-echo "Updating samba printing configuration if necessary..."
-perl -pi -e 's/= lpstat/= cups/' %{_sysconfdir}/%{name}/smb.conf
-%endif
-
 # Fix the logrotate.d file from smb and nmb to smbd and nmbd
 if [ -f %{_sysconfdir}/logrotate.d/samba ]; then
         perl -pi -e 's/smb /smbd /' %{_sysconfdir}/logrotate.d/samba
@@ -1199,17 +1355,34 @@ fi
 # And not loose our machine account SID
 [ -f %{_sysconfdir}/MACHINE.SID ] && mv -f %{_sysconfdir}/MACHINE.SID %{_sysconfdir}/%{name}/ ||:
 
+%triggerpostun common -- samba-common < 3.0.1-3mdk
+# (sb) merge any existing smb.conf with new syntax file
+if [ $1 = 2 ]; then
+       # (sb) save existing smb.conf for merge
+       echo "Upgrade: copy smb.conf to smb.conf.tomerge for merging..."
+       cp -f %{_sysconfdir}/%{name}/smb.conf %{_sysconfdir}/%{name}/smb.conf.tomerge
+       echo "Upgrade: merging previous smb.conf..."
+       if [ -f %{_datadir}/%{name}/smb.conf.clean ]; then
+               cp %{_datadir}/%{name}/smb.conf.clean %{_sysconfdir}/%{name}/smb.conf
+               cp %{_datadir}/%{name}/README.mdk.conf %{_sysconfdir}/%{name}/
+               %{_datadir}/%{name}/scripts/smb-migrate commit
+       fi
+fi
+
+%postun common
+if [ -f %{_sysconfdir}/%{name}/README.mdk.conf ];then rm -f %{_sysconfdir}/%{name}/README.mdk.conf;fi
+
 %if %build_winbind
 %post winbind
 if [ $1 = 1 ]; then
-    /sbin/chkconfig winbind%{samba_major} on
+    /sbin/chkconfig winbind on
     cp -af %{_sysconfdir}/nsswitch.conf %{_sysconfdir}/nsswitch.conf.rpmsave
     cp -af %{_sysconfdir}/nsswitch.conf %{_sysconfdir}/nsswitch.conf.rpmtemp
     for i in passwd group;do
-        grep ^$i %{_sysconfdir}/nsswitch.conf |grep -v 'winbind%{samba_major}' >/dev/null
+        grep ^$i %{_sysconfdir}/nsswitch.conf |grep -v 'winbind' >/dev/null
         if [ $? = 0 ];then
-            echo "Adding a winbind%{samba_major} entry to the $i section of %{_sysconfdir}/nsswitch.conf"
-            awk '/^'$i'/ {print $0 " winbind%{samba_major}"};!/^'$i'/ {print}' %{_sysconfdir}/nsswitch.conf.rpmtemp >%{_sysconfdir}/nsswitch.conf;
+            echo "Adding a winbind entry to the $i section of %{_sysconfdir}/nsswitch.conf"
+            awk '/^'$i'/ {print $0 " winbind"};!/^'$i'/ {print}' %{_sysconfdir}/nsswitch.conf.rpmtemp >%{_sysconfdir}/nsswitch.conf;
            cp -af %{_sysconfdir}/nsswitch.conf %{_sysconfdir}/nsswitch.conf.rpmtemp
         else
             echo "$i entry found in %{_sysconfdir}/nsswitch.conf"
@@ -1220,10 +1393,10 @@ fi
 
 %preun winbind
 if [ $1 = 0 ]; then
-       echo "Removing winbind%{samba_major} entries from %{_sysconfdir}/nsswitch.conf"
-       perl -pi -e 's/ winbind%{samba_major}//' %{_sysconfdir}/nsswitch.conf
+       echo "Removing winbind entries from %{_sysconfdir}/nsswitch.conf"
+       perl -pi -e 's/ winbind//' %{_sysconfdir}/nsswitch.conf
 
-       /sbin/chkconfig winbind%{samba_major} reset
+       /sbin/chkconfig winbind reset
 fi
 %endif %build_winbind
 
@@ -1231,10 +1404,10 @@ fi
 %post -n nss_wins%{samba_major}
 if [ $1 = 1 ]; then
     cp -af %{_sysconfdir}/nsswitch.conf %{_sysconfdir}/nsswitch.conf.rpmsave
-    grep '^hosts' %{_sysconfdir}/nsswitch.conf |grep -v 'wins%{samba_major}' >/dev/null
+    grep '^hosts' %{_sysconfdir}/nsswitch.conf |grep -v 'wins' >/dev/null
     if [ $? = 0 ];then
         echo "Adding a wins entry to the hosts section of %{_sysconfdir}/nsswitch.conf"
-        awk '/^hosts/ {print $0 " wins%{samba_major}"};!/^hosts/ {print}' %{_sysconfdir}/nsswitch.conf.rpmsave >%{_sysconfdir}/nsswitch.conf;
+        awk '/^hosts/ {print $0 " wins"};!/^hosts/ {print}' %{_sysconfdir}/nsswitch.conf.rpmsave >%{_sysconfdir}/nsswitch.conf;
     else
         echo "wins entry found in %{_sysconfdir}/nsswitch.conf"
     fi
@@ -1245,7 +1418,7 @@ fi
 %preun -n nss_wins%{samba_major}
 if [ $1 = 0 ]; then
        echo "Removing wins entry from %{_sysconfdir}/nsswitch.conf"
-       perl -pi -e 's/ wins%{samba_major}//' %{_sysconfdir}/nsswitch.conf
+       perl -pi -e 's/ wins//' %{_sysconfdir}/nsswitch.conf
 #else
 #      echo "Leaving %{_sysconfdir}/nsswitch.conf intact"
 fi
@@ -1260,15 +1433,6 @@ if [ $1 = 0 ] ; then
 #    /sbin/chkconfig --level 35 smb reset
 # Let's not loose /var/cache/samba
 
-#    for i in browse.dat wins.dat brlock.tdb unexpected.tdb connections.tdb \
-#locking.tdb messages.tdb;do
-#        if [ -e /var/cache/samba/$i ]; then
-#                mv -f /var/cache/samba/$i /var/cache/samba/$i.BAK
-#        fi;
-#    done
-    if [ -d /var/log/%{name} ]; then
-      rm -rf /var/log/%{name}/*
-    fi
     if [ -d /var/cache/%{name} ]; then
       mv -f /var/cache/%{name} /var/cache/%{name}.BAK
     fi
@@ -1292,37 +1456,42 @@ if [ "$1" = "0" -a -x /usr/bin/update-menus ]; then /usr/bin/update-menus || tru
 
 %clean_menus
 
-%triggerpostun -- samba < 1.9.18p7
+%if %build_system
+%post -n %{libname} -p /sbin/ldconfig
+%postun -n %{libname} -p /sbin/ldconfig
+%endif
 
-if [ $1 != 0 ]; then
-    /sbin/chkconfig --level 35 smb on
-fi
+%if %build_alternatives
+%post client
 
-%triggerpostun -- samba < 2.0.5a-3, samba >= 2.0.0
+update-alternatives --install %{_bindir}/smbclient smbclient \
+%{_bindir}/smbclient%{alternative_major} 10 \
+$(for i in {/bin/mount.cifs,/sbin/{%{client_sbin}},%{_bindir}/{%{clientbin}}};do
+j=`basename $i`
+[ "$j" = "smbclient" ] || \
+echo -n " --slave ${i} ${j} ${i}%{alternative_major}";done) \
+--slave %{_libdir}/cups/backend/smb cups_smb %{_libdir}/cups/backend/smb%{alternative_major} || \
+update-alternatives --auto smbclient
 
-if [ $1 != 0 ]; then
-        [ ! -d /var/lock/samba ] && mkdir -m 0755 /var/lock/samba ||:
-        [ ! -d /var/spool/samba ] && mkdir -m 1777 /var/spool/samba ||:
-        [ -f %{_sysconfdir}/inetd.conf ] && chmod 644 %{_sysconfdir}/services %{_sysconfdir}/inetd.conf ||:
-fi
+%preun client
+[ $1 = 0 ] && update-alternatives --remove smbclient %{_bindir}/smbclient%{alternative_major} ||:
+%endif
+
+%if %build_alternatives
+%triggerpostun client -- samba-client, samba2-client
+[ ! -e %{_bindir}/smbclient ] && update-alternatives --auto smbclient || :
+%endif
 
 %files server
 %defattr(-,root,root)
-#%attr(-,root,root) /sbin/*
-%{_sbindir}/%{name}
-%{_sbindir}/smbd%{samba_major}
-%{_sbindir}/nmbd%{samba_major}
-#%{_sbindir}/wrepld%{samba_major}
-%{_bindir}/smbcontrol%{samba_major}
-#%{_sbindir}/mkntpwd
-%{_bindir}/smbstatus%{samba_major}
-%{_bindir}/pdbedit%{samba_major}
-%{_bindir}/tdbbackup%{samba_major}
-%{_bindir}/profiles%{samba_major}
-%{_bindir}/editreg%{samba_major}
+%(for i in %{_sbindir}/{%{serversbin}}%{samba_major};do echo $i;done)
+%(for i in %{_bindir}/{%{serverbin}}%{samba_major};do echo $i;done)
 %attr(755,root,root) /%{_lib}/security/pam_smbpass*
 %dir %{_libdir}/%{name}/vfs
 %{_libdir}/%{name}/vfs/*.so
+%if %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan*.so
+%endif
 %dir %{_libdir}/%{name}/pdb
 
 %attr(-,root,root) %config(noreplace) %{_sysconfdir}/%{name}/smbusers
@@ -1331,29 +1500,21 @@ fi
 %attr(-,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
 %attr(-,root,root) %config(noreplace) %{_sysconfdir}/pam.d/%{name}
 #%attr(-,root,root) %config(noreplace) %{_sysconfdir}/%{name}/samba-slapd.include
-%{_mandir}/man1/smbstatus*.1*
-%{_mandir}/man5/smbpasswd*.5*
-%{_mandir}/man7/samba*.7*
-%{_mandir}/man8/smbd*.8*
-%{_mandir}/man8/nmbd*.8*
-%{_mandir}/man8/pdbedit*.8*
-%{_mandir}/man1/smbcontrol*.1*
-%{_mandir}/man8/tdbbackup*.8*
-%{_mandir}/man1/profiles*.1*
-%{_mandir}/man1/editreg*.1*
+%(for i in %{_mandir}/man?/{%{serverbin},%{serversbin}}%{samba_major}\.[0-9]*;do echo $i|grep -v mkntpwd;done)
 %attr(775,root,adm) %dir %{_localstatedir}/%{name}/netlogon
 %attr(755,root,root) %dir %{_localstatedir}/%{name}/profiles
 %attr(755,root,root) %dir %{_localstatedir}/%{name}/printers
-%attr(775,root,adm) %dir %{_localstatedir}/%{name}/printers/*
+%attr(2775,root,adm) %dir %{_localstatedir}/%{name}/printers/*
 %attr(1777,root,root) %dir /var/spool/%{name}
 %dir %{_datadir}/%{name}
 %dir %{_datadir}/%{name}/scripts
 %attr(0755,root,root) %{_datadir}/%{name}/scripts/print-pdf
-#%attr(0750,root,root) %{_datadir}/%{name}/scripts/smbldap*.pl
-#%attr(0640,root,root) %config(noreplace) %{_sysconfdir}/%{name}/smbldap_conf.pm
-#%attr(0644,root,root) %{_datadir}/%{name}/scripts/smbldap_tools.pm
-#%{perl_vendorlib}/*.pm
-%attr(0700,root,root) %{_datadir}/%{name}/scripts/*port_smbpasswd.pl
+%attr(0750,root,adm) %{_datadir}/%{name}/scripts/smbldap*.pl
+%attr(0750,root,adm) %{_bindir}/smbldap*
+%attr(0640,root,adm) %config(noreplace) %{_sysconfdir}/%{name}/smbldap_conf.pm
+%attr(0644,root,root) %{_datadir}/%{name}/scripts/smbldap_tools.pm
+%{perl_vendorlib}/*.pm
+#%attr(0700,root,root) %{_datadir}/%{name}/scripts/*port_smbpasswd.pl
 %attr(0755,root,root) %{_datadir}/%{name}/scripts/convertSambaAccount
 
 
@@ -1362,8 +1523,8 @@ fi
 %doc README COPYING Manifest Read-Manifest-Now
 %doc WHATSNEW.txt Roadmap
 %doc README.%{name}-mandrake-rpm
-%doc docs
-%doc examples
+%doc clean-docs/samba-doc/docs
+%doc clean-docs/samba-doc/examples
 %attr(-,root,root) %{_datadir}/swat%{samba_major}/using_samba/
 
 %files swat
@@ -1381,17 +1542,28 @@ fi
 %lang(ja) %{_datadir}/swat%{samba_major}/lang/ja
 %lang(tr) %{_datadir}/swat%{samba_major}/lang/tr
 %{_mandir}/man8/swat*.8*
-%doc swat/README
+%lang(de) %{_libdir}/%{name}/de.msg
+%lang(en) %{_libdir}/%{name}/en.msg
+%lang(fr) %{_libdir}/%{name}/fr.msg
+%lang(it) %{_libdir}/%{name}/it.msg
+%lang(ja) %{_libdir}/%{name}/ja.msg
+%lang(nl) %{_libdir}/%{name}/nl.msg
+%lang(pl) %{_libdir}/%{name}/pl.msg
+%lang(tr) %{_libdir}/%{name}/tr.msg
+#%doc swat/README
 
 %files client
 %defattr(-,root,root)
+%(for i in %{_bindir}/{%{clientbin}}%{alternative_major};do echo $i;done)
+%(for i in %{_mandir}/man?/{%{clientbin}}%{alternative_major}.?.*;do echo $i|grep -v smbprint;done)
+#xclude %{_mandir}/man?/smbget*
+%{_mandir}/man5/smbgetrc%{alternative_major}.5*
 %ifnarch alpha
-/sbin/mount.smb%{samba_major}
-/sbin/mount.smbfs%{samba_major}
-/sbin/mount.cifs
-%attr(755,root,root) %{_bindir}/smbmount%{samba_major}
-%attr(4755,root,root) %{_bindir}/smbumount%{samba_major}
-%attr(4755,root,root) %{_bindir}/smbmnt%{samba_major}
+%(for i in /sbin/{%{client_sbin}}%{alternative_major};do echo $i;done)
+%attr(4755,root,root) /bin/mount.cifs%{alternative_major}
+%attr(755,root,root) %{_bindir}/smbmount%{alternative_major}
+%attr(4755,root,root) %{_bindir}/smbumount%{alternative_major}
+%attr(4755,root,root) %{_bindir}/smbmnt%{alternative_major}
 %{_mandir}/man8/smbmnt*.8*
 %{_mandir}/man8/smbmount*.8*
 %{_mandir}/man8/smbumount*.8*
@@ -1400,41 +1572,20 @@ fi
 %exclude %{_bindir}/smb*m*nt%{samba_major}
 %exclude %{_mandir}/man8/smb*m*nt*.8*
 %endif
-%{_bindir}/nmblookup%{samba_major}
-%{_bindir}/findsmb%{samba_major}
-%{_bindir}/smbclient%{samba_major}
-%{_bindir}/smbprint%{samba_major}
-%{_bindir}/smbtar%{samba_major}
-%{_bindir}/smbspool%{samba_major}
 # Link of smbspool to CUPS
-/%{_libdir}/cups/backend/smb%{samba_major}
-/%{_mandir}/man1/nmblookup*.1*
-/%{_mandir}/man1/findsmb*.1*
-/%{_mandir}/man1/smbclient*.1*
-/%{_mandir}/man1/smbtar*.1*
-/%{_mandir}/man8/smbspool*.8*
+/%{_libdir}/cups/backend/smb%{alternative_major}
 
 %files common
 %defattr(-,root,root)
 %dir /var/cache/%{name}
 %dir /var/log/%{name}
 %dir /var/run/%{name}
-#%{_bindir}/make_smbcodepage
-#%{_bindir}/make_unicodemap
-%{_bindir}/testparm%{samba_major}
-%{_bindir}/testprns%{samba_major}
-#%{_bindir}/make_printerdef
-%{_bindir}/rpcclient%{samba_major}
-#%{_bindir}/smbsh%{samba_major}
-%{_bindir}/smbpasswd%{samba_major}
-%{_bindir}/smbcacls%{samba_major}
-%{_bindir}/smbcquotas%{samba_major}
-%{_bindir}/net%{samba_major}
-%{_bindir}/smbtree%{samba_major}
-%{_bindir}/ntlm_auth%{samba_major}
+%(for i in %{_bindir}/{%{commonbin},tdbtool}%{samba_major};do echo $i;done)
+%(for i in %{_mandir}/man?/{%{commonbin}}%{samba_major}\.[0-9]*;do echo $i;done)
 #%{_libdir}/smbwrapper%{samba_major}.so
 %dir %{_libdir}/%{name}
 %{_libdir}/%{name}/*.dat
+%{_libdir}/%{name}/charset
 #%{_libdir}/%{name}/lowcase.dat
 #%{_libdir}/%{name}/valid.dat
 %dir %{_sysconfdir}/%{name}
@@ -1443,31 +1594,23 @@ fi
 %attr(-,root,root) %config(noreplace) %{_sysconfdir}/%{name}/lmhosts
 %dir %{_localstatedir}/%{name}
 %attr(-,root,root) %{_localstatedir}/%{name}/codepages
-#%{_mandir}/man1/make_smbcodepage*.1*
-#%{_mandir}/man1/make_unicodemap*.1*
-%{_mandir}/man1/testparm*.1*
-%{_mandir}/man1/rpcclient*.1*
-%{_mandir}/man1/testprns*.1*
 %{_mandir}/man5/smb.conf*.5*
 %{_mandir}/man5/lmhosts*.5*
-%{_mandir}/man8/smbpasswd*.8*
-%{_mandir}/man1/smbcacls*.1*
-%{_mandir}/man1/smbcquotas*.1*
-%{_mandir}/man8/net*.8*
-%{_mandir}/man1/smbtree*.1*
-%{_mandir}/man1/ntlm_auth*.1*
-%{_mandir}/man7/Samba*.7*
+#%{_mandir}/man7/Samba*.7*
 %dir %{_datadir}/swat%{samba_major}
+%attr(0750,root,adm) %{_datadir}/%{name}/scripts/smb-migrate
+%attr(-,root,root) %{_datadir}/%{name}/smb.conf.clean
+%attr(-,root,root) %{_datadir}/%{name}/README.mdk.conf
 
 %if %build_winbind
 %files winbind
 %defattr(-,root,root)
-%{_sbindir}/winbindd%{samba_major}
-%{_sbindir}/winbind%{samba_major}
-%{_bindir}/wbinfo%{samba_major}
+%{_sbindir}/winbindd
+%{_sbindir}/winbind
+%{_bindir}/wbinfo
 %attr(755,root,root) /%{_lib}/security/pam_winbind*
-%attr(755,root,root) /%{_lib}/libnss_winbind%{samba_major}*
-%attr(-,root,root) %config(noreplace) %{_initrddir}/winbind%{samba_major}
+%attr(755,root,root) /%{_lib}/libnss_winbind*
+%attr(-,root,root) %config(noreplace) %{_initrddir}/winbind
 %attr(-,root,root) %config(noreplace) %{_sysconfdir}/pam.d/system-auth-winbind*
 %{_mandir}/man8/winbindd*.8*
 %{_mandir}/man1/wbinfo*.1*
@@ -1476,43 +1619,41 @@ fi
 %if %build_wins
 %files -n nss_wins%{samba_major}
 %defattr(-,root,root)
-%attr(755,root,root) /%{_lib}/libnss_wins%{samba_major}.so*
+%attr(755,root,root) /%{_lib}/libnss_wins.so*
 %endif
 
-%if %{?_without_test:0}%{!?_without_test:1}
+%if %{?_with_test:1}%{!?_with_test:0}
 %files test
 %defattr(-,root,root)
-%{_bindir}/debug2html%{samba_major}
-%{_bindir}/smbtorture%{samba_major}
-%{_bindir}/msgtest%{samba_major}
-%{_bindir}/masktest%{samba_major}
-%{_bindir}/locktest%{samba_major}
-%{_bindir}/locktest2%{samba_major}
-%{_bindir}/nsstest%{samba_major}
-%{_bindir}/vfstest%{samba_major}
+%(for i in %{_bindir}/{%{testbin}}%{samba_major};do echo $i;done)
 %{_mandir}/man1/vfstest%{samba_major}*.1*
+%exclude %{_mandir}/man1/log2pcap*.1*
 %else
 %exclude %{_mandir}/man1/vfstest%{samba_major}*.1*
+%exclude %{_mandir}/man1/log2pcap*.1*
 %endif
 
 %if %build_system
-%files -n libsmbclient%{libsmbmajor}
+%files -n %{libname}
 %defattr(-,root,root)
-%{_libdir}/libsmbclient.so*
+%{_libdir}/libsmbclient.so.*
 %else
-%exclude %{_libdir}/libsmbclient.so*
+%exclude %{_libdir}/libsmbclient.so.*
 %endif
 
 %if %build_system
-%files -n libsmbclient%{libsmbmajor}-devel
+%files -n %{libname}-devel
 %defattr(-,root,root)
 %{_includedir}/*
+%{_libdir}/libsmbclient.so
+%doc clean-docs/libsmbclient/*
 %else
 %exclude %{_includedir}/*
+%exclude %{_libdir}/libsmbclient.so
 %endif
 
 %if %build_system
-%files -n libsmbclient%{libsmbmajor}-static-devel
+%files -n %{libname}-static-devel
 %defattr(-,root,root)
 %{_libdir}/libsmbclient.a
 %else
@@ -1529,11 +1670,29 @@ fi
 %{_libdir}/%{name}/pdb/*mysql.so
 %endif
 
+#ifnarch alpha
+%files passdb-pgsql
+%defattr(-,root,root)
+%{_libdir}/%{name}/pdb/*pgsql.so
+#endif
+
 %files passdb-xml
 %defattr(-,root,root)
 %{_libdir}/%{name}/pdb/*xml.so
 
 #Files for antivirus support:
+%if %build_clamav
+%files vscan-clamav
+%defattr(-,root,root)
+%{_libdir}/%{name}/vfs/vscan-clamav.so
+%config(noreplace) %{_sysconfdir}/%{name}/vscan-clamav.conf
+%doc %{vfsdir}/%{vscandir}/INSTALL
+%endif
+%if !%build_clamav && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-clamav.so
+%exclude %{_sysconfdir}/%{name}/vscan-clamav.conf
+%endif
+
 %if %build_fprot
 %files vscan-fprot
 %defattr(-,root,root)
@@ -1541,6 +1700,35 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-fprotd.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_fprot && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-fprotd.so
+%exclude %{_sysconfdir}/%{name}/vscan-fprotd.conf
+%endif
+
+%if %build_fsav
+%files vscan-fsecure
+%defattr(-,root,root)
+%{_libdir}/%{name}/vfs/vscan-fsav.so
+%config(noreplace) %{_sysconfdir}/%{name}/vscan-fsav.conf
+%doc %{vfsdir}/%{vscandir}/INSTALL
+%endif
+%if !%build_fsav && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-fsav.so
+%exclude %{_sysconfdir}/%{name}/vscan-fsav.conf
+%endif
+
+%if %build_icap
+%files vscan-icap
+%defattr(-,root,root)
+%{_libdir}/%{name}/vfs/vscan-icap.so
+%config(noreplace) %{_sysconfdir}/%{name}/vscan-icap.conf
+%doc %{vfsdir}/%{vscandir}/INSTALL
+%endif
+%if !%build_icap && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-icap.so
+%exclude %{_sysconfdir}/%{name}/vscan-icap.conf
+%endif
+
 
 %if %build_kaspersky
 %files vscan-kaspersky
@@ -1549,6 +1737,10 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-kavp.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_kaspersky && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-kavp.so
+%exclude %{_sysconfdir}/%{name}/vscan-kavp.conf
+%endif
 
 %if %build_mks
 %files vscan-mks
@@ -1557,6 +1749,22 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-mks*.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_mks && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-mksd.so
+%exclude %{_sysconfdir}/%{name}/vscan-mks*.conf
+%endif
+
+%if %build_nai
+%files vscan-nai
+%defattr(-,root,root)
+%{_libdir}/%{name}/vfs/vscan-mcdaemon.so
+%config(noreplace) %{_sysconfdir}/%{name}/vscan-mcdaemon.conf
+%doc %{vfsdir}/%{vscandir}/INSTALL
+%endif
+%if !%build_nai && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-mcdaemon.so
+%exclude %{_sysconfdir}/%{name}/vscan-mcdaemon.conf
+%endif
 
 %if %build_openav
 %files vscan-openav
@@ -1565,6 +1773,10 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-oav.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_openav && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-oav.so
+%exclude %{_sysconfdir}/%{name}/vscan-oav.conf
+%endif
 
 %if %build_sophos
 %files vscan-sophos
@@ -1573,6 +1785,10 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-sophos.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_sophos && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-sophos.so
+%exclude %{_sysconfdir}/%{name}/vscan-sophos.conf
+%endif
 
 %if %build_symantec
 %files vscan-symantec
@@ -1581,6 +1797,9 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-symantec.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_symantec && %build_vscan
+%exclude %{_sysconfdir}/%{name}/vscan-symantec.conf
+%endif
 
 %if %build_trend
 %files vscan-trend
 %config(noreplace) %{_sysconfdir}/%{name}/vscan-trend.conf
 %doc %{vfsdir}/%{vscandir}/INSTALL
 %endif
+%if !%build_trend && %build_vscan
+%exclude %{_libdir}/%{name}/vfs/vscan-trend.so
+%exclude %{_sysconfdir}/%{name}/vscan-trend.conf
+%endif
 
 %exclude %{_mandir}/man1/smbsh*.1*
 
 %changelog
+* Tue Nov 09 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.8-1mdk
+- 3.0.8
+- add tdbtool to common
+- fix doc permissions (broken in tarball)
+
+* Fri Nov 05 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.8-0.pre2.1mdk
+- 3.0.8pre2
+
+* Wed Oct 06 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.7-3mdk
+- drop patch 23 to ldap schema (patch in 3.0.6 was to bring schema up-to-date
+  with pre-3.0.7 cvs) (#11960)
+- merge winbind init script fix into packaging patch
+- Don't set printcap name in pdf printer share (#11861)
+- allow official builds off-cluster (with _with_official macro defined)
+
+* Tue Sep 14 2004 Stew Benedict <sbenedict@mandrakesoft.com> 3.0.7-2mdk
+- fix typo in winbind init script that prevented stop
+  (in 3.0.6 too, patch27)
+
+* Mon Sep 13 2004 Stew Benedict <sbenedict@mandrakesoft.com> 3.0.7-1mdk
+- 3.0.7 (drop patch10,21,22,24,25,26; rediff patch23)
+
+* Thu Sep 09 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.6-5mdk
+- patch for samba bug 1464
+- make release-depenent release tag more like security updates tags
+- sync smb.conf with drakwizard (which also fixes quoting of macros which
+  can have spaces)
+- add example admin share
+- patches from Gerald Carter
+
+* Mon Aug 31 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.6-4mdk
+- Add Jerry's post-3.0.6 patches
+- fix bug 11088 
+
+* Fri Aug 27 2004 Buchan Milne <bgmilne@linux-mandrake.com>3.0.6-3mdk
+- patch from Urban Widmark via Robert Sim (anthill bug 1086) to be able
+  to diable unix extensions in smbmount (and via 'unix extensions' in smb.conf)
+- magic-devel only available on 9.2 and up
+- allow building for stable release on the chroots on the cluster
+- fix patch8
+- fix build on older releases
+
+* Fri Aug 20 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.6-2mdk
+- 3.0.6
+-drop P6 (merged), P7 (broken for now)
+-keep libsmbclient where it belongs (on x86 for now)
+-implement mandrake version-specific release number
+
+* Thu Aug 12 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.5-2mdk
+- 3.0.5
+- fix pid file location (#10666)
+- merge amd64 fixes (P7)
+- make pdf printer work again, and other misc fixes to default config
+
+* Sun Jun 20 2004 Oden Eriksson <oeriksson@mandrakesoft.com> 3.0.5-0.pre1.3mdk
+- fix rpm group in libsmbclient0-devel (Goetz Waschk)
+
+* Sat Jun 19 2004 Oden Eriksson <oeriksson@mandrakesoft.com> 3.0.5-0.pre1.2mdk
+- fix deps
+
+* Wed May 26 2004 Buchan Milne <bgmilne@linux-mandrake.com>3.0.5-0.pre1.1mdk
+- fix building without scanners
+- 3.0.5pre1 (and drop patch from CVS)
+
+* Fri May 21 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.4-3mdk
+- re-work scanner support
+
+* Thu May 13 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.4-2mdk
+- 3.0.4
+- Patch for winbind (from samba bug 1315)
+
+* Thu Apr 29 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.2a-4mdk
+- Fix samba-vscan (0.3.5), add clamav and icap, and build scanners by default
+- Fix default vscan-clamav config and add sample config for homes share
+- Add pgsql passdb backend
+
+* Mon Mar 01 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.2a-3mdk
+- Fix default smbldap config
+- Don't clobber smb.conf backup for no reason
+
+* Mon Feb 16 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.2a-2mdk
+- 3.0.2a
+- Only update smb.conf in upgrade from <3.0.1-3mdk (via trigger) and update
+  upgrade script (stew)
+
+* Mon Feb 09 2004 Buchan Milne <bgmilne@linux0mandrake.com> 3.0.2-2mdk
+- 3.0.2
+
+* Mon Feb 02 2004 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.2-0.rc2.1mdk
+- 3.0.2rc2
+
+* Tue Jan  6 2004 Stew Benedict <sbenedict@mandrakesoft.com> 3.0.1-5mdk
+- update migrate script, feedback from Luca Berra
+
+* Mon Jan  5 2004 Stew Benedict <sbenedict@mandrakesoft.com> 3.0.1-4mdk
+- re-enable relaxed CFLAGS to fix broken smbmount, smbclient
+
+* Fri Jan  2 2004 Stew Benedict <sbenedict@mandrakesoft.com> 3.0.1-3mdk
+- add migrate script to merge existing smb.conf
+
+* Fri Dec 19 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-2mdk
+- 3.0.1 final
+
+* Thu Dec 11 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.rc2.2mdk
+- 3.0.1rc2
+
+* Sat Dec 06 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.rc1.2mdk
+- rc1
+- samba-vscan-0.3.4
+
+* Fri Dec 05 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre3.5mdk
+- Allow winbind to start if old winbind ranges are used (ease upgrades)
+
+* Tue Nov 18 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre3.4mdk
+- Fix build as system on 8.2 (and probably earlier)
+
+* Sun Nov 16 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre3.3mdk
+- Ensure printer drivers keep permissions by default (setgid and inherit perms)
+
+* Fri Nov 14 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre3.2mdk
+- 3.0.1pre3
+- Add support for Mandrake 10.0 (as system samba)
+- Fix alternatives triggers
+- Fix obsoletes
+
+* Mon Nov 10 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre2.2mdk
+- 3.0.1pre2
+- misc spec files (pointed out by Luca Olivetti)
+- Fix path to smbldap-passwd.pl
+- Only allow one copy of winbind and nss_wins
+- Add trigger for alternatives
+
+* Sun Oct 12 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.1-0.pre1.2mdk
+- 3.0.1pre1
+- remove buildroot patch (p3), fixed upstream
+
+* Thu Sep 25 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-2mdk
+- 3.0.0 final
+
+* Sat Sep 13 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc4.2mdk
+- rc4
+- Don't update alternatives in pre/post scripts when not using alternatives
+- Fix case of --with-system without alternatives
+- Final fixes to smbldap-tools for non-system case
+- Remove duplicate docs (really - 1 character typo ...)
+- Update configs (fix winbind init script, add example scripts in smb.conf)
+
+* Tue Sep 09 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc3.2mdk
+- rc3
+- Fix mount.smb{,fs} alternatives (spotted by Laurent Culioli)
+
+* Thu Sep 04 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc2.3mdk
+- Fix alternatives
+- Fix libname (can I blame guillomovitch's evil line-wrapping spec mode?)
+- Fix smbldap-tools package/use names when not system samba
+- Don't conflict samba3-client with samba-client for now so we can install it
+
+* Fri Aug 29 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc2.2mdk
+- rc2
+- Remove patches 100-102 (upstream)
+- Fix libname
+- Alternatavise client
+- Better solution to avoid rpath
+
+* Fri Aug 22 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc1.3mdk
+- Fix build with test package (p100), but not by default (too big)
+- Fix (p101) for SID resolution when member of samba-2.2.x domain
+- Fix libsmbclient packages (thanks Gotz)
+- version mount.cifs, patch from CVS (p102), and setuid it
+- Clean up docs (guillomovitch spam ;-)
+
+* Sat Aug 16 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.rc1.2mdk
+- rc1
+- disable test subpackage since it's broken again
+
 * Mon Jul 28 2003 Buchan Milne <bgmilne@linux-mandrake.com> 3.0.0-0.beta3.3mdk
 - Rebuild for kerberos-1.3 on cooker
 - Put printer directories back