From 9ab87693199de7484d2801436d51395daa84d07e Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 10 Aug 2024 00:26:16 -0400 Subject: [PATCH] backports/forgejo-runner: new aport --- backports/forgejo-runner/APKBUILD | 47 +++++++++++++++++++ backports/forgejo-runner/forgejo-runner.confd | 17 +++++++ backports/forgejo-runner/forgejo-runner.initd | 38 +++++++++++++++ .../forgejo-runner/forgejo-runner.logrotate | 5 ++ .../forgejo-runner/forgejo-runner.pre-install | 14 ++++++ .../forgejo-runner/forgejo-runner.pre-upgrade | 1 + 6 files changed, 122 insertions(+) create mode 100644 backports/forgejo-runner/APKBUILD create mode 100644 backports/forgejo-runner/forgejo-runner.confd create mode 100644 backports/forgejo-runner/forgejo-runner.initd create mode 100644 backports/forgejo-runner/forgejo-runner.logrotate create mode 100644 backports/forgejo-runner/forgejo-runner.pre-install create mode 120000 backports/forgejo-runner/forgejo-runner.pre-upgrade diff --git a/backports/forgejo-runner/APKBUILD b/backports/forgejo-runner/APKBUILD new file mode 100644 index 0000000..1005964 --- /dev/null +++ b/backports/forgejo-runner/APKBUILD @@ -0,0 +1,47 @@ +# Contributor: Patrycja Rosa +# Maintainer: Patrycja Rosa +pkgname=forgejo-runner +pkgver=3.5.0 +pkgrel=2 +pkgdesc="CI/CD job runner for Forgejo" +url="https://code.forgejo.org/forgejo/runner" +arch="all" +license="MIT" +makedepends="go" +install="$pkgname.pre-install $pkgname.pre-upgrade" +subpackages="$pkgname-openrc" +source="$pkgname-$pkgver.tar.gz::https://code.forgejo.org/forgejo/runner/archive/v$pkgver.tar.gz + + forgejo-runner.logrotate + forgejo-runner.initd + forgejo-runner.confd + " +builddir="$srcdir/runner" +options="!check" # tests require running forgejo + +build() { + go build \ + -o forgejo-runner \ + -ldflags "-X gitea.com/gitea/act_runner/internal/pkg/ver.version=$pkgver" + ./forgejo-runner generate-config > config.example.yaml +} + +check() { + go test ./... +} + +package() { + install -Dm755 forgejo-runner -t "$pkgdir"/usr/bin/ + install -Dm644 config.example.yaml -t "$pkgdir"/etc/forgejo-runner/ + + install -Dm755 "$srcdir"/forgejo-runner.initd "$pkgdir"/etc/init.d/forgejo-runner + install -Dm644 "$srcdir"/forgejo-runner.confd "$pkgdir"/etc/conf.d/forgejo-runner + install -Dm644 "$srcdir"/forgejo-runner.logrotate "$pkgdir"/etc/logrotate.d/forgejo-runner +} + +sha512sums=" +e78968a5f9b6e797fb759a5c8cbf46a5c2fef2083dabc88599c9017729faface963576c63a948b0add424cb267902e864fb1a1b619202660296976d93e670713 forgejo-runner-3.5.0.tar.gz +a3c7238b0c63053325d31e09277edd88690ef5260854517f82d9042d6173fb5d24ebfe36e1d7363673dd8801972638a6e69b6af8ad43debb6057515c73655236 forgejo-runner.logrotate +bb0c6fbe90109c77f9ef9cb0d35d20b8033be0e4b7a60839b596aa5528dfa24309ec894d8c04066bf8fb30143e63a5fd8cc6fc89aac364422b583e0f840e2da6 forgejo-runner.initd +e11eab27f88f1181112389befa7de3aa0bac7c26841861918707ede53335535425c805e6682e25704e9c8a6aecba3dc13e20900a99df1183762b012b62f26d5f forgejo-runner.confd +" diff --git a/backports/forgejo-runner/forgejo-runner.confd b/backports/forgejo-runner/forgejo-runner.confd new file mode 100644 index 0000000..874e695 --- /dev/null +++ b/backports/forgejo-runner/forgejo-runner.confd @@ -0,0 +1,17 @@ +# Configuration for /etc/init.d/forgejo-runner + +# Path to the config file (--config). +#cfgfile="/etc/forgejo-runner/config.yaml" + +# Path to the working directory (--working-directory). +#datadir="/var/lib/forgejo-runner" + +# Path to the log file where stdout/stderr will be redirected. +# Leave empty/commented out to use syslog instead. +#output_log="/var/log/forgejo-runner.log" + +# You may change this to root, e.g. to run jobs in LXC +#command_user="forgejo-runner" + +# Comment out to run without process supervisor. +supervisor=supervise-daemon diff --git a/backports/forgejo-runner/forgejo-runner.initd b/backports/forgejo-runner/forgejo-runner.initd new file mode 100644 index 0000000..c54acdd --- /dev/null +++ b/backports/forgejo-runner/forgejo-runner.initd @@ -0,0 +1,38 @@ +#!/sbin/openrc-run + +description="Forgejo CI Runner" +name="Forgejo Runner" + +: ${cfgfile:="/etc/forgejo-runner/config.yaml"} +: ${datadir:="/var/lib/forgejo-runner"} +: ${command_user:="forgejo-runner"} + +command="/usr/bin/forgejo-runner" +command_args="daemon --config $cfgfile" +command_background="yes" +directory="$datadir" +pidfile="/run/$RC_SVCNAME.pid" + +depend() { + need net + use dns logger +} + +start_pre() { + checkpath -d -o "$command_user" /etc/forgejo-runner + checkpath -d -o "$command_user" "$datadir" + + if ! [ -e "$cfgfile" ]; then + eerror "Config file $cfgfile doesn't exist." + eerror "You can generate it with: forgejo-runner generate-config," + eerror "or use the auto-generated one in /etc/forgejo-runner/config.example.yaml" + return 1 + fi + + if [ "$error_log" ]; then + output_log="$error_log" + else + output_logger="logger -t '${RC_SVCNAME}' -p daemon.info" + error_logger="logger -t '${RC_SVCNAME}' -p daemon.error" + fi +} diff --git a/backports/forgejo-runner/forgejo-runner.logrotate b/backports/forgejo-runner/forgejo-runner.logrotate new file mode 100644 index 0000000..1a0539e --- /dev/null +++ b/backports/forgejo-runner/forgejo-runner.logrotate @@ -0,0 +1,5 @@ +/var/log/forgejo-runner.log { + copytruncate + missingok + notifempty +} diff --git a/backports/forgejo-runner/forgejo-runner.pre-install b/backports/forgejo-runner/forgejo-runner.pre-install new file mode 100644 index 0000000..5ce27be --- /dev/null +++ b/backports/forgejo-runner/forgejo-runner.pre-install @@ -0,0 +1,14 @@ +#!/bin/sh + +addgroup -S forgejo-runner 2>/dev/null +adduser -S -D -H -h /var/lib/forgejo-runner -s /sbin/nologin -G forgejo-runner -g forgejo-runner forgejo-runner 2>/dev/null + +cat >&2 <