File samba.spec of Package samba

%define realname samba
%define realver  4.10.1
%define srcext   tar.gz

%define ctdb_ver %{realver}

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%define CUPS_BACKEND_DIR %(cups-config --serverbin)/backend/

%if 0%{?suse_version} < 1500
%define cxx11abi -D_GLIBCXX_USE_CXX11_ABI=0
%endif

# Python 3.x
%if 0%{?suse_version}
%define python3_pkg python3
%define python3 python3
%endif

# EPEL
%if 0%{?rhel} == 6
%define python3_pkg python34
%define python3     python3.4
%endif
%if 0%{?rhel} == 7
%define python3_pkg python36
%define python3     python3.6
%endif

%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)

%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif
%if ! 0%{?python3_sitearch:1}
%define python3_sitearch %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(True))')
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-3.0+ and LGPL-3.0+
Group:         Productivity/Networking/Samba
URL:           https://www.samba.org/
Summary:       A Windows AD and SMB/CIFS fileserver for UNIX

# Use systemd on systems supporting it
%if 0%{?suse_version} >= 1230 || 0%{?rhel} >= 7
BuildRequires: systemd-devel
Requires:      systemd
%endif

# Install-time parameters
%if 0%{?suse_version} >= 1320 || 0%{?rhel} >= 7
Requires:      krb5-server >= 1.15.1
%endif

# Samba libs dependencies
#
# ldb
# \ tevent
# \ \ talloc
# \ tdb

# Build-time parameters
BuildArch:     %{_build_arch}
BuildRequires: cyrus-sasl-devel
BuildRequires: %{python3_pkg}-devel
BuildRequires: pkg-config gettext
BuildRequires: zlib-devel >= 1.2.3
BuildRequires: xfsprogs-devel
BuildRequires: ncurses-devel readline-devel
BuildRequires: libgpg-error-devel
BuildRequires: gpgme-devel
BuildRequires: pam-devel
BuildRequires: libcap-devel
BuildRequires: libacl-devel
BuildRequires: libaio-devel
BuildRequires: cups-devel
BuildRequires: openssl-devel
BuildRequires: popt-devel
BuildRequires: libcephfs-devel librados-devel
BuildRequires: pkgconfig(ldb)           >= 1.5.4
BuildRequires: libpyldb-util-devel      >= 1.5.4
BuildRequires: pkgconfig(talloc)        >= 2.1.16
BuildRequires: libpytalloc-util-devel   >= 2.1.16
BuildRequires: pkgconfig(tdb)           >= 1.3.18
BuildRequires: pkgconfig(tevent)        >= 0.9.39
BuildRequires: pkgconfig(com_err)
BuildRequires: pkgconfig(jansson)
BuildRequires: %{python3_pkg}-ldb
BuildRequires: %{python3_pkg}-talloc
BuildRequires: %{python3_pkg}-tdb
BuildRequires: %{python3_pkg}-tevent
BuildRequires: %{python3_pkg}-PyYAML
BuildRequires: perl(ExtUtils::MakeMaker) perl(Parse::Yapp)
%if 0%{?suse_version}
BuildRequires: openldap2-devel
BuildRequires: libavahi-devel
BuildRequires: libxslt-tools
BuildRequires: docbook-xsl-stylesheets docbook_4
%else
BuildRequires: openldap-devel
BuildRequires: avahi-devel
BuildRequires: libxslt
BuildRequires: docbook-style-xsl
%endif
# GlusterFS support
%if 0%{?suse_version} || 0%{?rhel} >= 7
BuildRequires: pkgconfig(libarchive) >= 3.1.2
BuildRequires: pkgconfig(glusterfs-api) >= 4
%else
BuildRequires: pkgconfig(libarchive3) >= 3.1.2
%endif
# AD DC support
%if 0%{?suse_version} >= 1320 || 0%{?rhel} >= 7
BuildRequires: krb5-devel  >= 1.15.1
BuildRequires: krb5-server >= 1.15.1
BuildRequires: pkgconfig(gnutls) >= 3.4.7
%else
BuildRequires: krb5-devel >= 1.9
BuildRequires: pkgconfig(gnutls)
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       https://download.samba.org/pub/samba/stable/%{realname}-%{realver}%{?extraver}.%{srcext}
Source1000:    sub-pkgs.py
Source1001:    samba-pkgs.yaml

