File rubygem-puppet.spec of Package rubygem-puppet.26170

#
# spec file for package rubygem-puppet
#
# Copyright (c) 2018 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/
#


#
# This file was generated with a gem2rpm.yml and not just plain gem2rpm.
# All sections marked as MANUAL, license headers, summaries and descriptions
# can be maintained in that file. Please consult this file before editing any
# of those fields
#

Name:           rubygem-puppet
Version:        4.8.1
Release:        0
%define mod_name puppet
%define mod_full_name %{mod_name}-%{version}
# MANUAL
%define confdir %{_sysconfdir}/puppetlabs/%{mod_name}
%define codedir %{_sysconfdir}/puppetlabs/code
%define logdir %{_localstatedir}/log/puppetlabs/puppet
%define vardir %{_localstatedir}/cache/puppetlabs/puppet
%define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services
%define _unitdir /usr/lib/systemd
%{!?vim_data_dir:%global vim_data_dir %{_datadir}/vim/%(readlink %{_datadir}/vim/current)}

# not really required, but we don't want to own their dirs
BuildRequires: vim
BuildRequires: emacs-nox

BuildRequires: facter
BuildRequires: fdupes
BuildRequires: systemd
BuildRequires: %{rubygem rgen >= 0.6.6}
BuildRequires: %{rubygem deep_merge}
BuildRequires: %{rubygem pathspec}
BuildRequires: %{rubygem hiera >= 2.0}
%{?systemd_requires}
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
Requires(pre): %fillup_prereq
Requires:      rubygem(%{mod_name})
Requires:      tar
Requires:      facter
Provides:      puppet-agent = 1.8.1
#!BuildIgnore: rubygem(%{mod_name})
# /MANUAL
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  ruby-macros >= 5
BuildRequires:  %{ruby >= 1.9.3}
BuildRequires:  %{rubygem gem2rpm}
BuildRequires:  %{rubygem rdoc > 3.10}
BuildRequires:  update-alternatives
Url:            https://github.com/puppetlabs/puppet
Source:         https://rubygems.org/gems/%{mod_full_name}.gem
Source1:        puppet.fw
Source2:        %{name}-rpmlintrc
Source3:        gem2rpm.yml
# MANUAL
Patch0:  puppet-4.8.1-gemspec.patch
Patch1:  puppet-4.8.1-change-default-cache-dir.patch
Patch2:  puppet-4.8.1-CVE-2017-10689.patch
Patch3:  puppet-4.8.1-CVE-2021-27023.patch
# /MANUAL
Summary:        A network tool for managing many disparate systems
License:        Apache-2.0
Group:          Development/Languages/Ruby
PreReq:         update-alternatives

%description
Puppet lets you centrally manage every important aspect of your system
using a cross-platform specification language that manages all the
separate elements normally aggregated in different files, like users,
cron jobs, and hosts, along with obviously discrete elements like
packages, services, and files.
%prep
%gem_unpack
%patch0 -p0
%patch1 -p1
%patch2 -p1
%patch3 -p1
find -type f -print0 | xargs -0 touch -r %{S:0}
%gem_build

%build

%install
%gem_install \
  --symlink-binaries \
  --doc-files="LICENSE README.md" \
  -f
# MANUAL
gemdir="%{buildroot}$(gem env gemdir)/gems/%{mod_full_name}"
install -d -m 755 %{buildroot}%{_sbindir}
install -d -m 750 %{buildroot}%{vardir}
install -d -m 750 %{buildroot}%{logdir}
install -d -m 755 %{buildroot}%{_fwdefdir}
install -d -m 755 %{buildroot}%{_unitdir}/system
install -D -m 644 $gemdir/conf/puppet.conf %{buildroot}%{confdir}/puppet.conf
for dir in hieradata manifests modules; do
    install -d -m 755 %{buildroot}%{codedir}/environments/production/$dir
done
install -D -m 644 $gemdir/conf/environment.conf %{buildroot}%{codedir}/environments/production/environment.conf
install -d -m 755 %{buildroot}%{codedir}/modules
install -d %{buildroot}%{_localstatedir}/adm/fillup-templates
install -m 644 $gemdir/ext/redhat/client.sysconfig %{buildroot}/%{_localstatedir}/adm/fillup-templates/sysconfig.puppet
ln -sf service %{buildroot}/%{_sbindir}/rcpuppet
sed -i -e 's:/opt/puppetlabs/puppet:/usr:' $gemdir/ext/systemd/puppet.service
install -m 644 $gemdir/ext/systemd/puppet.service  %{buildroot}%{_unitdir}/system/puppet.service
install -m 644 %{SOURCE2} %{buildroot}/%{_fwdefdir}/puppet

for mandirX in $(ls $gemdir/man); do
    for manpage in $(ls $gemdir/man/$mandirX); do
        install -Dm0444 $gemdir/man/$mandirX/$manpage %{buildroot}/%{_mandir}/$mandirX/$manpage
    done
done

%fdupes %{buildroot}%{_prefix}

# create /var/run/puppetlabs directory
mkdir -p %{buildroot}%{_tmpfilesdir}
cat > %{buildroot}%{_tmpfilesdir}/puppet.conf <<EOF
d /var/run/puppetlabs 0755 root root -
EOF

