4969b8
4969b8
%global pkgname   dirsrv
4969b8
%global srcname   389-ds-base
4969b8
4969b8
# Exclude i686 bit arches
4969b8
ExcludeArch: i686 
4969b8
4969b8
# If perl-Socket-2.000 or newer is available, set 0 to use_Socket6.
4969b8
%global use_Socket6 0
4969b8
4969b8
%global use_asan 0
4969b8
%global use_rust 1
4969b8
%global bundle_jemalloc 1
4969b8
%if %{use_asan}
4969b8
%global bundle_jemalloc 0
4969b8
%endif
4969b8
4969b8
%if %{bundle_jemalloc}
4969b8
%global jemalloc_name jemalloc
854bad
%global jemalloc_ver 5.3.0
4969b8
%global __provides_exclude ^libjemalloc\\.so.*$
4969b8
%endif
4969b8
4969b8
# Use Clang instead of GCC
4969b8
%global use_clang 0
4969b8
4969b8
# Build cockpit plugin
4969b8
%global use_cockpit 0
4969b8
4969b8
# fedora 15 and later uses tmpfiles.d
4969b8
# otherwise, comment this out
4969b8
%{!?with_tmpfiles_d: %global with_tmpfiles_d %{_sysconfdir}/tmpfiles.d}
4969b8
4969b8
# systemd support
4969b8
%global groupname %{pkgname}.target
4969b8
4969b8
# set PIE flag
4969b8
%global _hardened_build 1
4969b8
4969b8
# Filter argparse-manpage from autogenerated package Requires
4969b8
%global __requires_exclude ^python.*argparse-manpage
4969b8
4969b8
# Force to require nss version greater or equal as the version available at the build time
4969b8
# See bz1986327
4969b8
%define dirsrv_requires_ge()  %(LC_ALL="C" echo '%*' | xargs -r rpm -q --qf 'Requires: %%{name} >= %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
4969b8
4969b8
Summary:          389 Directory Server (base)
4969b8
Name:             389-ds-base
854bad
Version:          2.1.3
854bad
Release:          4%{?dist}
854bad
License:          GPLv3+ and (ASL 2.0 or MIT)
4969b8
URL:              https://www.port389.org
4969b8
Conflicts:        selinux-policy-base < 3.9.8
4969b8
Conflicts:        freeipa-server < 4.0.3
4969b8
Obsoletes:        %{name} <= 1.4.0.9
4969b8
Obsoletes:        %{name}-legacy-tools < 1.4.4.6
4969b8
Obsoletes:        %{name}-legacy-tools-debuginfo < 1.4.4.6
4969b8
Provides:         ldif2ldbm >= 0
4969b8
4969b8
##### Bundled cargo crates list - START #####
4969b8
Provides:  bundled(crate(ahash)) = 0.7.6
4969b8
Provides:  bundled(crate(ansi_term)) = 0.12.1
4969b8
Provides:  bundled(crate(atty)) = 0.2.14
854bad
Provides:  bundled(crate(autocfg)) = 1.1.0
4969b8
Provides:  bundled(crate(base64)) = 0.13.0
4969b8
Provides:  bundled(crate(bitflags)) = 1.3.2
4969b8
Provides:  bundled(crate(byteorder)) = 1.4.3
4969b8
Provides:  bundled(crate(cbindgen)) = 0.9.1
854bad
Provides:  bundled(crate(cc)) = 1.0.73
4969b8
Provides:  bundled(crate(cfg-if)) = 1.0.0
4969b8
Provides:  bundled(crate(clap)) = 2.34.0
4969b8
Provides:  bundled(crate(concread)) = 0.2.21
854bad
Provides:  bundled(crate(crossbeam)) = 0.8.2
854bad
Provides:  bundled(crate(crossbeam-channel)) = 0.5.6
854bad
Provides:  bundled(crate(crossbeam-deque)) = 0.8.2
854bad
Provides:  bundled(crate(crossbeam-epoch)) = 0.9.10
854bad
Provides:  bundled(crate(crossbeam-queue)) = 0.3.6
854bad
Provides:  bundled(crate(crossbeam-utils)) = 0.8.11
4969b8
Provides:  bundled(crate(entryuuid)) = 0.1.0
4969b8
Provides:  bundled(crate(entryuuid_syntax)) = 0.1.0
854bad
Provides:  bundled(crate(fastrand)) = 1.8.0
4969b8
Provides:  bundled(crate(fernet)) = 0.1.4
4969b8
Provides:  bundled(crate(foreign-types)) = 0.3.2
4969b8
Provides:  bundled(crate(foreign-types-shared)) = 0.1.1
854bad
Provides:  bundled(crate(getrandom)) = 0.2.7
854bad
Provides:  bundled(crate(hashbrown)) = 0.12.3
4969b8
Provides:  bundled(crate(hermit-abi)) = 0.1.19
4969b8
Provides:  bundled(crate(instant)) = 0.1.12
854bad
Provides:  bundled(crate(itoa)) = 1.0.3
4969b8
Provides:  bundled(crate(jobserver)) = 0.1.24
854bad
Provides:  bundled(crate(libc)) = 0.2.132
4969b8
Provides:  bundled(crate(librnsslapd)) = 0.1.0
4969b8
Provides:  bundled(crate(librslapd)) = 0.1.0
854bad
Provides:  bundled(crate(lock_api)) = 0.4.7
854bad
Provides:  bundled(crate(log)) = 0.4.17
854bad
Provides:  bundled(crate(lru)) = 0.7.8
4969b8
Provides:  bundled(crate(memoffset)) = 0.6.5
854bad
Provides:  bundled(crate(once_cell)) = 1.13.1
854bad
Provides:  bundled(crate(openssl)) = 0.10.41
854bad
Provides:  bundled(crate(openssl-macros)) = 0.1.0
854bad
Provides:  bundled(crate(openssl-sys)) = 0.9.75
4969b8
Provides:  bundled(crate(parking_lot)) = 0.11.2
4969b8
Provides:  bundled(crate(parking_lot_core)) = 0.8.5
4969b8
Provides:  bundled(crate(paste)) = 0.1.18
4969b8
Provides:  bundled(crate(paste-impl)) = 0.1.18
854bad
Provides:  bundled(crate(pin-project-lite)) = 0.2.9
854bad
Provides:  bundled(crate(pkg-config)) = 0.3.25
4969b8
Provides:  bundled(crate(ppv-lite86)) = 0.2.16
4969b8
Provides:  bundled(crate(proc-macro-hack)) = 0.5.19
854bad
Provides:  bundled(crate(proc-macro2)) = 1.0.43
4969b8
Provides:  bundled(crate(pwdchan)) = 0.1.0
854bad
Provides:  bundled(crate(quote)) = 1.0.21
854bad
Provides:  bundled(crate(rand)) = 0.8.5
4969b8
Provides:  bundled(crate(rand_chacha)) = 0.3.1
4969b8
Provides:  bundled(crate(rand_core)) = 0.6.3
854bad
Provides:  bundled(crate(redox_syscall)) = 0.2.16
4969b8
Provides:  bundled(crate(remove_dir_all)) = 0.5.3
854bad
Provides:  bundled(crate(ryu)) = 1.0.11
4969b8
Provides:  bundled(crate(scopeguard)) = 1.1.0
854bad
Provides:  bundled(crate(serde)) = 1.0.143
854bad
Provides:  bundled(crate(serde_derive)) = 1.0.143
854bad
Provides:  bundled(crate(serde_json)) = 1.0.83
4969b8
Provides:  bundled(crate(slapd)) = 0.1.0
4969b8
Provides:  bundled(crate(slapi_r_plugin)) = 0.1.0
854bad
Provides:  bundled(crate(smallvec)) = 1.9.0
4969b8
Provides:  bundled(crate(strsim)) = 0.8.0
854bad
Provides:  bundled(crate(syn)) = 1.0.99
4969b8
Provides:  bundled(crate(synstructure)) = 0.12.6
4969b8
Provides:  bundled(crate(tempfile)) = 3.3.0
4969b8
Provides:  bundled(crate(textwrap)) = 0.11.0
854bad
Provides:  bundled(crate(tokio)) = 1.20.1
854bad
Provides:  bundled(crate(tokio-macros)) = 1.8.0
854bad
Provides:  bundled(crate(toml)) = 0.5.9
854bad
Provides:  bundled(crate(unicode-ident)) = 1.0.3
4969b8
Provides:  bundled(crate(unicode-width)) = 0.1.9
854bad
Provides:  bundled(crate(unicode-xid)) = 0.2.3
4969b8
Provides:  bundled(crate(uuid)) = 0.8.2
4969b8
Provides:  bundled(crate(vcpkg)) = 0.2.15
4969b8
Provides:  bundled(crate(vec_map)) = 0.8.2
4969b8
Provides:  bundled(crate(version_check)) = 0.9.4
854bad
Provides:  bundled(crate(wasi)) = 0.11.0+wasi_snapshot_preview1
4969b8
Provides:  bundled(crate(winapi)) = 0.3.9
4969b8
Provides:  bundled(crate(winapi-i686-pc-windows-gnu)) = 0.4.0
4969b8
Provides:  bundled(crate(winapi-x86_64-pc-windows-gnu)) = 0.4.0
854bad
Provides:  bundled(crate(zeroize)) = 1.5.7
854bad
Provides:  bundled(crate(zeroize_derive)) = 1.3.2
4969b8
##### Bundled cargo crates list - END #####
4969b8
854bad
BuildRequires:    nspr-devel >= 4.32
854bad
BuildRequires:    nss-devel >= 3.67.0-7
854bad
4969b8
BuildRequires:    openldap-devel
854bad
BuildRequires:    lmdb-devel
4969b8
BuildRequires:    libdb-devel
4969b8
BuildRequires:    cyrus-sasl-devel
4969b8
BuildRequires:    icu
4969b8
BuildRequires:    libicu-devel
4969b8
BuildRequires:    pcre-devel
4969b8
BuildRequires:    cracklib-devel
4969b8
%if %{use_clang}
4969b8
BuildRequires:    libatomic
4969b8
BuildRequires:    clang
4969b8
%else
4969b8
BuildRequires:    gcc
4969b8
BuildRequires:    gcc-c++
4969b8
%endif
4969b8
# The following are needed to build the snmp ldap-agent
4969b8
BuildRequires:    net-snmp-devel
4969b8
BuildRequires:    lm_sensors-devel
4969b8
BuildRequires:    bzip2-devel
4969b8
BuildRequires:    zlib-devel
4969b8
BuildRequires:    openssl-devel
4969b8
# the following is for the pam passthru auth plug-in
4969b8
BuildRequires:    pam-devel
4969b8
BuildRequires:    systemd-units
4969b8
BuildRequires:    systemd-devel
4969b8
%if %{use_asan}
4969b8
BuildRequires:    libasan
4969b8
%endif
4969b8
# If rust is enabled
4969b8
%if %{use_rust}
4969b8
BuildRequires: cargo
4969b8
BuildRequires: rust
4969b8
%endif
4969b8
BuildRequires:    pkgconfig
4969b8
BuildRequires:    pkgconfig(systemd)
4969b8
BuildRequires:    pkgconfig(krb5)
4969b8
4969b8
# Needed to support regeneration of the autotool artifacts.
4969b8
BuildRequires:    autoconf
4969b8
BuildRequires:    automake
4969b8
BuildRequires:    libtool
4969b8
# For our documentation
4969b8
BuildRequires:    doxygen
4969b8
# For tests!
4969b8
BuildRequires:    libcmocka-devel
4969b8
BuildRequires:    libevent-devel
4969b8
# For lib389 and related components
4969b8
BuildRequires:    python%{python3_pkgversion}-devel
4969b8
BuildRequires:    python%{python3_pkgversion}-setuptools
4969b8
BuildRequires:    python%{python3_pkgversion}-ldap
4969b8
BuildRequires:    python%{python3_pkgversion}-six
4969b8
BuildRequires:    python%{python3_pkgversion}-pyasn1
4969b8
BuildRequires:    python%{python3_pkgversion}-pyasn1-modules
4969b8
BuildRequires:    python%{python3_pkgversion}-dateutil
4969b8
BuildRequires:    python%{python3_pkgversion}-argcomplete
4969b8
BuildRequires:    python%{python3_pkgversion}-argparse-manpage
4969b8
BuildRequires:    python%{python3_pkgversion}-libselinux
4969b8
BuildRequires:    python%{python3_pkgversion}-policycoreutils
4969b8
4969b8
# For cockpit
4969b8
%if %{use_cockpit}
4969b8
BuildRequires:    rsync
4969b8
%endif
4969b8
4969b8
Requires:         %{name}-libs = %{version}-%{release}
4969b8
Requires:         python%{python3_pkgversion}-lib389 = %{version}-%{release}
854bad
Requires:         lmdb-libs
4969b8
4969b8
# this is needed for using semanage from our setup scripts
4969b8
Requires:         policycoreutils-python-utils
4969b8
Requires:         /usr/sbin/semanage
4969b8
Requires:         libsemanage-python%{python3_pkgversion}
4969b8
Requires:         selinux-policy >= 3.14.1-29
4969b8
4969b8
# the following are needed for some of our scripts
4969b8
Requires:         openldap-clients
4969b8
Requires:         /usr/bin/c_rehash
4969b8
Requires:         python%{python3_pkgversion}-ldap
854bad
Requires:         acl
4969b8
4969b8
# this is needed to setup SSL if you are not using the
4969b8
# administration server package
854bad
Requires:         nspr >= 4.32
854bad
Requires:         nss >= 3.67.0-7
4969b8
Requires:         nss-tools
4969b8
%dirsrv_requires_ge nss
4969b8
4969b8
# these are not found by the auto-dependency method
4969b8
# they are required to support the mandatory LDAP SASL mechs
4969b8
Requires:         cyrus-sasl-gssapi
4969b8
Requires:         cyrus-sasl-md5
4969b8
Requires:         cyrus-sasl-plain
4969b8
4969b8
# this is needed for verify-db.pl
4969b8
Requires:         libdb-utils
4969b8
4969b8
# Needed for password dictionary checks
4969b8
Requires:         cracklib-dicts
4969b8
4969b8
# Needed by logconv.pl
4969b8
Requires:         perl-DB_File
4969b8
Requires:         perl-Archive-Tar
4969b8
Requires:         perl-debugger
4969b8
Requires:         perl-sigtrap
4969b8
4969b8
# Picks up our systemd deps.
4969b8
%{?systemd_requires}
4969b8
4969b8
Obsoletes:        %{name} <= 1.3.5.4
4969b8
4969b8
Source0:          https://releases.pagure.org/389-ds-base/%{name}-%{version}.tar.bz2
4969b8
# 389-ds-git.sh should be used to generate the source tarball from git
4969b8
Source1:          %{name}-git.sh
4969b8
Source2:          %{name}-devel.README
4969b8
%if %{bundle_jemalloc}
4969b8
Source3:          https://github.com/jemalloc/%{jemalloc_name}/releases/download/%{jemalloc_ver}/%{jemalloc_name}-%{jemalloc_ver}.tar.bz2
4969b8
%endif
854bad
Patch01:          0001-Issue-5254-dscreate-create-template-regression-due-t.patch
4969b8
4969b8
%description
4969b8
389 Directory Server is an LDAPv3 compliant server.  The base package includes
4969b8
the LDAP server and command line utilities for server administration.
4969b8
%if %{use_asan}
4969b8
WARNING! This build is linked to Address Sanitisation libraries. This probably
4969b8
isn't what you want. Please contact support immediately.
4969b8
Please see http://seclists.org/oss-sec/2016/q1/363 for more information.
4969b8
%endif
4969b8
4969b8
%package          libs
4969b8
Summary:          Core libraries for 389 Directory Server
854bad
BuildRequires:    nspr >= 4.32
854bad
BuildRequires:    nss >= 3.67.0-7
4969b8
BuildRequires:    openldap-devel
4969b8
BuildRequires:    libdb-devel
4969b8
BuildRequires:    cyrus-sasl-devel
4969b8
BuildRequires:    libicu-devel
4969b8
BuildRequires:    pcre-devel
4969b8
BuildRequires:    libtalloc-devel
4969b8
BuildRequires:    libevent-devel
4969b8
BuildRequires:    libtevent-devel
4969b8
Requires:         krb5-libs
4969b8
Requires:         libevent
4969b8
BuildRequires:    systemd-devel
4969b8
BuildRequires:    make
4969b8
Provides:         svrcore = 4.1.4
4969b8
Conflicts:        svrcore
4969b8
Obsoletes:        svrcore <= 4.1.3
4969b8
4969b8
%description      libs
4969b8
Core libraries for the 389 Directory Server base package.  These libraries
4969b8
are used by the main package and the -devel package.  This allows the -devel
4969b8
package to be installed with just the -libs package and without the main package.
4969b8
4969b8
%package          devel
4969b8
Summary:          Development libraries for 389 Directory Server
4969b8
Requires:         %{name}-libs = %{version}-%{release}
4969b8
Requires:         pkgconfig
4969b8
Requires:         nspr-devel
4969b8
Requires:         nss-devel >= 3.34
4969b8
Requires:         openldap-devel
4969b8
Requires:         libtalloc
4969b8
Requires:         libevent
4969b8
Requires:         libtevent
4969b8
Requires:         systemd-libs
4969b8
Provides:         svrcore-devel = 4.1.4
4969b8
Conflicts:        svrcore-devel
4969b8
Obsoletes:        svrcore-devel <= 4.1.3
4969b8
4969b8
%description      devel
4969b8
Development Libraries and headers for the 389 Directory Server base package.
4969b8
4969b8
%package          snmp
4969b8
Summary:          SNMP Agent for 389 Directory Server
4969b8
Requires:         %{name} = %{version}-%{release}
4969b8
4969b8
Obsoletes:        %{name} <= 1.4.0.0
4969b8
4969b8
%description      snmp
4969b8
SNMP Agent for the 389 Directory Server base package.
4969b8
4969b8
%package -n python%{python3_pkgversion}-lib389
4969b8
Summary:  A library for accessing, testing, and configuring the 389 Directory Server
4969b8
BuildArch:        noarch
4969b8
Requires: openssl
4969b8
Requires: iproute
854bad
Requires: 389-ds-base
4969b8
Recommends: bash-completion
4969b8
Requires: python%{python3_pkgversion}
4969b8
Requires: python%{python3_pkgversion}-distro
4969b8
Requires: python%{python3_pkgversion}-ldap
4969b8
Requires: python%{python3_pkgversion}-six
4969b8
Requires: python%{python3_pkgversion}-pyasn1
4969b8
Requires: python%{python3_pkgversion}-pyasn1-modules
4969b8
Requires: python%{python3_pkgversion}-dateutil
4969b8
Requires: python%{python3_pkgversion}-argcomplete
4969b8
Requires: python%{python3_pkgversion}-libselinux
4969b8
Requires: python%{python3_pkgversion}-setuptools
4969b8
%{?python_provide:%python_provide python%{python3_pkgversion}-lib389}
4969b8
4969b8
%description -n python%{python3_pkgversion}-lib389
4969b8
This module contains tools and libraries for accessing, testing,
4969b8
 and configuring the 389 Directory Server.
4969b8
4969b8
%if %{use_cockpit}
4969b8
%package -n cockpit-389-ds
4969b8
Summary:          Cockpit UI Plugin for configuring and administering the 389 Directory Server
4969b8
BuildArch:        noarch
4969b8
Requires:         cockpit
4969b8
Requires:         389-ds-base
4969b8
Requires:         python%{python3_pkgversion}
4969b8
Requires:         python%{python3_pkgversion}-lib389
4969b8
4969b8
%description -n cockpit-389-ds
4969b8
A cockpit UI Plugin for configuring and administering the 389 Directory Server
4969b8
%endif
4969b8
4969b8
%prep
4969b8
4969b8
%autosetup -p1 -v -n %{name}-%{version}
4969b8
%if %{bundle_jemalloc}
4969b8
%setup -q -n %{name}-%{version} -T -D -b 3
4969b8
%endif
4969b8
4969b8
cp %{SOURCE2} README.devel
4969b8
4969b8
# The configure macro will modify some autoconf-related files, which upsets
4969b8
# cargo when it tries to verify checksums in those files.  If we just truncate
4969b8
# that file list, cargo won't have anything to complain about.
4969b8
find vendor -name .cargo-checksum.json \
4969b8
  -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
4969b8
4969b8
%build
4969b8
4969b8
OPENLDAP_FLAG="--with-openldap"
4969b8
%{?with_tmpfiles_d: TMPFILES_FLAG="--with-tmpfiles-d=%{with_tmpfiles_d}"}
4969b8
# hack hack hack https://bugzilla.redhat.com/show_bug.cgi?id=833529
4969b8
NSSARGS="--with-nss-lib=%{_libdir} --with-nss-inc=%{_includedir}/nss3"
4969b8
4969b8
%if %{use_asan}
4969b8
ASAN_FLAGS="--enable-asan --enable-debug"
4969b8
%endif
4969b8
4969b8
%if %{use_rust}
4969b8
RUST_FLAGS="--enable-rust --enable-rust-offline"
4969b8
%endif
4969b8
4969b8
%if !%{use_cockpit}
4969b8
COCKPIT_FLAGS="--disable-cockpit"
4969b8
%endif 
4969b8
4969b8
%if %{use_clang}
4969b8
export CC=clang
4969b8
export CXX=clang++
4969b8
CLANG_FLAGS="--enable-clang"
4969b8
%endif
4969b8
4969b8
%if %{bundle_jemalloc}
4969b8
# Override page size, bz #1545539
4969b8
# 4K
4969b8
%ifarch %ix86 %arm x86_64 s390x
4969b8
%define lg_page --with-lg-page=12
4969b8
%endif
4969b8
4969b8
# 64K
4969b8
%ifarch ppc64 ppc64le aarch64
4969b8
%define lg_page --with-lg-page=16
4969b8
%endif
4969b8
4969b8
# Override huge page size on aarch64
4969b8
# 2M instead of 512M
4969b8
%ifarch aarch64
4969b8
%define lg_hugepage --with-lg-hugepage=21
4969b8
%endif
4969b8
4969b8
# Build jemalloc
4969b8
pushd ../%{jemalloc_name}-%{jemalloc_ver}
4969b8
%configure \
4969b8
        --libdir=%{_libdir}/%{pkgname}/lib \
4969b8
        --bindir=%{_libdir}/%{pkgname}/bin \
4969b8
        --enable-prof
4969b8
make %{?_smp_mflags}
4969b8
popd
4969b8
%endif
4969b8
4969b8
# Enforce strict linking
4969b8
%define _ld_strict_symbol_defs 1
4969b8
4969b8
# Rebuild the autotool artifacts now.
4969b8
autoreconf -fiv
4969b8
4969b8
%configure --enable-autobind --with-selinux $TMPFILES_FLAG \
4969b8
           --with-systemd \
4969b8
           --with-systemdsystemunitdir=%{_unitdir} \
4969b8
           --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \
4969b8
           --with-systemdgroupname=%{groupname}  \
4969b8
           --libexecdir=%{_libexecdir}/%{pkgname} \
4969b8
           $NSSARGS $ASAN_FLAGS $RUST_FLAGS $CLANG_FLAGS $COCKPIT_FLAGS \
854bad
           --enable-cmocka --enable-new-dtags --with-libldap-r=no
4969b8
4969b8
4969b8
# lib389
4969b8
pushd ./src/lib389
4969b8
%py3_build
4969b8
popd
4969b8
# argparse-manpage dynamic man pages have hardcoded man v1 in header,
4969b8
# need to change it to v8
4969b8
sed -i  "1s/\"1\"/\"8\"/" %{_builddir}/%{name}-%{version}/src/lib389/man/dsconf.8
4969b8
sed -i  "1s/\"1\"/\"8\"/" %{_builddir}/%{name}-%{version}/src/lib389/man/dsctl.8
4969b8
sed -i  "1s/\"1\"/\"8\"/" %{_builddir}/%{name}-%{version}/src/lib389/man/dsidm.8
4969b8
sed -i  "1s/\"1\"/\"8\"/" %{_builddir}/%{name}-%{version}/src/lib389/man/dscreate.8
4969b8
4969b8
# Generate symbolic info for debuggers
4969b8
export XCFLAGS=$RPM_OPT_FLAGS
4969b8
4969b8
#make %{?_smp_mflags}
4969b8
make
4969b8
4969b8
%install
4969b8
4969b8
mkdir -p %{buildroot}%{_datadir}/gdb/auto-load%{_sbindir}
4969b8
%if %{use_cockpit}
4969b8
mkdir -p %{buildroot}%{_datadir}/cockpit
4969b8
%endif
4969b8
make DESTDIR="$RPM_BUILD_ROOT" install
4969b8
4969b8
%if %{use_cockpit}
4969b8
find %{buildroot}%{_datadir}/cockpit/389-console -type d | sed -e "s@%{buildroot}@@" | sed -e 's/^/\%dir /' > cockpit.list
4969b8
find %{buildroot}%{_datadir}/cockpit/389-console -type f | sed -e "s@%{buildroot}@@" >> cockpit.list
4969b8
%endif
4969b8
4969b8
# Copy in our docs from doxygen.
4969b8
cp -r %{_builddir}/%{name}-%{version}/man/man3 $RPM_BUILD_ROOT/%{_mandir}/man3
4969b8
4969b8
# lib389
4969b8
pushd src/lib389
4969b8
%py3_install
4969b8
popd
4969b8
4969b8
mkdir -p $RPM_BUILD_ROOT/var/log/%{pkgname}
4969b8
mkdir -p $RPM_BUILD_ROOT/var/lib/%{pkgname}
4969b8
mkdir -p $RPM_BUILD_ROOT/var/lock/%{pkgname}
4969b8
4969b8
# for systemd
4969b8
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/systemd/system/%{groupname}.wants
4969b8
4969b8
# remove libtool archives and static libs
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/*.a
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/*.la
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.a
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.la
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/libsvrcore.a
4969b8
rm -f $RPM_BUILD_ROOT%{_libdir}/libsvrcore.la
4969b8
4969b8
%if %{bundle_jemalloc}
4969b8
pushd ../%{jemalloc_name}-%{jemalloc_ver}
4969b8
make DESTDIR="$RPM_BUILD_ROOT" install_lib install_bin
4969b8
cp -pa COPYING ../%{name}-%{version}/COPYING.jemalloc
4969b8
cp -pa README ../%{name}-%{version}/README.jemalloc
4969b8
popd
4969b8
%endif
4969b8
4969b8
%check
4969b8
# This checks the code, if it fails it prints why, then re-raises the fail to shortcircuit the rpm build.
4969b8
if ! make DESTDIR="$RPM_BUILD_ROOT" check; then cat ./test-suite.log && false; fi
4969b8
4969b8
%post
4969b8
if [ -n "$DEBUGPOSTTRANS" ] ; then
4969b8
    output=$DEBUGPOSTTRANS
4969b8
    output2=${DEBUGPOSTTRANS}.upgrade
4969b8
else
4969b8
    output=/dev/null
4969b8
    output2=/dev/null
4969b8
fi
4969b8
# reload to pick up any changes to systemd files
4969b8
/bin/systemctl daemon-reload >$output 2>&1 || :
4969b8
4969b8
# https://fedoraproject.org/wiki/Packaging:UsersAndGroups#Soft_static_allocation
4969b8
# Soft static allocation for UID and GID
4969b8
USERNAME="dirsrv"
4969b8
ALLOCATED_UID=389
4969b8
GROUPNAME="dirsrv"
4969b8
ALLOCATED_GID=389
4969b8
HOMEDIR="/usr/share/dirsrv"
4969b8
4969b8
getent group $GROUPNAME >/dev/null || /usr/sbin/groupadd -f -g $ALLOCATED_GID -r $GROUPNAME
4969b8
if ! getent passwd $USERNAME >/dev/null ; then
4969b8
    if ! getent passwd $ALLOCATED_UID >/dev/null ; then
4969b8
      /usr/sbin/useradd -r -u $ALLOCATED_UID -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin -c "user for 389-ds-base" $USERNAME
4969b8
    else
4969b8
      /usr/sbin/useradd -r -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin -c "user for 389-ds-base" $USERNAME
4969b8
    fi
4969b8
fi
4969b8
4969b8
# Reload our sysctl before we restart (if we can)
4969b8
sysctl --system &> $output; true
4969b8
4969b8
# Gather the running instances so we can restart them
4969b8
instbase="%{_sysconfdir}/%{pkgname}"
4969b8
ninst=0
4969b8
for dir in $instbase/slapd-* ; do
4969b8
    echo dir = $dir >> $output 2>&1 || :
4969b8
    if [ ! -d "$dir" ] ; then continue ; fi
4969b8
    case "$dir" in *.removed) continue ;; esac
4969b8
    basename=`basename $dir`
4969b8
    inst="%{pkgname}@`echo $basename | sed -e 's/slapd-//g'`"
4969b8
    echo found instance $inst - getting status  >> $output 2>&1 || :
4969b8
    if /bin/systemctl -q is-active $inst ; then
4969b8
       echo instance $inst is running >> $output 2>&1 || :
4969b8
       instances="$instances $inst"
4969b8
    else
4969b8
       echo instance $inst is not running >> $output 2>&1 || :
4969b8
    fi
4969b8
    ninst=`expr $ninst + 1`
4969b8
done
4969b8
if [ $ninst -eq 0 ] ; then
4969b8
    echo no instances to upgrade >> $output 2>&1 || :
4969b8
    exit 0 # have no instances to upgrade - just skip the rest
4969b8
else
4969b8
    # restart running instances
4969b8
    echo shutting down all instances . . . >> $output 2>&1 || :
4969b8
    for inst in $instances ; do
4969b8
        echo stopping instance $inst >> $output 2>&1 || :
4969b8
        /bin/systemctl stop $inst >> $output 2>&1 || :
4969b8
    done
4969b8
    for inst in $instances ; do
4969b8
        echo starting instance $inst >> $output 2>&1 || :
4969b8
        /bin/systemctl start $inst >> $output 2>&1 || :
4969b8
    done
4969b8
fi
4969b8
4969b8
4969b8
%preun
4969b8
if [ $1 -eq 0 ]; then # Final removal
4969b8
    # remove instance specific service files/links
4969b8
    rm -rf %{_sysconfdir}/systemd/system/%{groupname}.wants/* > /dev/null 2>&1 || :
4969b8
fi
4969b8
4969b8
%postun
4969b8
if [ $1 = 0 ]; then # Final removal
4969b8
    rm -rf /var/run/%{pkgname}
4969b8
fi
4969b8
4969b8
%post snmp
4969b8
%systemd_post %{pkgname}-snmp.service
4969b8
4969b8
%preun snmp
4969b8
%systemd_preun %{pkgname}-snmp.service %{groupname}
4969b8
4969b8
%postun snmp
4969b8
%systemd_postun_with_restart %{pkgname}-snmp.service
4969b8
4969b8
exit 0
4969b8
4969b8
%files
4969b8
%if %{bundle_jemalloc}
4969b8
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.jemalloc
4969b8
%license COPYING.jemalloc
4969b8
%else
4969b8
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl
4969b8
%endif
4969b8
%dir %{_sysconfdir}/%{pkgname}
4969b8
%dir %{_sysconfdir}/%{pkgname}/schema
4969b8
%config(noreplace)%{_sysconfdir}/%{pkgname}/schema/*.ldif
4969b8
%dir %{_sysconfdir}/%{pkgname}/config
4969b8
%dir %{_sysconfdir}/systemd/system/%{groupname}.wants
4969b8
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/slapd-collations.conf
4969b8
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/certmap.conf
4969b8
%{_datadir}/%{pkgname}
4969b8
%{_datadir}/gdb/auto-load/*
4969b8
%{_unitdir}
4969b8
%{_bindir}/dbscan
4969b8
%{_mandir}/man1/dbscan.1.gz
4969b8
%{_bindir}/ds-replcheck
4969b8
%{_mandir}/man1/ds-replcheck.1.gz
4969b8
%{_bindir}/ds-logpipe.py
4969b8
%{_mandir}/man1/ds-logpipe.py.1.gz
4969b8
%{_bindir}/ldclt
4969b8
%{_mandir}/man1/ldclt.1.gz
4969b8
%{_bindir}/logconv.pl
4969b8
%{_mandir}/man1/logconv.pl.1.gz
4969b8
%{_bindir}/pwdhash
4969b8
%{_mandir}/man1/pwdhash.1.gz
4969b8
#%caps(CAP_NET_BIND_SERVICE=pe) {_sbindir}/ns-slapd
4969b8
%{_sbindir}/ns-slapd
4969b8
%{_mandir}/man8/ns-slapd.8.gz
4969b8
%{_sbindir}/openldap_to_ds
4969b8
%{_mandir}/man8/openldap_to_ds.8.gz
4969b8
%{_libexecdir}/%{pkgname}/ds_systemd_ask_password_acl
4969b8
%{_libexecdir}/%{pkgname}/ds_selinux_restorecon.sh
4969b8
%{_mandir}/man5/99user.ldif.5.gz
4969b8
%{_mandir}/man5/certmap.conf.5.gz
4969b8
%{_mandir}/man5/slapd-collations.conf.5.gz
4969b8
%{_mandir}/man5/dirsrv.5.gz
4969b8
%{_mandir}/man5/dirsrv.systemd.5.gz
4969b8
%{_libdir}/%{pkgname}/python
4969b8
%dir %{_libdir}/%{pkgname}/plugins
4969b8
%{_libdir}/%{pkgname}/plugins/*.so
4969b8
# This has to be hardcoded to /lib - $libdir changes between lib/lib64, but
4969b8
# sysctl.d is always in /lib.
4969b8
%{_prefix}/lib/sysctl.d/*
4969b8
%dir %{_localstatedir}/lib/%{pkgname}
4969b8
%dir %{_localstatedir}/log/%{pkgname}
4969b8
%ghost %dir %{_localstatedir}/lock/%{pkgname}
4969b8
%exclude %{_sbindir}/ldap-agent*
4969b8
%exclude %{_mandir}/man1/ldap-agent.1.gz
4969b8
%exclude %{_unitdir}/%{pkgname}-snmp.service
4969b8
%if %{bundle_jemalloc}
4969b8
%{_libdir}/%{pkgname}/lib/
4969b8
%{_libdir}/%{pkgname}/bin/
4969b8
%exclude %{_libdir}/%{pkgname}/bin/jemalloc-config
4969b8
%exclude %{_libdir}/%{pkgname}/bin/jemalloc.sh
4969b8
%exclude %{_libdir}/%{pkgname}/lib/libjemalloc.a
4969b8
%exclude %{_libdir}/%{pkgname}/lib/libjemalloc.so
4969b8
%exclude %{_libdir}/%{pkgname}/lib/libjemalloc_pic.a
4969b8
%exclude %{_libdir}/%{pkgname}/lib/pkgconfig
4969b8
%endif
4969b8
4969b8
%files devel
4969b8
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel
4969b8
%{_mandir}/man3/*
4969b8
%{_includedir}/svrcore.h
4969b8
%{_includedir}/%{pkgname}
4969b8
%{_libdir}/libsvrcore.so
4969b8
%{_libdir}/%{pkgname}/libslapd.so
4969b8
%{_libdir}/%{pkgname}/libns-dshttpd.so
4969b8
%{_libdir}/%{pkgname}/libldaputil.so
4969b8
%{_libdir}/pkgconfig/svrcore.pc
4969b8
%{_libdir}/pkgconfig/dirsrv.pc
4969b8
4969b8
%files libs
4969b8
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel
4969b8
%dir %{_libdir}/%{pkgname}
4969b8
%{_libdir}/libsvrcore.so.*
4969b8
%{_libdir}/%{pkgname}/libslapd.so.*
4969b8
%{_libdir}/%{pkgname}/libns-dshttpd.so.*
4969b8
%{_libdir}/%{pkgname}/libldaputil.so.*
4969b8
%{_libdir}/%{pkgname}/librewriters.so*
4969b8
%if %{bundle_jemalloc}
4969b8
%{_libdir}/%{pkgname}/lib/libjemalloc.so.2
4969b8
%endif
4969b8
4969b8
%files snmp
4969b8
%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel
4969b8
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/ldap-agent.conf
4969b8
%{_sbindir}/ldap-agent*
4969b8
%{_mandir}/man1/ldap-agent.1.gz
4969b8
%{_unitdir}/%{pkgname}-snmp.service
4969b8
4969b8
%files -n python%{python3_pkgversion}-lib389
4969b8
%doc LICENSE LICENSE.GPLv3+
4969b8
%{python3_sitelib}/lib389*
4969b8
%{_sbindir}/dsconf
4969b8
%{_mandir}/man8/dsconf.8.gz
4969b8
%{_sbindir}/dscreate
4969b8
%{_mandir}/man8/dscreate.8.gz
4969b8
%{_sbindir}/dsctl
4969b8
%{_mandir}/man8/dsctl.8.gz
4969b8
%{_sbindir}/dsidm
4969b8
%{_mandir}/man8/dsidm.8.gz
4969b8
%{_libexecdir}/%{pkgname}/dscontainer
4969b8
4969b8
%if %{use_cockpit}
4969b8
%files -n cockpit-389-ds -f cockpit.list
4969b8
%{_datarootdir}/metainfo/389-console/org.port389.cockpit_console.metainfo.xml
4969b8
%doc README.md
4969b8
%endif
4969b8
4969b8
%changelog
854bad
* Thu Oct 6 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.3-4
854bad
- Bump version to 2.1.3-4
854bad
- Resolves: Bug 1872451 - Fix regression with dscreate template
854bad
854bad
* Fri Aug 19 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.3-3
854bad
- Bump version to 2.1.3-3
854bad
- Resolves: Bug 2118765
854bad
854bad
* Thu Aug 18 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.3-2
854bad
- Bump version to 2.1.3-2
854bad
- Resolves: Bug 2118765 - SIGSEGV in sync_repl
854bad
854bad
* Mon Jul 11 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.3-1
854bad
- Bump version to 2.1.3-1
854bad
- Resolves: Bug 2061801 - rebase 389-ds-base to 2.1.3
854bad
- Resolves: Bug 1872451 - RFE - run as non-root
854bad
- Resolves: Bug 2052527 - RFE - Provide an option to abort an Auto Member rebuild task
854bad
- Resolves: Bug 2057056 - Import may break the replication because changelog starting csn may not be created
854bad
- Resolves: Bug 2057063 - Add support for recursively deleting subentries
854bad
- Resolves: Bug 2062778 - sending crafted message could result in DoS
854bad
- Resolves: Bug 2064781 - expired password was still allowed to access the database
854bad
- Resolves: Bug 2100337 - dsconf backend export userroot fails ldap.DECODING_ERROR
854bad
854bad
* Mon Jun 13 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.1-3
854bad
- Bump version to 2.1.1-3
854bad
- Resolves: Bug 2061801 - Fix nss-tools requirement
854bad
854bad
* Mon Jun 13 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.1-2
854bad
- Bump version to 2.1.1-2
854bad
- Resolves: Bug 2061801 - Fix lmdb-libs requirement
854bad
854bad
* Thu May 12 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.1-1
854bad
- Bump version to 2.1.1-1
854bad
- Resolves: Bug 2061801 - rebase 389-ds-base to 2.1.1
854bad
854bad
* Tue Mar 8 2022 Mark Reynolds <mreynolds@redhat.com> - 2.1.0-1
854bad
- Bump version to 2.1.0-1
854bad
- Resolves: Bug 2061801 - rebase 389-ds-base to 2.1.0
4969b8