%description
The Samba software suite is a collection of programs that implements the Server
Message Block (commonly abbreviated as SMB) protocol for UNIX systems and
provides Active Directory services. This protocol is sometimes also referred to
as the Common Internet File System (CIFS). Samba also implements the NetBIOS
protocol in nmbd.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name}-libs = %{version}-%{release}
Requires:      libdcerpc-binding0 = %{version}-%{release}
Requires:      libdcerpc-samr0 = %{version}-%{release}
Requires:      libdcerpc-server0 = %{version}-%{release}
Requires:      libdcerpc0 = %{version}-%{release}
Requires:      libndr-krb5pac0 = %{version}-%{release}
Requires:      libndr-nbt0 = %{version}-%{release}
Requires:      libndr-standard0 = %{version}-%{release}
Requires:      libndr0 = %{version}-%{release}
Requires:      libnetapi0 = %{version}-%{release}
Requires:      libnss_winbind2 = %{version}-%{release}
Requires:      libnss_wins2 = %{version}-%{release}
Requires:      libsamba-credentials0 = %{version}-%{release}
Requires:      libsamba-errors1 = %{version}-%{release}
Requires:      libsamba-hostconfig0 = %{version}-%{release}
Requires:      libsamba-passdb0 = %{version}-%{release}
Requires:      libsamba-policy0 = %{version}-%{release}
Requires:      libsamba-util0 = %{version}-%{release}
Requires:      libsamdb0 = %{version}-%{release}
Requires:      libsmbconf0 = %{version}-%{release}
Requires:      libsmbldap2 = %{version}-%{release}
Requires:      libtevent-util0 = %{version}-%{release}
Requires:      libwbclient0 = %{version}-%{release}

%description devel
Development files for %{name}.

%package -n libsmbclient-devel
Group:         Development/Languages/C and C++
Summary:       Development files for Samba-client
Requires:      libsmbclient0 = %{version}-%{release}

%description -n libsmbclient-devel
Headers and libraries required to build software to have Samba-client capability.

%package libs
Group:         Productivity/Networking/Samba
Summary:       Samba private libraries
Provides:      samba-private-libs

%description libs
Samba private libraries

%{expand:%(%python3 %{S:1000} %{S:1001})}

%package client
Group:         Productivity/Networking/Samba
Summary:       Samba Client Utilities
Provides:      libnss_wins2 = %{version}-%{release}
Requires:      cups

%description client
The Samba software suite is a collection of programs that implements the Server
Message Block (commonly abbreviated as SMB) protocol for UNIX systems and
provides Active Directory services. This protocol is sometimes also referred to
as the Common Internet File System (CIFS). Samba also implements the NetBIOS
protocol in nmbd.

This package contains client utilities.

%package winbind
Group:         Productivity/Networking/Samba
Summary:       Samba winbind daemon and tools
Provides:      libnss_winbind2 = %{version}-%{release}
Requires:      krb5-plugin-libkrb5-winbind = %{version}-%{release}

%description winbind
The Samba software suite is a collection of programs that implements the Server
Message Block (commonly abbreviated as SMB) protocol for UNIX systems and
provides Active Directory services. This protocol is sometimes also referred to
as the Common Internet File System (CIFS). Samba also implements the NetBIOS
protocol in nmbd.

This package contains winbind daemon and tools.

%package test
Group:         Productivity/Networking/Samba
Summary:       Testing tools for Samba servers and clients

%description test
Testing tools for Samba servers and clients.

