File gitlab-pages.spec of Package gitlab-pages

#
# spec file for package gitlab-pages
#
# Copyright (c) 2021 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} == 1315
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif

Name:           gitlab-pages
Version:        18.1.6
Release:        0
%define branch   master
%define revision v%{version}
License:        MIT
Summary:        GitLab Pages Daemon
Url:            https://gitlab.com/gitlab-org/gitlab-pages/-/tags
Group:          Development/Tools/Version Control
Source:         https://gitlab.com/gitlab-org/gitlab-pages/-/archive/v%{version}/gitlab-pages-v%{version}.tar.bz2
Source1:        %{name}.service
Source2:        gitlab-pages.sysconfig
Source3:        gitlab-pages.conf
Source98:       vendor.tar.xz
Source99:       series
Patch0:         pie.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.17
Requires(pre):  gitlab-common >= 0.0.2
BuildRequires:  pkgconfig(systemd)
Requires(post): fillup
Requires:       unzip
BuildRequires:  gitlab-common
%requires_eq    gitlab-common
Requires(pre):  gitlab-common
# for 11.1
# Requires:       make
%go_nostrip

%description
gitlab-git-http-server was designed to unload Git HTTP traffic from the GitLab
Rails app (Unicorn) to a separate daemon. All authentication and authorization
logic is still handled by the GitLab Rails app.

%prep
%autosetup -p1 -n %{name}-v%{version} -a 98

%build
make REVISION=%{revision} LAST_TAG=v%{version} COMMITS=0

%install
install -D -m 0755 %{name} %{buildroot}%{_sbindir}/%{name}
install -D -m 0644 %{S:1} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0750 -d     %{buildroot}%{_sysconfdir}/%{name}/
install -D -m 0640 %{S:3} %{buildroot}%{_sysconfdir}/%{name}/config
%if 0%{?suse_version}
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif
install -D -m 0644 %{S:2} \
    %{buildroot}%{_fillupdir}/sysconfig.%{name}

%if 0%{?suse_version}
%pre
%service_add_pre %{name}.service
%endif

%preun
%if 0%{?suse_version}
%service_del_preun %{name}.service
%else
%systemd_preun %{name}.service
%endif

%post
%if 0%{?suse_version}
%fillup_only %{name}
%service_add_post %{name}.service
%else
%systemd_post %{name}.service
%endif

%postun
%if 0%{?suse_version}
%service_del_postun %{name}.service
%else
%systemd_postun_with_restart %{name}.service
%endif

%files
%defattr(-,root,root)
%doc CHANGELOG.md README.md LICENSE
%{_sbindir}/%{name}
%config(noreplace) %attr(-,root,gitlab) %{_sysconfdir}/%{name}/
%{_fillupdir}/sysconfig.%{name}
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif
%{_unitdir}/%{name}.service
openSUSE Build Service is sponsored by