# Install vim syntax files
install -Dp -m 644 $gemdir/ext/vim/ftdetect/%{mod_name}.vim %{buildroot}%{vim_data_dir}/ftdetect/%{mod_name}.vim
install -Dp -m 644 $gemdir/ext/vim/ftplugin/%{mod_name}.vim %{buildroot}%{vim_data_dir}/ftplugin/%{mod_name}.vim
install -Dp -m 644 $gemdir/ext/vim/indent/%{mod_name}.vim %{buildroot}%{vim_data_dir}/indent/%{mod_name}.vim
install -Dp -m 644 $gemdir/ext/vim/syntax/%{mod_name}.vim %{buildroot}%{vim_data_dir}/syntax/%{mod_name}.vim

# Install emacs mode files
emacsdir=%{buildroot}%{_datadir}/emacs/site-lisp
install -Dp -m 644 $gemdir/ext/emacs/puppet-mode.el $emacsdir/puppet-mode.el
install -Dp -m 644 $gemdir/ext/emacs/puppet-mode-init.el $emacsdir/site-start.d/puppet-mode-init.el

# The users should use upstream puppetserver package so we need to create symlinks to make puppetserver working with our agent
mkdir -p %{buildroot}/opt/puppetlabs/puppet/{bin,lib/ruby/vendor_ruby}
ln -s /usr/bin/puppet %{buildroot}/opt/puppetlabs/puppet/bin
VENDOR_RUBY_PATH=$(gem env gemdir | sed 's/gems/vendor_ruby/')
ln -s $VENDOR_RUBY_PATH/facter* %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby
for file in deep_merge hiera rgen pathspec; do
    ln -s $(gem env gemdir)/gems/$file-*/lib/${file}* %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby
done
for file in hiera_puppet.rb puppet puppet.rb puppet_x.rb semver.rb; do
    ln -s $(gem env gemdir)/gems/%{mod_full_name}/lib/$file %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby
done
# /opt/puppetlabs/lib/ruby/vendor_ruby/hiera directory needs to contain files from both the hiera and the puppet packages
rm %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera
install -d -m 755 %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera
for file in $(ls %{buildroot}/$(gem env gemdir)/gems/hiera-*/lib/hiera/); do
    ln -s $(gem env gemdir)/gems/hiera-*/lib/hiera/${file} %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/
done
for file in $(ls $gemdir/lib/hiera); do
    ln -s $(gem env gemdir)/gems/%{mod_full_name}/lib/hiera/$file %{buildroot}/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/
done

for gem in $(/usr/bin/ruby-find-versioned gem) ; do
    # Remove those dirs as they cause strange runtime dependencies
    gemdir="%{buildroot}$($gem env gemdir)/gems/%{mod_full_name}"
    rm -rf $gemdir/ext/{debian,gentoo,solaris,ips}
    # Remove bundled libraries
    rm -rf $gemdir/lib/puppet/vendor/{*rgen*,*deep_merge*,*pathspec*}
done
# /MANUAL


%files
%defattr(-,root,root,-)
%dir %{_sysconfdir}/puppetlabs
%dir %{confdir}
%{codedir}
%config(noreplace) %{confdir}/%{mod_name}.conf
%config(noreplace) %{codedir}/environments/production/environment.conf
%config(noreplace) %{_fwdefdir}/%{mod_name}
%{_mandir}/man?/*
%{_sbindir}/rcpuppet
%{_unitdir}/system/%{mod_name}.service
%{_localstatedir}/adm/fillup-templates/sysconfig.puppet
%dir %{_localstatedir}/log/puppetlabs
%attr(0750,root,root) %dir %{logdir}
%dir %{_localstatedir}/cache/puppetlabs
%attr(0750,root,root) %dir %{vardir}
%{_tmpfilesdir}/puppet.conf
%dir /opt/puppetlabs
/opt/puppetlabs/puppet

%pre
%service_add_pre puppet.service

%preun
%service_del_preun puppet.service

%postun
%service_del_postun puppet.service

%post
%tmpfiles_create %{_tmpfilesdir}/puppet.conf
%fillup_only -n puppet
%service_add_post puppet.service

%package vim
Summary:     Vim syntax files for Puppet manifests
Group:       Productivity/Text/Editors
Requires:    vim
BuildArch:   noarch
Supplements: packageand(vim:%{name})
Provides:    puppet-vim = %{version}-%{release}
Obsoletes:   puppet-vim < %{version}-%{release}

# Requires:      rubygem-puppet = 4.8.1
%description vim
Vim ftdetect and syntax files for Puppet manifests

%files vim
%defattr(-,root,root,-)
%dir %{vim_data_dir}/ftdetect
%{vim_data_dir}/ftdetect/%{mod_name}.vim
%{vim_data_dir}/ftplugin/%{mod_name}.vim
%{vim_data_dir}/indent/%{mod_name}.vim
%{vim_data_dir}/syntax/%{mod_name}.vim


%package emacs
Summary:     Emacs syntax files for Puppet
Group:       Productivity/Text/Editors
Requires:    emacs
BuildArch:   noarch
Supplements: packageand(emacs:%{name})
Provides:    puppet-emacs = %{version}-%{release}

# Requires:      rubygem-puppet = 4.8.1
%description emacs
Emacs syntax files for Puppet manifests

%files emacs
%defattr(-,root,root,-)
# emacs-mode files
%{_datadir}/emacs/site-lisp/puppet-mode.el
%{_datadir}/emacs/site-lisp/site-start.d/puppet-mode-init.el


%gem_packages

%changelog
openSUSE Build Service is sponsored by