File puppetserver.spec of Package puppetserver

#
# spec file for package puppetserver
#
# 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.sles15
%global rpm_name %{name}-%{version}-%{rpm_release}.noarch.rpm
%global puppetserver_ca_version 2.0.1

Name:           puppetserver
Version:        8.6.2
Release:        0
Summary:        Puppet Labs server for Puppet
License:        Apache-2.0
Group:          System/Daemons
Url:            http://puppet.com
Source0:        https://yum.puppet.com/puppet8/sles/15/x86_64/%{rpm_name}
Source1:        https://github.com/puppetlabs/puppetserver/blob/%{version}/LICENSE.md
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) >= 8.0.0

Recommends:     jruby(facter.jar) >= 3.14
Requires:       rubygem(concurrent-ruby) >= 1.1.5
Requires:       rubygem(deep_merge) >= 1.0.1
Requires:       rubygem(fast_gettext) >= 1.1.2
Requires:       rubygem(gettext) >= 3.2.2
Requires:       rubygem(hocon) >= 1.3.1
Requires:       rubygem(locale) >= 2.1.2
Requires:       rubygem(text) >= 1.3.1
Requires:       rubygem(semantic_puppet) >= 1.0.2
Requires:       rubygem(puppetserver-ca) >= %{puppetserver_ca_version}
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
Puppet Server is the next-generation application for managing Puppet agents.
This platform implements Puppet's server-side components in a more distributed, service-oriented architecture.

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

%build

%install

install -m 755 -d %{buildroot}/etc/puppetlabs/%{name}/conf.d %{buildroot}/etc/puppetlabs/%{name}/services.d %{buildroot}/etc/puppetlabs/code
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/auth.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/ca.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/global.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/metrics.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/puppetserver.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/web-routes.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/conf.d/webserver.conf %{buildroot}/etc/puppetlabs/%{name}/conf.d
install -m 644 ./etc/puppetlabs/puppetserver/logback.xml %{buildroot}/etc/puppetlabs/%{name}/
install -m 644 ./etc/puppetlabs/puppetserver/request-logging.xml %{buildroot}/etc/puppetlabs/%{name}/
install -m 644 ./etc/puppetlabs/puppetserver/services.d/ca.cfg %{buildroot}/etc/puppetlabs/%{name}/services.d/

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

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

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

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

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

install -m 644 ./opt/puppetlabs/server/apps/puppetserver/cli/cli-defaults.sh %{buildroot}%{_libexecdir}/%{name}/cli/

install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/ca %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/foreground %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/gem %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/irb %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/reload %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/ruby %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/start %{buildroot}%{_libexecdir}/%{name}/cli/apps/
install -m 755 ./opt/puppetlabs/server/apps/puppetserver/cli/apps/stop %{buildroot}%{_libexecdir}/%{name}/cli/apps/

install -m 755 -d %{buildroot}/%{_datadir}/%{name}/config/services.d
install -m 644 ./opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg %{buildroot}/%{_datadir}/%{name}/config/services.d/

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 puppet >/dev/null || %{_sbindir}/groupadd -r puppet
getent passwd puppet >/dev/null || %{_sbindir}/useradd -r -g puppet -d /var/lib/puppet -s /bin/false -c "puppet daemon" puppet
%service_add_pre %{name}.service

%post
%{fillup_only}
%service_add_post %{name}.service
%set_permissions /etc/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.md
%config %{_sysconfdir}/puppetlabs/%{name}
%{_bindir}/puppetserver
%{_sbindir}/rc%{name}
%{_libexecdir}/%{name}/
%{_datadir}/%{name}/
%attr(-, puppet, puppet) %dir %{_localstatedir}/cache/%{name}
%attr(-, puppet, puppet) %{_localstatedir}/log/%{name}
%{_unitdir}/%{name}.service
%{_fillupdir}/sysconfig.%{name}
%{_tmpfilesdir}/%{name}.conf
%ghost /run/%{name}

%changelog

openSUSE Build Service is sponsored by