File smbldap-tools.spec of Package smbldap-tools

#
# spec file for package smbldap-tools
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2011, 2016, Weberhofer GmbH, Vienna, Austria.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           smbldap-tools
Version:        0.9.11
Release:        0
Summary:        User & Group administration tools for Samba/LDAP
License:        GPL-2.0+
Group:          Productivity/Networking/Samba
Url:            http://gna.org/projects/smbldap-tools/
Source0:        http://download.gna.org/smbldap-tools/sources/%{version}/%{name}-%{version}.tar.gz
Source1:        http://download.gna.org/smbldap-tools/sources/%{version}/%{name}-%{version}.tar.gz.sig
Patch11:        %{name}-0.9.11-suse-migrationscripts.patch
Patch12:        %{name}-0.9.9-suse-populate.patch
BuildRequires:  openssl
BuildRequires:  perl >= 5.6
Requires:       perl-Digest-SHA1
Requires:       perl-IO-Socket-SSL
Requires:       perl-Net-LDAP
Requires:       perl-Unicode-String
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
# Fedora/opensuse integration
%if 0%{?suse_version}
Patch10:        %{name}-0.9.9-suse-config.patch
%else
Patch10:        %{name}-0.9.9-fedora-config.patch
%endif
%if 0%{?suse_version} < 1140
Requires:       perl = %{perl_version}
%else
%{perl_requires}
%endif

%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 and get/change
  personnal informations

%package migration
Summary:        Migration relatet tools provided by smbldap-tools
Group:          Productivity/Networking/Samba
Requires:       smbldap-tools = %{version}

%description migration
The migration tools are a part of the smbldap-tools used to migrate local
unix and smb accounts to samba.

%package doc
Summary:        Documentation package to smbldap-tools
Group:          Productivity/Networking/Samba
Requires:       smbldap-tools = %{version}

%description doc
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.

%prep
%setup -q
%if 0%{?suse_version}
%patch10 -p1
%patch11 -p1
%patch12 -p1
%else
%patch10
%endif
rm %{name}.spec

%build
# Figure out where ssl stuff goes
%if 0%{?suse_version}
%define cadir %{_sysconfdir}/ssl
%define cafile ca-bundle.pem
%else
%define cadir %{_sysconfdir}/pki/tls/certs
%define cafile ca-bundle.crt
%endif

%define use_pki %(if [ -f %{cadir}/%{cafile} ]; then echo 1; else echo 0; fi)
%configure
make %{?_smp_mflags}
%if ! %{use_pki}
	perl -pi -e 's|%{cadir}|%{_datadir}/ssl/certs/|g;' smbldap.conf
%endif

# create manpages for migration scripts
for F in smbldap-migrate-pwdump-accounts smbldap-migrate-unix-accounts smbldap-migrate-unix-groups ; do
        pod2man "doc/migration_scripts/$F" > "doc/migration_scripts/$F.8"
done

%install
make %{?_smp_mflags} DESTDIR=%{buildroot} install
install -d -m 755 %{buildroot}%{_mandir}/man8/
install -p -m 644 smbldap-*.8 %{buildroot}%{_mandir}/man8/
install -d -m 755 %{buildroot}%{_sysconfdir}/smbldap-tools/
install -p -m 644 smbldap.conf %{buildroot}%{_sysconfdir}/smbldap-tools/smbldap.conf
install -p -m 600 smbldap_bind.conf %{buildroot}%{_sysconfdir}/smbldap-tools/smbldap_bind.conf

# Install migration script for pre-0.9.7 users
sed -e 's|@PERL_COMMAND@|%{_bindir}/perl|' smbldap-upgrade-0.9.6.pl > \
	%{buildroot}%{_sbindir}/smbldap-upgrade-0.9.6.pl
chmod 755 %{buildroot}%{_sbindir}/smbldap-upgrade-0.9.6.pl

# install migration scripts and manpages
for F in doc/migration_scripts/*[^8] ; do
        install -p -m 750 "$F" %{buildroot}%{_sbindir}/
done
for F in smbldap-migrate-pwdump-accounts smbldap-migrate-unix-accounts smbldap-migrate-unix-groups ; do
	install -p -m 644 "doc/migration_scripts/$F.8" %{buildroot}%{_mandir}/man8/
done

%post
if [ -f %{_libexecdir}/perl5/site_perl/smbldap_tools.pm ] ; then
	rm -f %{_libexecdir}/perl5/site_perl/smbldap_tools.pm
fi
if [ -f %{_libexecdir}/perl5/site_perl/smbldap_conf.pm ] ; then
	rm -f %{_libexecdir}/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,0750)
%{_sbindir}/smbldap-config
%{_sbindir}/smbldap-groupadd
%{_sbindir}/smbldap-groupdel
%{_sbindir}/smbldap-grouplist
%{_sbindir}/smbldap-groupmod
%{_sbindir}/smbldap-groupshow
%{_sbindir}/smbldap-passwd
%{_sbindir}/smbldap-populate
%{_sbindir}/smbldap-upgrade-0.9.6.pl
%{_sbindir}/smbldap-useradd
%{_sbindir}/smbldap-userdel
%{_sbindir}/smbldap-userinfo
%{_sbindir}/smbldap-userlist
%{_sbindir}/smbldap-usermod
%{_sbindir}/smbldap-usershow
%defattr(644,root,root,0750)
%doc CONTRIBUTORS COPYING ChangeLog FILES INFRA README INSTALL TODO
%{_mandir}/man8/smbldap-[^m]*
%{perl_vendorlib}/smbldap*
%defattr(600,root,root,0750)
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/smbldap.conf
%config(noreplace) %{_sysconfdir}/%{name}/smbldap_bind.conf

%files migration
%defattr(750,root,root,0750)
%{_sbindir}/smbldap-migrate*
%defattr(644,root,root,0755)
%{_mandir}/man8/smbldap-migrate*

%files doc
%defattr(644,root,root,0755)
%doc doc/*.html
%doc doc/*.pdf

%changelog
openSUSE Build Service is sponsored by