File puppetdb.spec of Package puppetdb

#
# spec file for package puppetdb
#
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

%global rpm_release 1.sles12
%global rpm_name %{name}-%{version}-%{rpm_release}.noarch.rpm

Name:           puppetdb
Version:        7.5.0
Release:        0
Summary:        Puppet Labs puppetdb
License:        Apache-2.0
Group:          System/Daemons
Url:            http://puppet.com
Source0:        https://yum.puppet.com/puppet7/sles/12/x86_64/%{rpm_name}
Source1:        https://github.com/puppetlabs/puppetdb/blob/%{version}/LICENSE.txt
Patch:          fix-file-location.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

BuildRequires:  cpio
BuildRequires:  config(aaa_base)
BuildRequires:  systemd-rpm-macros
# puppet own /etc/puppetlabs
BuildRequires:  rubygem(puppet) >= 7.0.0

Requires:       rubygem(puppet) >= 7.0.0
Requires:       java-1_8_0-openjdk-headless
Requires:       bash
Requires:       net-tools
PreReq:         permissions pwdutils %{fillup_prereq} shadow
%{?systemd_requires}

%description
PuppetDB is the fast, scalable, and reliable data warehouse for Puppet. It
caches data generated by Puppet, and gives you advanced features at awesome
speed with a powerful API.

%prep
%setup -c -T
rpm2cpio %{SOURCE0} | cpio -idmv
%patch -p1
cp %{SOURCE1} ./

%build

%install

install -m 755 -d %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/%{name}/conf.d/config.ini %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/%{name}/conf.d/database.ini %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/%{name}/conf.d/jetty.ini %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/%{name}/conf.d/repl.ini %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/%{name}/bootstrap.cfg %{buildroot}/etc/puppetlabs/%{name}/
install -m 644 ./etc/puppetlabs/%{name}/logback.xml %{buildroot}/etc/puppetlabs/%{name}/
install -m 644 ./etc/puppetlabs/%{name}/request-logging.xml %{buildroot}/etc/puppetlabs/%{name}/

mkdir -p %{buildroot}%{_fillupdir}
install -m 644 ./etc/sysconfig/%{name} %{buildroot}%{_fillupdir}/sysconfig.%{name}

mkdir -p %{buildroot}%{_unitdir}
install -m 644 ./usr/lib/systemd/system/%{name}.service %{buildroot}%{_unitdir}/

mkdir -p %{buildroot}%{_tmpfilesdir}
install -m 644 ./usr/lib/tmpfiles.d/%{name}.conf %{buildroot}%{_tmpfilesdir}/

mkdir -p %{buildroot}%{_bindir}
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/bin/puppetdb %{buildroot}%{_bindir}/

install -m 755 -d %{buildroot}%{_libexecdir}/%{name} %{buildroot}%{_libexecdir}/%{name}/cli %{buildroot}%{_libexecdir}/%{name}/cli/apps
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/ezbake-functions.sh %{buildroot}%{_libexecdir}/%{name}/
install -m 644 ./opt/puppetlabs/server/apps/puppetdb/ezbake.manifest %{buildroot}%{_libexecdir}/%{name}/
install -m 644 ./opt/puppetlabs/server/apps/puppetdb/puppetdb.jar %{buildroot}%{_libexecdir}/%{name}/

install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/anonymize %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/config-migration %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/delete-reports %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/foreground %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/reload %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/ssl-setup %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/start %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/stop %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetdb/cli/apps/upgrade %{buildroot}%{_libexecdir}/%{name}/cli/apps/

install -m 755 -d %{buildroot}%{_docdir}/%{name}/
cp -r ./opt/puppetlabs/server/apps/puppetdb/share/doc/%{name}-%{version}/docs/puppetdb/* %{buildroot}%{_docdir}/%{name}/

install -m 750 -d %{buildroot}%{_localstatedir}/log/%{name} %{buildroot}%{_localstatedir}/cache/%{name}

mkdir -p %{buildroot}%{_sbindir}
ln -s /sbin/service %{buildroot}%{_sbindir}/rc%{name}

%pre
getent group puppetdb >/dev/null || %{_sbindir}/groupadd -r puppetdb
getent passwd puppetdb >/dev/null || %{_sbindir}/useradd -r -g puppetdb -d /var/lib/puppetdb -s /bin/false -c "puppetdb daemon" puppetdb
%service_add_pre %{name}.service

%post
%{fillup_only}
%service_add_post %{name}.service
%set_permissions %{_sysconfdir}/puppetlabs/%{name}/*
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%defattr(-,root,root)
%license LICENSE.txt
%config %{_sysconfdir}/puppetlabs/%{name}
%{_fillupdir}/sysconfig.%{name}
%{_bindir}/%{name}
%{_libexecdir}/%{name}/
%{_docdir}/%{name}/
%{_sbindir}/rc%{name}
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
%attr(-, puppetdb, puppetdb) %dir %{_localstatedir}/cache/%{name}
%attr(-, puppetdb, puppetdb) %dir %{_localstatedir}/log/%{name}
%ghost /run/%{name}

%changelog

openSUSE Build Service is sponsored by