File jenkins-agent.spec of Package jenkins-agent

#
# spec file for package jenkins-agent
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%if 0%{?suse_version} < 1600
%define _libexecdir %{_usr}/libexec/
%endif
Name:           jenkins-agent
Version:        1
Release:        0
Summary:        Jenkins agent bootstrap helper
License:        Apache-2.0
Group:          Development/Tools/Building
Source0:        jenkins-agent-download.sh
Source1:        jenkins-agent-workdir.sh
Source2:        jenkins-agent.service
Source3:        jenkins-agent.sysconfig
Source4:        jenkins-agent.sysuser
Source5:        README.SUSE
BuildRequires:  sysuser-tools
Requires:       java-17-openjdk-headless
BuildArch:      noarch

%description
Download and setup helper for bootstrapping a Jenkins agent.

%prep
cp %{SOURCE5} .

%build
%sysusers_generate_pre %{SOURCE4} %{name}

%install
install -d %{buildroot}%{_fillupdir} %{buildroot}%{_unitdir} %{buildroot}%{_sbindir} %{buildroot}%{_sysusersdir} %{buildroot}%{_libexecdir} %{buildroot}/opt/jenkins/bin
install -vm0755 %{SOURCE0} %{buildroot}%{_sbindir}
install -vm0755 %{SOURCE1} %{buildroot}%{_libexecdir}
install -vm0644 %{SOURCE2} %{buildroot}%{_unitdir}
install -vm0644 %{SOURCE4} %{buildroot}%{_sysusersdir}/%{name}.conf
install -vm0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{name}
ln -sv %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%pre -f %{name}.pre
%service_add_pre %{name}.service

%post
%{fillup_only -n %{name}}
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%doc README.SUSE
%{_sbindir}/rc%{name}
%{_sbindir}/%{name}-download.sh
%{_libexecdir}/%{name}-workdir.sh
%{_unitdir}/%{name}.service
%{_sysusersdir}/%{name}.conf
%{_fillupdir}/sysconfig.%{name}
%dir /opt/jenkins{,/bin}
%ghost /opt/jenkins/bin/agent.jar
%if 0%{?suse_version} < 1600
%dir %{_libexecdir}
%endif

%changelog
openSUSE Build Service is sponsored by