%package -n ctdb
Version:       %{ctdb_ver}
Group:         Productivity/Networking/Samba
URL:           http://ctdb.samba.org
Summary:       Clustered implementation of TDB database

%description -n ctdb
This is the release version of CTDB, a clustered implementation of TDB
database used by Samba and other projects to store temporary data.

%package -n ctdb-tests
Version:       %{ctdb_ver}
Group:         Productivity/Networking/Samba
URL:           http://ctdb.samba.org
Summary:       Test suite for clustered implementation of TDB database
Requires:      ctdb = %{ctdb_ver}-%{release}

%description -n ctdb-tests
Test suite for clustered implementation of TDB database.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%{__sed} -ri 's|rpcgen (-[chl]) |rpcgen -Y %{_bindir} \1 |' ctdb/wscript source3/modules/wscript_build
%{__sed} -ri '/#include "replace.h"/ i\#include <signal.h>' ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c
%{_bindir}/%{python3} %{S:1000} %{S:1001} > samba.spec.inc
### %{__ln_s} . default
# EPEL for CentOS 6.x has libarchive3
%if 0%{?rhel} && 0%{?rhel} < 7
%{__sed} -i '/archive\.h/ s/archive/archive3/g' \
  source3/client/clitar.c \
  source3/wscript
%endif

%build
export PATH=${PATH}:${_libexecdir}/mit/bin
export CFLAGS="%{optflags} %{?gcc_lto} -I%{_includedir}"
export CXXFLAGS="%{optflags} %{?gcc_lto} -I%{_includedir} %{?cxx11abi}"
export LDFLAGS="%{!?suse_version:-ltinfo }-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}"
export PYTHON=%{_bindir}/%{python3}
### %if 0%{?suse_version}
### export XML_CATALOG_FILES=/etc/xml/docbook-xsl-stylesheets.xml
### %endif
./configure \
 --enable-fhs \
 --prefix=%{_prefix} \
 --libexecdir=%{_libexecdir} \
 --sysconfdir=%{_sysconfdir} \
 --sharedstatedir=%{_localstatedir}/lib/samba \
 --localstatedir=%{_localstatedir} \
 --libdir=%{_libdir} \
 \
 --with-piddir=%{!?unitdir:%{_localstatedir}}/run/samba \
 --with-sockets-dir=%{!?unitdir:%{_localstatedir}}/run/samba \
 \
 --with-shared-modules=ALL \
 --with-cluster-support \
%if 0%{?suse_version} >= 1230 || 0%{?rhel} >= 7
 --with-systemd \
%endif
 --enable-ceph-reclock \
%if 0%{?suse_version} >= 1320 || 0%{?rhel} >= 7
 --with-system-mitkrb5 \
 --with-experimental-mit-ad-dc \
