File gitlab-runner.spec of Package gitlab-runner

#
# spec file for package gitlab-runner
#
# Copyright (c) 2017 SUSE LINUX Products 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/
#
%define         home /srv/gitlab-runner
%define         username gitlab-runner
%define         configdir /etc/gitlab-runner/
%define         servicefile gitlab-runner.service

Name:           gitlab-runner
Version:        12.10.2
Release:        0
License:        GPL-3.0
Summary:        GitLab CI Runner
Url:            https://gitlab.com/gitlab-org/gitlab-runner
Source:         %{name}-linux-amd64.tar.gz
Source1:        %{servicefile}
Source2:        config.toml.example
BuildRequires:  pkgconfig(systemd)
Obsoletes:      gitlab-ci-multi-runner
BuildRoot:      %{_tmppath}/%{name}-%{version}-build


%description
GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab.
It is used in conjunction with GitLab CI, the open-source continuous integration service included with GitLab that coordinates the jobs.

%prep
%setup -cn %{name}-linux-amd64

%build

%install
install -D -m 0755 %{name}-linux-amd64 %{buildroot}%{_sbindir}/%{name}
install -D -m 0644 %{S:1} %{buildroot}%{_unitdir}/%{servicefile}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -Dd -m 0750 %{buildroot}%{home}
install -Dd -m 0750 %{buildroot}%{configdir}
install -m 0640 %{S:2} %{buildroot}%{configdir}/config.toml.example

%pre
/usr/sbin/groupadd -r %{username} >/dev/null 2>&1 || :
/usr/sbin/useradd -g %{username} -s /bin/false -r -c "%{summary}" -d %{home} %{username} >/dev/null 2>&1 || :
%service_add_pre %{servicefile}


%preun
%service_del_preun %{servicefile}


%post
%service_add_post %{servicefile}
if /usr/bin/getent group docker >/dev/null 2>&1; then
 usermod -aG docker %{username}
fi

%postun
%service_del_postun %{servicefile}

%files
%defattr(-,root,root)
%{_sbindir}/%{name}
%config(noreplace) %attr(-,root,%{username}) %{configdir}
%dir %attr(-,%{username},%{username}) %{home}
%{_unitdir}/%{servicefile}
%{_sbindir}/rc%{name}
openSUSE Build Service is sponsored by