File jenkins.spec of Package jenkins

#
# spec file for package jenkins
#
# Copyright (c) 2011-2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2011-2012, Sascha Peilicke <saschpe@gmx.de>
#
# 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/
#

# macro is not present in every supported distribution yet
%if 0%{!?_fillupdir:1}
%define _fillupdir /usr/share/fillup-templates
%define fillupdir_missing 1
%endif

Name:           jenkins
Version:        2.267
Release:        1
License:        MIT
Summary:        An extendable open source continuous integration server
Url:            https://jenkins-ci.org
Group:          Development/Tools/Building
Source0:        https://pkg.jenkins.io/opensuse/jenkins-%{version}-1.2.noarch.rpm
Source1:        https://pkg.jenkins.io/redhat/jenkins.io.key
Source2:        %{name}.init
Source3:        %{name}.sysconfig
Source4:        %{name}.logrotate
BuildRequires:  unzip
Requires:       java >= 1.8
Provides:       hudson = %{version}
Obsoletes:      hudson < %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if 0%{?suse_version} >= 1010
Suggests:       logrotate
%endif
Requires(pre):  pwdutils
Requires(pre):  %fillup_prereq %insserv_prereq

%description
Jenkins-CI monitors executions of repeated jobs, such as building a software
project or jobs run by cron. Among those things, current Jenkins-CI focuses
on the following two jobs:

   1. Building/testing software projects continuously, just like
      CruiseControl or DamageControl. In a nutshell, Jenkins-CI provides an
      easy-to-use so-called continuous integration system, making it
      easier for developers to integrate changes to the project, and
      making it easier for users to obtain a fresh build. The automated,
      continuous build increases the productivity.
   2. Monitoring executions of externally-run jobs, such as cron jobs and
      procmail jobs, even those that are run on a remote machine. For
      example, with cron, all you receive is regular e-mails that capture
      the output, and it is up to you to look at them diligently and notice
      when it broke. Jenkins-CI keeps those outputs and makes it easy for you
      to notice when something is wrong.

%prep
rpm=%{SOURCE0}
rpmkeys --dbpath `pwd`/rpm --import %{SOURCE1}
rpm --dbpath `pwd`/rpm -K $rpm
set -o pipefail
rpm2cpio $rpm | cpio -i --to-stdout ".*usr/lib/jenkins/jenkins.war" > jenkins.war
test -s jenkins.war # ensure it is not empty

%build

%install
install -Dm0644 jenkins.war %{buildroot}%{_prefix}/lib/%{name}/%{name}.war
install -Dm0755 %{SOURCE2} %{buildroot}%{_sysconfdir}/init.d/%{name}
install -d %{buildroot}%{_sbindir}
ln -sf ../..%{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
install -Dm0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{name}
install -Dm0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -d %{buildroot}%{_localstatedir}/lib/%{name}
install -d %{buildroot}%{_localstatedir}/log/%{name}

%pre
groupadd -r jenkins &>/dev/null || :
useradd -g jenkins -s /bin/false -r -c "Jenkins Continuous Build server" -d /var/lib/jenkins jenkins &>/dev/null || :
# package update ?
if [ ${1:-0} -gt 1 ]; then
  # update to >= 1.451.1
  # set a mark when updating from JENKINS_AJP_HOST="0.0.0.0"
  eval JENKINS_AJP_HOST='' \
    `grep -s '^[[:space:]]*JENKINS_AJP_HOST=' etc/sysconfig/jenkins`
  if [ "x$JENKINS_AJP_HOST" = "x0.0.0.0" ] ; then
    touch etc/sysconfig/__change_jenkins_ajp_host__
  fi
fi

%post
%fillup_and_insserv %{name}
# replace old val of JENKINS_AJP_HOST if necessary
if [ -f etc/sysconfig/__change_jenkins_ajp_host__ ] ; then
  rm -f etc/sysconfig/__change_jenkins_ajp_host__
  sed -i -e 's/^JENKINS_AJP_HOST=.*/JENKINS_AJP_HOST=""/g' \
    etc/sysconfig/jenkins
fi

%preun
%stop_on_removal %{name}

%postun
%restart_on_update %{name}
%insserv_cleanup

%files
%defattr(-,root,root,,)
%{_sbindir}/rc%{name}
%{_prefix}/lib/%{name}
%config %{_sysconfdir}/init.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
#%%config(noreplace) %%{_sysconfdir}/sysconfig/%%{name}
%if 0%{?fillupdir_missing}
%dir %_fillupdir
%endif
%_fillupdir/sysconfig.%{name}
%attr(0755,jenkins,jenkins) %dir %{_localstatedir}/lib/%{name}
%attr(0755,jenkins,jenkins) %{_localstatedir}/log/%{name}

%changelog
openSUSE Build Service is sponsored by