# $Source: /opt/cvs/samba/smbldap-tools/smbldap-tools.spec,v $
%define name 	smbldap-tools
%define realname  smbldap-tools

%ifos linux
%undefine sysconf_ext
%endif

%ifos %{solaris}
%define prefix_opt     1
%define _prefix         /opt/osstech
%define _sysconfdir	%{_prefix}/etc
%define sysconf_ext	.default
%endif

Summary:       User & Group administration tools for Samba/LDAP
Name: 		%{name}
Version: 0.9.2
Release: 1.8_OSSTECH
Group: 		System Environment/Base
License: 	GPL
URL:		http://samba.idealx.org/
Vendor:		OSS Tech Corp. <http://www.osstech.co.jp>
Source:	smbldap-tools-%{version}.tar.gz
Source1: samba.schema
Source2: samba-schema-netscapeds5.x
BuildRoot: 	/%{_tmppath}/%{name}
%ifos linux
BuildRequires:	perl >= 5.6
%endif
Requires:	perl >= 5.6, samba
Prefix:		%{_prefix}
BuildArch:	noarch
Patch0:		smbldap-tools-0.9.2-osstech_conf.patch
Patch1:		smbldap-tools-0.9.2-noadminpass.patch
Patch2: 	smbldap-tools-0.9.2-passwd.patch
Patch3:		smbldap-tools-0.9.2.utf8.patch

Patch100: smbldap-tools-0.9.2-solaris_conf.patch
Patch101: smbldap-tools-0.9.2-OracleSES.patch

%description
Smbldap-tools is a set of perl scripts designed to manage user and group 
accounts stored in an LDAP directory. They can be used both by users and 
administrators of Linux systems: 
. administrators can perform users and groups management operations, in a 
  way similar to the standard useradd or groupmod commands
. users can change their LDAP password from the command line

These scripts are developed and maintained by IDEALX for the Samba project.

