173 lines
5.6 KiB
RPMSpec
173 lines
5.6 KiB
RPMSpec
%global common_description %{expand:
|
|
A runner for Gitea based on act.}
|
|
|
|
%global dockerd dockerd
|
|
%global rootless rootless
|
|
%global dockerd_rootless %{dockerd}-%{rootless}
|
|
%global dockerd_rootless_service %{dockerd}-%{rootless}-user.service
|
|
%global act_runner_bin act_runner
|
|
%global runner_user act-runner
|
|
%global runner_user_rootless %{runner_user}-%{rootless}
|
|
%global debug_package %{nil}
|
|
|
|
%global golicenses LICENSE
|
|
%global godocs examples README.md
|
|
%global goipath gitea.com/gitea/act_runner
|
|
|
|
Name: gitea-act-runner
|
|
Version: 0.2.11
|
|
Release: %autorelease -b 5
|
|
Summary: A runner for Gitea based on act.
|
|
|
|
%global act_runner_service %{name}.service
|
|
%global act_runner_rootless_service %{name}-%{rootless}.service
|
|
|
|
License: MIT
|
|
URL: https://gitea.com/gitea/act_runner
|
|
Source0: https://gitea.com/gitea/act_runner/archive/v%{version}.tar.gz
|
|
Source1: %{act_runner_service}
|
|
Source2: %{act_runner_rootless_service}
|
|
Source3: %{dockerd_rootless_service}
|
|
Source4: README-%{dockerd}.md
|
|
Source5: README-%{rootless}-%{dockerd}.md
|
|
Source6: rootless-act_runner-register.sh
|
|
Source7: %{name}-sysusers.conf
|
|
Source8: %{name}-tmpfiles.conf
|
|
Source9: act_runner-register.sh
|
|
|
|
BuildRequires: go >= 1.23
|
|
BuildRequires: go-rpm-macros
|
|
BuildRequires: git-core
|
|
|
|
%gometa -L -f
|
|
|
|
%description %{common_description}
|
|
|
|
# #############################################################
|
|
# act_runner with dockerd package
|
|
%package %{dockerd}
|
|
Summary: Enable running gitea actions in docker containers
|
|
Requires: %{name} docker-ce
|
|
Conflicts: %{name}-%{dockerd_rootless}
|
|
BuildRequires: systemd-rpm-macros
|
|
%{?%systemd_requires}
|
|
|
|
%description %{dockerd}
|
|
%{common_description}
|
|
Run gitea actions in docker containers
|
|
|
|
%pre %{dockerd}
|
|
%sysusers_create_package %{name} %{SOURCE7}
|
|
%tmpfiles_create_package %{name} %{SOURCE8}
|
|
|
|
%post %{dockerd}
|
|
%systemd_post %{act_runner_service}
|
|
if [ $1 -eq 1 ] || [ ! -d %{_sharedstatedir}/%{runner_user}/act_runner ]; then
|
|
echo ' INFO Please read README-%{dockerd}.md to finish the installation'
|
|
fi
|
|
|
|
%preun %{dockerd}
|
|
%systemd_preun %{act_runner_service}
|
|
|
|
%postun %{dockerd}
|
|
%systemd_postun %{act_runner_service}
|
|
|
|
# #############################################################
|
|
|
|
|
|
# #############################################################
|
|
# act_runner with rootless dockerd package
|
|
%package %{dockerd_rootless}
|
|
Summary: Enable running gitea actions in non-root docker containers
|
|
|
|
Requires: %{name} docker-ce slirp4netns fuse-overlayfs iptables docker-ce-rootless-extras shadow-utils
|
|
Conflicts: %{name}-%{dockerd}
|
|
BuildRequires: systemd-rpm-macros
|
|
%{?%systemd_requires}
|
|
|
|
%description %{dockerd_rootless}
|
|
%{common_description}
|
|
Run gitea actions in non-root docker containers
|
|
|
|
%pre %{dockerd_rootless}
|
|
if [ $1 -eq 1 ]; then
|
|
getent group '%{runner_user_rootless}' >/dev/null || groupadd -r '%{runner_user_rootless}' || :
|
|
getent passwd '%{runner_user_rootless}' >/dev/null || \
|
|
CREATE_MAIL_SPOOL=false useradd -r -m -F -g '%{runner_user_rootless}' -d '/home/%{runner_user_rootless}' -s '/sbin/nologin' -c 'Rootless act_runner docker user' '%{runner_user_rootless}' || :
|
|
fi
|
|
|
|
%post %{dockerd_rootless}
|
|
%systemd_user_post %{act_runner_rootless_service} %{dockerd_rootless_service}
|
|
if [ $1 -eq 1 ] || [ ! -d /home/%{runner_user_rootless}/act_runner ]; then
|
|
echo ' INFO Please read README-%{rootless}-%{dockerd}.md to finish the installation'
|
|
fi
|
|
loginctl enable-linger %{runner_user_rootless}
|
|
|
|
%preun %{dockerd_rootless}
|
|
%systemd_user_preun %{dockerd_rootless_service} %{act_runner_rootless_service}
|
|
if [ $1 -eq 0 ]; then
|
|
loginctl disable-linger %{runner_user_rootless}
|
|
fi
|
|
|
|
%postun %{dockerd_rootless}
|
|
%systemd_user_postun %{dockerd_rootless_service} %{act_runner_rootless_service}
|
|
if [ $1 -eq 0 ]; then
|
|
CREATE_MAIL_SPOOL=false userdel -rf %{runner_user_rootless}
|
|
fi
|
|
|
|
# #############################################################
|
|
|
|
|
|
%prep
|
|
%autosetup -p1 -C
|
|
%{__cp} %{SOURCE4} %{SOURCE5} .
|
|
|
|
%build
|
|
go build %{gobuild_baseflags} -o bin/%{act_runner_bin} %{goipath}
|
|
|
|
%install
|
|
# The binary
|
|
install -m 0755 -vd %{buildroot}%{_bindir}
|
|
install -m 0755 -vp bin/* %{buildroot}%{_bindir}
|
|
|
|
# dockerd
|
|
install -m 0755 -vd %{buildroot}%{_unitdir}
|
|
install -m 0755 -vd %{buildroot}%{_sysconfdir}/%{name}
|
|
install -D -m 0644 -vp %{SOURCE1} %{buildroot}%{_unitdir}/%{act_runner_service}
|
|
install -D %{SOURCE7} %{buildroot}%{_sysusersdir}/%{name}.conf
|
|
install -D %{SOURCE8} %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
|
bin/act_runner generate-config > %{buildroot}%{_sysconfdir}/%{name}/config.yaml
|
|
install -D -m 0755 -vp %{SOURCE9} %{buildroot}%{_datadir}/%{name}/act_runner-register.sh
|
|
|
|
# dockerd-rootless
|
|
install -m 0755 -vd %{buildroot}%{_userunitdir}
|
|
install -m 0755 -vd %{buildroot}%{_datadir}/%{name}
|
|
install -D -m 0644 -vp %{SOURCE2} %{buildroot}%{_userunitdir}/%{act_runner_rootless_service}
|
|
install -D -m 0644 -vp %{SOURCE3} %{buildroot}%{_userunitdir}/%{dockerd_rootless_service}
|
|
install -D -m 0755 -vp %{SOURCE6} %{buildroot}%{_datadir}/%{name}/rootless-act_runner-register.sh
|
|
|
|
%files
|
|
%license LICENSE
|
|
%doc README.md
|
|
%{_bindir}/*
|
|
%dir %{_datadir}/%{name}
|
|
|
|
%files %{dockerd}
|
|
%license LICENSE
|
|
%doc README-%{dockerd}.md
|
|
%dir %{_sysconfdir}/%{name}
|
|
%config %{_sysconfdir}/%{name}/config.yaml
|
|
%{_unitdir}/*
|
|
%{_sysusersdir}/%{name}.conf
|
|
%{_tmpfilesdir}/%{name}.conf
|
|
%{_datadir}/%{name}/act_runner-register.sh
|
|
|
|
%files %{dockerd_rootless}
|
|
%license LICENSE
|
|
%doc README-%{rootless}-%{dockerd}.md
|
|
%{_userunitdir}/*
|
|
%{_datadir}/%{name}/rootless-act_runner-register.sh
|
|
|
|
%changelog
|
|
%autochangelog
|