<commit_before>%global realname puppetdb
%global realversion <%= Pkg::Config.version %>
%global rpmversion <%= Pkg::Config.rpmversion %>

%define __jar_repack 0

<% if @pe -%>
%global open_jdk          pe-java
<% else -%>
%if 0%{?suse_version} >= 1220
%global open_jdk          java-1_7_0-openjdk
%else
%global open_jdk          java-1.7.0-openjdk
%endif
<% end -%>

# On FOSS releases for platforms with ruby 1.9, puppet uses vendorlibdir instead of sitelibdir
# On PE, we use sitelibdir
<% if @pe -%>
%global puppet_libdir     %(PATH=/opt/puppet/bin:$PATH ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
<% else -%>
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%global puppet_libdir     %(ruby -rrbconfig -e "puts RbConfig::CONFIG['vendorlibdir']")
%else
%global puppet_libdir     %(ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
%endif
<% end -%>

# Fedora 17 and later and EL > 7 use systemd
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%global _with_systemd 1
%else
%global _with_systemd 0
%endif

# These macros are not always defined on much older rpm-based systems
%global  _sharedstatedir /var/lib
%global  _realsysconfdir /etc
%if 0%{?suse_version}
%global  _initddir       %{_realsysconfdir}/init.d
%else
%global  _initddir       %{_realsysconfdir}/rc.d/init.d
%endif
%global  _rundir         /var/run

<% if @pe -%>
%global p_vendor pe
%global _orig_prefix %{_prefix}
%global name_prefix  %{p_vendor}-
%global _sysconfdir /etc/puppetlabs
%define _lib lib
%define _prefix /opt/puppet
%define _libexecdir %{_prefix}/libexec
<% end -%>

<% if @pe -%>
Name:          pe-puppetdb
<% else -%>
Name:          puppetdb
<% end -%>
Version:       <%= Pkg::Config.rpmversion %>
Release:       <%= Pkg::Config.rpmrelease %>%{?dist}
BuildRoot:     %{_tmppath}/%{realname}-%{version}-%{release}-root-%(%{__id_u} -n)

Summary:       Puppet Centralized Storage Daemon
%if 0%{?suse_version}
License:       Apache-2.0
%else
License:       ASL 2.0
%endif

<% if @pe -%>
URL:           http://puppetlabs.com/puppet/puppet-enterprise
Source0:       %{name}-%{realversion}.tar.gz
<% else -%>
URL:           http://github.com/puppetlabs/puppetdb
Source0:       http://downloads.puppetlabs.com/puppetdb/%{realname}-%{realversion}.tar.gz
<% end -%>

%if 0%{?suse_version}
Group:         System/Daemons
%else
Group:         System Environment/Daemons
%endif

<% if @pe -%>
BuildRequires: pe-facter >= 1.7.0, pe-puppet
BuildRequires: pe-rubygem-rake
BuildRequires: pe-ruby
Requires:      pe-puppet >= 2.7.12
<% else -%>
BuildRequires: facter >= 1.7.0
BuildRequires: puppet >= 2.7.12
BuildRequires: rubygem-rake
BuildRequires: ruby
Requires:      puppet >= 2.7.12
Requires:      facter >= 1.6.8
<% end -%>
BuildArch:     noarch
%if 0%{?suse_version}
BuildRequires: aaa_base
BuildRequires: unzip
BuildRequires: sles-release
Requires:      aaa_base
Requires:      pwdutils
Requires:      logrotate
Requires:      procps
%else
BuildRequires: /usr/sbin/useradd
%if 0%{?_with_systemd}
# Required for %%post, %%preun, %%postun
Requires:       systemd
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
BuildRequires:  systemd
%else
BuildRequires:  systemd-units
%endif
%else
# Required for %%post and %%preun
Requires:       chkconfig
%endif
%endif
BuildRequires: %{open_jdk}
Requires:      %{open_jdk}

%description
Puppet Centralized Storage.

%package terminus
Summary: Puppet terminus files to connect to PuppetDB
%if 0%{?suse_version}
Group: System/Libraries
%else
Group: Development/Libraries
%endif
<% if @pe -%>
Requires: pe-puppet >= 2.7.12
<% else -%>
Requires: puppet >= 2.7.12
<% end -%>

%description terminus
Connect Puppet to PuppetDB by setting up a terminus for PuppetDB.

%prep
<% if @pe -%>
%setup -q -n %{name}-%{realversion}
<% else -%>
%setup -q -n %{realname}-%{realversion}
<% end -%>

%build

%install
%if 0%{?suse_version}
export NO_BRP_CHECK_BYTECODE_VERSION=true
%endif

rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_initddir}

<% if @pe -%>
PATH=/opt/puppet/bin:$PATH rake install PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT PE_BUILD=true
PATH=/opt/puppet/bin:$PATH rake terminus PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT PE_BUILD=true
<% else -%>
rake install PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT
rake terminus PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT
<% end -%>

mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/%{name}
mkdir -p $RPM_BUILD_ROOT/%{_rundir}/%{name}
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/%{name}
touch  $RPM_BUILD_ROOT/%{_localstatedir}/log/%{name}/%{name}.log

%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 || 0%{?sles_version} >= 12
sed -i '/notifempty/a\    su puppetdb puppetdb' $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/%{name}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%pre
# Here we'll do a little bit of cleanup just in case something went horribly
# awry during a previous install/uninstall:
if [ -f "<%= @install_dir %>/start_service_after_upgrade" ] ; then
   rm <%= @install_dir %>/start_service_after_upgrade
fi
# If this is an upgrade (as opposed to an install) then we need to check
#  and see if the service is running.  If it is, we need to stop it.
#  we want to shut down and disable the service.
if [ "$1" = "2" ] ; then<commit_msg>(maint) Explicitly set LANG in RPM spec file<commit_after>%global realname puppetdb
%global realversion <%= Pkg::Config.version %>
%global rpmversion <%= Pkg::Config.rpmversion %>

%define __jar_repack 0

<% if @pe -%>
%global open_jdk          pe-java
<% else -%>
%if 0%{?suse_version} >= 1220
%global open_jdk          java-1_7_0-openjdk
%else
%global open_jdk          java-1.7.0-openjdk
%endif
<% end -%>

# On FOSS releases for platforms with ruby 1.9, puppet uses vendorlibdir instead of sitelibdir
# On PE, we use sitelibdir
<% if @pe -%>
%global puppet_libdir     %(PATH=/opt/puppet/bin:$PATH ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
<% else -%>
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%global puppet_libdir     %(ruby -rrbconfig -e "puts RbConfig::CONFIG['vendorlibdir']")
%else
%global puppet_libdir     %(ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
%endif
<% end -%>

# Fedora 17 and later and EL > 7 use systemd
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%global _with_systemd 1
%else
%global _with_systemd 0
%endif

# These macros are not always defined on much older rpm-based systems
%global  _sharedstatedir /var/lib
%global  _realsysconfdir /etc
%if 0%{?suse_version}
%global  _initddir       %{_realsysconfdir}/init.d
%else
%global  _initddir       %{_realsysconfdir}/rc.d/init.d
%endif
%global  _rundir         /var/run

<% if @pe -%>
%global p_vendor pe
%global _orig_prefix %{_prefix}
%global name_prefix  %{p_vendor}-
%global _sysconfdir /etc/puppetlabs
%define _lib lib
%define _prefix /opt/puppet
%define _libexecdir %{_prefix}/libexec
<% end -%>

<% if @pe -%>
Name:          pe-puppetdb
<% else -%>
Name:          puppetdb
<% end -%>
Version:       <%= Pkg::Config.rpmversion %>
Release:       <%= Pkg::Config.rpmrelease %>%{?dist}
BuildRoot:     %{_tmppath}/%{realname}-%{version}-%{release}-root-%(%{__id_u} -n)

Summary:       Puppet Centralized Storage Daemon
%if 0%{?suse_version}
License:       Apache-2.0
%else
License:       ASL 2.0
%endif

<% if @pe -%>
URL:           http://puppetlabs.com/puppet/puppet-enterprise
Source0:       %{name}-%{realversion}.tar.gz
<% else -%>
URL:           http://github.com/puppetlabs/puppetdb
Source0:       http://downloads.puppetlabs.com/puppetdb/%{realname}-%{realversion}.tar.gz
<% end -%>

%if 0%{?suse_version}
Group:         System/Daemons
%else
Group:         System Environment/Daemons
%endif

<% if @pe -%>
BuildRequires: pe-facter >= 1.7.0, pe-puppet
BuildRequires: pe-rubygem-rake
BuildRequires: pe-ruby
Requires:      pe-puppet >= 2.7.12
<% else -%>
BuildRequires: facter >= 1.7.0
BuildRequires: puppet >= 2.7.12
BuildRequires: rubygem-rake
BuildRequires: ruby
Requires:      puppet >= 2.7.12
Requires:      facter >= 1.6.8
<% end -%>
BuildArch:     noarch
%if 0%{?suse_version}
BuildRequires: aaa_base
BuildRequires: unzip
BuildRequires: sles-release
Requires:      aaa_base
Requires:      pwdutils
Requires:      logrotate
Requires:      procps
%else
BuildRequires: /usr/sbin/useradd
%if 0%{?_with_systemd}
# Required for %%post, %%preun, %%postun
Requires:       systemd
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
BuildRequires:  systemd
%else
BuildRequires:  systemd-units
%endif
%else
# Required for %%post and %%preun
Requires:       chkconfig
%endif
%endif
BuildRequires: %{open_jdk}
Requires:      %{open_jdk}

%description
Puppet Centralized Storage.

%package terminus
Summary: Puppet terminus files to connect to PuppetDB
%if 0%{?suse_version}
Group: System/Libraries
%else
Group: Development/Libraries
%endif
<% if @pe -%>
Requires: pe-puppet >= 2.7.12
<% else -%>
Requires: puppet >= 2.7.12
<% end -%>

%description terminus
Connect Puppet to PuppetDB by setting up a terminus for PuppetDB.

%prep
<% if @pe -%>
%setup -q -n %{name}-%{realversion}
<% else -%>
%setup -q -n %{realname}-%{realversion}
<% end -%>

%build

%install
%if 0%{?suse_version}
export NO_BRP_CHECK_BYTECODE_VERSION=true
%endif

rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_initddir}

# Explicitly set environment variable LANG,
# because otherwise it gets set to 'C' and that
# is wrong, wrong, wrong. There may be a better
# way to handle this, so this may change.
export LANG=en_US.UTF-8

<% if @pe -%>
PATH=/opt/puppet/bin:$PATH rake install PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT PE_BUILD=true
PATH=/opt/puppet/bin:$PATH rake terminus PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT PE_BUILD=true
<% else -%>
rake install PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT
rake terminus PARAMS_FILE= DESTDIR=$RPM_BUILD_ROOT
<% end -%>

mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/%{name}
mkdir -p $RPM_BUILD_ROOT/%{_rundir}/%{name}
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/%{name}
touch  $RPM_BUILD_ROOT/%{_localstatedir}/log/%{name}/%{name}.log

%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 || 0%{?sles_version} >= 12
sed -i '/notifempty/a\    su puppetdb puppetdb' $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/%{name}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%pre
# Here we'll do a little bit of cleanup just in case something went horribly
# awry during a previous install/uninstall:
if [ -f "<%= @install_dir %>/start_service_after_upgrade" ] ; then
   rm <%= @install_dir %>/start_service_after_upgrade
fi
# If this is an upgrade (as opposed to an install) then we need to check
#  and see if the service is running.  If it is, we need to stop it.
#  we want to shut down and disable the service.
if [ "$1" = "2" ] ; then
{'fraction_non_alphanumeric': 0.149478672985782, 'fraction_numerical': 0.016398104265402842, 'mean_word_length': 4.005218216318785, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6246799', 'n_tokens_mistral': 4367, 'n_tokens_neox': 4071, 'n_words': 1023}