Scripts are described in the Smbldap-tools User Manual
(http://samba.idealx.org/smbldap-tools.en.html) which also give command
line examples.
You can download the latest version on IDEALX web site
(http://samba.idealx.org/dist/).
Comments and/or questions can be sent to the smbldap-tools mailing list
(http://lists.idealx.org/lists/samba).

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

%ifos %{solaris}
%patch100 -p1
%endif

%patch101 -p1


%build
sed  "s,/etc/opt/IDEALX/smbldap-tools/,%{_sysconfdir}/smbldap-tools/,g" smbldap_tools.pm
sed  "s,/etc/opt/IDEALX/smbldap-tools/,%{_sysconfdir}/smbldap-tools/,g" configure.pl
sed  "s,/etc/opt/IDEALX/,%{_sysconfdir}/,g" smbldap.conf


%install
%{__rm} -rf %{buildroot}
mkdir -p $RPM_BUILD_ROOT/%_sysconfdir/smbldap-tools
mkdir -p $RPM_BUILD_ROOT/%_prefix/sbin/

for i in smbldap-*
do
	install $i $RPM_BUILD_ROOT/%_prefix/sbin/$i
done
install configure.pl $RPM_BUILD_ROOT/%_prefix/sbin/configure.pl
cp  smbldap.conf $RPM_BUILD_ROOT/%{_sysconfdir}/smbldap-tools/smbldap.conf%{?sysconf_ext}
cp  smbldap_bind.conf $RPM_BUILD_ROOT/%{_sysconfdir}/smbldap-tools/smbldap_bind.conf%{?sysconf_ext}
cp  smbldap_tools.pm $RPM_BUILD_ROOT/%{_prefix}/sbin
rm $RPM_BUILD_ROOT/%{_prefix}/sbin/smbldap-tools.spec

# Install samba.schema for OpenLDAP
mkdir -p $RPM_BUILD_ROOT/%_sysconfdir/openldap/schema
cp %{SOURCE1} $RPM_BUILD_ROOT/%_sysconfdir/openldap/schema/samba.schema 

%ifos %{solaris}
cp %{SOURCE2} $RPM_BUILD_ROOT/%_sysconfdir/smbldap-tools

ssbuild-pkgmk \
        --revision "$(expr "%{release}" : '\([^_]*\)_')" \
        %{?prefix_opt:--extraname "opt"} \
        --summary "%{summary}" \
        --vendor "%{vendor}" \
	--attr "%{_sysconfdir}/smbldap-tools/smbldap_bind.conf%{?sysconf_ext}:600::" \
        "$RPM_BUILD_ROOT" \
        "osstech-%{name}" \
        "%{version}" \
        "%{_rpmdir}"
%endif




%clean
if [ -n "$RPM_BUILD_ROOT" ] ; then
   [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
fi

%pre
files=`ls %{_prefix}/sbin/smbldap*.pl 2>/dev/null`
if [ "$files" != "" ];
then
	echo "WARNING: new scripts do not have any .pl extension"
	echo "         You need to update the smb.conf file"
fi

%post
# from smbldap-tools-0.8-2, libraries are loaded with the FindBin perl package
if [ -f /usr/lib/perl5/site_perl/smbldap_tools.pm ];
then
	rm -f /usr/lib/perl5/site_perl/smbldap_tools.pm
fi
if [ -f /usr/lib/perl5/site_perl/smbldap_conf.pm ];
then
	rm -f /usr/lib/perl5/site_perl/smbldap_conf.pm
fi

if [ ! -n `grep with_slappasswd %{_sysconfdir}/smbldap-tools/smbldap.conf | grep -v "^#"` ];
then
        echo "Check if you have the with_slappasswd parameter defined"
	echo "in smbldap.conf file (see the INSTALL file)"
fi

%files
%defattr(-,root,root)
%{_prefix}/sbin/configure.pl
%{_prefix}/sbin/smbldap-groupadd
%{_prefix}/sbin/smbldap-groupdel
%{_prefix}/sbin/smbldap-groupmod
%{_prefix}/sbin/smbldap-groupshow
%{_prefix}/sbin/smbldap-passwd
%{_prefix}/sbin/smbldap-populate
%{_prefix}/sbin/smbldap-useradd
%{_prefix}/sbin/smbldap-userdel
%{_prefix}/sbin/smbldap-usermod
%{_prefix}/sbin/smbldap-userinfo
%{_prefix}/sbin/smbldap-usershow
%{_prefix}/sbin/smbldap_tools.pm
%{_sysconfdir}/openldap/schema/samba.schema

%doc CONTRIBUTORS COPYING ChangeLog FILES INFRA README INSTALL TODO
%doc smb.conf smbldap.conf smbldap_bind.conf
%doc doc/smbldap-*
%doc doc/html
%defattr(644,root,root)
%config(noreplace) %{_sysconfdir}/smbldap-tools/smbldap.conf%{?sysconf_ext}
%defattr(600,root,root)
%config(noreplace) %{_sysconfdir}/smbldap-tools/smbldap_bind.conf%{?sysconf_ext}

%changelog
* Thu Jul 19 2007 SATOH Fumiyasu <fumiyas@osstech.co.jp> 0.9.2-1.8_OSSTECH
- fix sambaUnixIdPooldn value in default smbldap-tools.conf
- fix smb.conf path for Samba in /opt/osstech

* Sat Jul 14 2007 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.7_OSSTECH
- fix a permission(to 600) of smbldap_bind.conf.default on Solaris
- replace with_smbpasswd parameter from 1 to 0

* Fri Jul 13 2007 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.6_OSSTECH
- refine spec file to build from our svn
- add new samba-schema-netscapeds5.x for Sun DS(SourceNo.2)
- fix spec file to build on Solaris with ssbuild
- add uniqueMember attr to smbldap-tools and smbldap.conf for OracleSES(Patch:101)

* Mon Jan 15 2007 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.5_OSSTECH
- fix patch no.2

* Fri Dec 15 2006 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.4_OSSTECH
- add UTF-8 encoding patch (bug#3997) (Patch No.3)
- add samba.schema for OpenLDAP (Source No.1)

* Mon Oct 16 2006 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.3_OSSTECH
- removed to set admin password from smbldap-populate (Patch No.1)
- changed the default value of StartTLS of smbldap.conf (Patch No.0)
- Add password option for smbldap-passwd and smbldap-useradd(Patch No.2)

* Tue Sep 26 2006 Yasuma Takeda <yasuma@osstech.co.jp> 0.9.2-1.2_OSSTECH
- refine smbldap.conf file (Patch No.0)

* Tue Sep 12 2006 Yasuma Takeda <yasuma@osstech.org> 0.9.2-1.1OSSTECH
- rewrite for OSSTECH

* Fri Nov 28 2003 Jerome Tournier <jerome.tournier@idealx.com> 0.8.2-1
- see Changelog file for updates in scripts

