%global _build_id_links none %global debug_package %{nil} %undefine source_date_epoch_from_changelog %global upstream_version 3.2.0 %global software_name gitea-runner Name: %{software_name} Version: %{upstream_version} Release: 1%{?dist} Summary: A runner for Gitea Actions License: MIT URL: https://gitea.com/gitea/runner # Upstream module path is gitea.com/gitea/runner; the produced binary is named # "gitea-runner" via the -o flag below (the bare `go build` default is "runner"). # Source0 unpacks to gitea-runner-%%{upstream_version}/ (archive prefix set by the # vendor workflow). Same filename/layout as the Debian orig tarball. Source0: %{software_name}_%{upstream_version}.orig.tar.gz # Vendored Go modules (Debian orig-vendor component: contents of vendor/ only). Source1: %{software_name}_%{upstream_version}.orig-vendor.tar.gz # Systemd service file (system scope: rootful / host backend) Source2: %{software_name}.service # Sysusers configuration Source3: %{software_name}.sysusers # Systemd service file (user scope: rootless podman, run via `systemctl --user`) Source4: %{software_name}.user.service BuildRequires: tar, golang, systemd-rpm-macros %{?systemd_requires} # Explicit user/group creation in %%pre (sysusers may defer creation, # causing %%attr in %%files to fall back to root:root). Requires(pre): shadow # This package creates its own user/group in %%pre. # Provide them so RPM doesn't look externally for 'group(gitea-runner)'. Provides: group(%{software_name}) Provides: user(%{software_name}) # A container engine is only needed for the docker backend; the host backend # runs jobs without one. Weak dependency so the common case pulls one in while # host-only setups can omit it. Package names differ across distros. Recommends: (docker or moby-engine or podman) %description Gitea Actions runner runs jobs defined in Gitea Actions workflows. It supports both host and container (Docker) execution backends. %prep %autosetup -p1 -n %{software_name}-%{upstream_version} # Use vendored Go modules to minimize network access during build. # Source1 is a Debian-style orig-vendor component (contents of vendor/ only). mkdir -p vendor tar -xf %{SOURCE1} -C vendor if [ ! -f vendor/modules.txt ]; then echo "ERROR: vendor/modules.txt not found in Source1." >&2 exit 1 fi %build export GOPROXY=off export GOSUMDB=off export GOMODCACHE="$PWD/.gomodcache" # Default `go build` would name the binary after the module's last element # ("runner"); force the upstream/release name with -o. The version variable # matches what upstream's Makefile sets (prefixed with "v"). CGO_ENABLED=0 go build \ -v \ -trimpath \ -mod=vendor \ -modcacherw \ -buildvcs=false \ -ldflags="-s -w -X 'gitea.com/gitea/runner/internal/pkg/ver.version=v%{upstream_version}'" \ -o %{software_name} \ . # Chicken-and-egg: the sample config is produced by the program itself # (`gitea-runner generate-config`, which prints the embedded config.example.yaml). # Generate it here from the freshly built binary so it always tracks the binary's # options. OBS builds natively per-arch, so running the just-compiled binary is fine. ./%{software_name} generate-config > config.yaml.generated %install # Install binary install -Dsm755 %{software_name} -t %{buildroot}%{_bindir} # Install systemd service files (system + user scope) install -Dm644 %{SOURCE2} -t %{buildroot}%{_unitdir} install -Dm644 %{SOURCE4} %{buildroot}%{_userunitdir}/%{software_name}.service # Install sysusers configuration install -Dm644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{software_name}.conf # Place the generated config as the initial /etc/gitea-runner/config.yaml, # marked %%config(noreplace) so local edits survive package upgrades. No separate # .example is shipped: the binary embeds the sample and can reprint it any time # with `gitea-runner generate-config`. install -Dm640 config.yaml.generated %{buildroot}%{_sysconfdir}/%{software_name}/config.yaml # State directory for the runner (.runner registration file lives here). install -d -m750 %{buildroot}%{_sharedstatedir}/%{software_name} %check %pre # Create user/group before files are unpacked, otherwise %%attr falls back to root:root. getent group %{software_name} >/dev/null || groupadd -r %{software_name} getent passwd %{software_name} >/dev/null || \ useradd -r -g %{software_name} -d %{_sharedstatedir}/%{software_name} \ -s /sbin/nologin -c "Gitea Actions runner" %{software_name} %if 0%{?suse_version} %service_add_pre %{software_name}.service %endif %post %if 0%{?suse_version} %service_add_post %{software_name}.service %else %systemd_post %{software_name}.service %endif %preun %if 0%{?suse_version} %service_del_preun %{software_name}.service %else %systemd_preun %{software_name}.service %endif %postun %if 0%{?suse_version} %service_del_postun %{software_name}.service %else %systemd_postun_with_restart %{software_name}.service %endif %files %license LICENSE %doc README.md %{_bindir}/%{software_name} %{_unitdir}/%{software_name}.service %{_userunitdir}/%{software_name}.service %{_sysusersdir}/%{software_name}.conf %dir %{_sysconfdir}/%{software_name} %config(noreplace) %attr(0640,root,%{software_name}) %{_sysconfdir}/%{software_name}/config.yaml %dir %attr(0750,%{software_name},%{software_name}) %{_sharedstatedir}/%{software_name} %changelog