%endif
 \
 --disable-rpath \
 --private-extension-exception=ALL
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot}
%{__install} -d -m755 %{buildroot}%{_libdir}/krb5/plugins/libkrb5/
%{__mv} %{buildroot}%{_libdir}/samba/krb5/winbind_krb5_locator.so %{buildroot}%{_libdir}/krb5/plugins/libkrb5/
%{__install} -d -m755 %{buildroot}%{_sysconfdir}/ctdb/nodes
# Create symlink to use smbspool as cups backend
%{__install} -d -m755 %{buildroot}%{CUPS_BACKEND_DIR}
%{__ln_s} %{_bindir}/smbspool %{buildroot}%{CUPS_BACKEND_DIR}/smb
#%if "%{expand:%_vendor}" == "suse"
#%{__ln_s} %{_initrddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
#%else
#%endif

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc COPYING README.md WHATSNEW.txt
%{_bindir}/ltdbtool
%{_bindir}/ndrdump
%{_bindir}/onnode
%{_bindir}/ping_pong
%{_bindir}/samba-tool
%{_bindir}/smbstatus
%{_bindir}/smbtorture
%{_sbindir}/eventlogadm
%{_sbindir}/?mbd
%{_sbindir}/samba*
%dir %{_libdir}/samba/auth/
%dir %{_libdir}/samba/bind9/
%dir %{_libdir}/samba/gensec/
%dir %{_libdir}/samba/ldb/
%dir %{_libdir}/samba/pdb/
%dir %{_libdir}/samba/process_model/
%dir %{_libdir}/samba/service/
%dir %{_libdir}/samba/vfs/
%dir %{_libdir}/samba/
%{_libdir}/samba/auth/*.so
%{_libdir}/samba/bind9/*.so
%{_libdir}/samba/gensec/*.so
%{_libdir}/samba/ldb/*.so
%{_libdir}/samba/pdb/*.so
%{_libdir}/samba/process_model/*.so
%{_libdir}/samba/service/*.so
%{_libdir}/samba/vfs/*.so
%dir %{_datadir}/samba/setup/
%dir %{_datadir}/samba/
%{_datadir}/samba/setup/*
%doc %{_mandir}/man1/ltdbtool.1*
%doc %{_mandir}/man1/ndrdump.1*
%doc %{_mandir}/man1/onnode.1*
%doc %{_mandir}/man1/ping_pong.1*
%doc %{_mandir}/man1/smbstatus.1*
%doc %{_mandir}/man1/smbtorture.1*
%doc %{_mandir}/man8/?mbd.8*
%doc %{_mandir}/man8/samba-tool.8*
%doc %{_mandir}/man8/samba-gpupdate.8*
%doc %{_mandir}/man8/samba.8*
%doc %{_mandir}/man8/vfs_*.8*

# Development stuff
%files devel
%defattr(-,root,root)
%doc README.Coding README.contributing
%{_libdir}/pkgconfig/*.pc
%{_includedir}/*
%{_libdir}/*.so
%doc %{_mandir}/man3/*
%exclude %{_libdir}/pkgconfig/smbclient.pc
%exclude %{_includedir}/samba-4.0/libsmbclient.h
%exclude %{_libdir}/libsmbclient.so

%files  -n libsmbclient-devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/smbclient.pc
%dir %{_includedir}/samba-4.0
%{_includedir}/samba-4.0/libsmbclient.h
%{_libdir}/libsmbclient.so

# Private libraries
%files libs
%defattr(-,root,root)
%dir %{_libdir}/samba/
%{_libdir}/samba/*.so

%files client
%defattr(-,root,root)
%doc COPYING README.md WHATSNEW.txt
%dir %{_sysconfdir}/samba
%{_bindir}/*
%{_libdir}/libnss_wins.so.2
%dir %{_libexecdir}/samba/
%dir %{CUPS_BACKEND_DIR}
%{CUPS_BACKEND_DIR}/smb
%{_libexecdir}/samba/smbspool_krb5_wrapper
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/lmhosts.5*
%doc %{_mandir}/man5/smb.conf.5*
%doc %{_mandir}/man5/smbgetrc.5*
%doc %{_mandir}/man5/smbpasswd.5*
%doc %{_mandir}/man7/samba.7*
%doc %{_mandir}/man7/traffic_*.7*
%doc %{_mandir}/man8/cifsdd.8*
%doc %{_mandir}/man8/eventlogadm.8*
%doc %{_mandir}/man8/net.8*
%doc %{_mandir}/man8/pdbedit.8*
%doc %{_mandir}/man8/samba-regedit.8*
%doc %{_mandir}/man8/smbpasswd.8*
%doc %{_mandir}/man8/smbspool.8*
%doc %{_mandir}/man8/smbspool_krb5_wrapper.8*
%exclude %{_bindir}/ctdb*
%exclude %{_bindir}/*test
%exclude %{_bindir}/ltdbtool
%exclude %{_bindir}/ndrdump
%exclude %{_bindir}/ntlm_auth
%exclude %{_bindir}/onnode
%exclude %{_bindir}/pidl
%exclude %{_bindir}/ping_pong
%exclude %{_bindir}/samba-tool
%exclude %{_bindir}/smbstatus
%exclude %{_bindir}/smbtorture
%exclude %{_bindir}/wbinfo
%exclude %{_mandir}/man1/ctdb*.1*
%exclude %{_mandir}/man1/*test.1*
%exclude %{_mandir}/man1/ltdbtool.1*
%exclude %{_mandir}/man1/ndrdump.1*
%exclude %{_mandir}/man1/ntlm_auth.1*
%exclude %{_mandir}/man1/onnode.1*
%exclude %{_mandir}/man1/pidl.1*
%exclude %{_mandir}/man1/ping_pong.1*
%exclude %{_mandir}/man1/smbstatus.1*
%exclude %{_mandir}/man1/smbtorture.1*
%exclude %{_mandir}/man1/wbinfo.1*

%files winbind
%defattr(-,root,root)
%doc COPYING README.md WHATSNEW.txt
%{_bindir}/ntlm_auth
%{_bindir}/wbinfo
%{_sbindir}/winbindd
%{_libdir}/libnss_winbind.so.2
%dir %{_libdir}/samba/idmap/
%dir %{_libdir}/samba/nss_info/
%dir %{_libdir}/samba/
%{_libdir}/samba/idmap/*.so
%{_libdir}/samba/nss_info/*.so
%dir %{_libdir}/security/
%{_libdir}/security/pam_winbind.so
%doc %{_mandir}/man1/ntlm_auth.1*
%doc %{_mandir}/man1/wbinfo.1*
%doc %{_mandir}/man5/pam_winbind.conf.5*
%doc %{_mandir}/man8/idmap_*.8*
%doc %{_mandir}/man8/pam_winbind.8*
%doc %{_mandir}/man8/winbindd.8*

%files test
%defattr(-,root,root)
%{_bindir}/*test
%doc %{_mandir}/man1/*test.1*

%files -n ctdb
%defattr(-,root,root)
%doc ctdb/COPYING ctdb/README ctdb/doc/*.txt ctdb/doc/examples
%dir %{_sysconfdir}/ctdb/events/legacy
%dir %{_sysconfdir}/ctdb/events/notification
%dir %{_sysconfdir}/ctdb/events/
%dir %{_sysconfdir}/ctdb/nfs-checks.d/
%dir %{_sysconfdir}/ctdb/
%config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/*.*
%config(noreplace) %{_sysconfdir}/ctdb/*.sh
%config(noreplace) %{_sysconfdir}/ctdb/functions
%config(noreplace) %{_sysconfdir}/ctdb/nfs-linux-kernel-callout
%config(noreplace) %{_sysconfdir}/ctdb/statd-callout
%config(noreplace) /etc/sudoers.d/ctdb
%{_sysconfdir}/ctdb/events/notification/README
%{_sysconfdir}/ctdb/nfs-checks.d/README
%{_sysconfdir}/ctdb/notify.sh
%{_bindir}/ctdb*
%{_sbindir}/ctdbd*
%dir %{_datadir}/ctdb/events/legacy/
%dir %{_datadir}/ctdb/events/
%dir %{_datadir}/ctdb/
%{_datadir}/ctdb/events/legacy/*.script
%dir %{_libexecdir}/ctdb/
%{_libexecdir}/ctdb/*
%doc %{_mandir}/man1/ctdb*.1*
%doc %{_mandir}/man5/ctdb.conf.5*
%doc %{_mandir}/man5/ctdb.sysconfig.5*
%doc %{_mandir}/man5/ctdb-script.options.5*
%doc %{_mandir}/man7/ctdb*.7*

%files -n ctdb-tests
%defattr(-,root,root)
%doc ctdb/COPYING ctdb/tests/README
%{_datadir}/ctdb/tests/

%post   client -p /sbin/ldconfig
%postun client -p /sbin/ldconfig

%post   winbind -p /sbin/ldconfig
%postun winbind -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by