From 6d90e3bd2f6b2a661c91b99c29cf999408982f3a Mon Sep 17 00:00:00 2001 From: Jason Rothstein Date: Mon, 11 May 2026 23:30:59 -0500 Subject: [PATCH] Packaging best practices for Fedora 44+ Signed-off-by: Jason Rothstein --- forgejo.spec | 82 +++++++++++++++++++++++------------------------- forgejo.sysusers | 1 + 2 files changed, 40 insertions(+), 43 deletions(-) create mode 100644 forgejo.sysusers diff --git a/forgejo.spec b/forgejo.spec index e4e2bf8..3aea750 100644 --- a/forgejo.spec +++ b/forgejo.spec @@ -1,49 +1,41 @@ ExclusiveArch: %{go_arches} -%if 0%{?el9} -%global debug_package %{nil} -%endif -%if 0%{?el10} -%global debug_package %{nil} -%endif -%if 0%{?fc42} -%global debug_package %{nil} -%endif -%if 0%{?fc43} -%global debug_package %{nil} -%endif -%if 0%{?fc44} +%if 0${?el8} || 0%{?el9} || 0%{?el10} || 0%{?fc42} || 0%{?fc43} || 0%{?fc44} %global debug_package %{nil} %endif Name: forgejo Version: 11.0.13 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Beyond coding. We forge. License: GPL-3.0-or-later URL: https://forgejo.org/ Source0: https://codeberg.org/%{name}/%{name}/releases/download/v%{version}/%{name}-src-%{version}.tar.gz +Source1: forgejo.sysusers BuildRequires: git +BuildRequires: make BuildRequires: golang >= 1.25.9 BuildRequires: pam-devel -Requires(pre): /usr/bin/getent -Requires(pre): /usr/sbin/useradd +BuildRequires: systemd-rpm-macros +%{?sysusers_requires_compat} Requires: git %description +Forgejo is a self-hosted lightweight software forge. Easy to install and +low maintenance, it just does the job. %prep %setup -q -n %{name}-src-%{version} - +cp %{SOURCE1} . %build sed -i -e 's/-s -w //g' Makefile LDFLAGS="" export LDFLAGS -make \ +%make_build \ TAGS="bindata timetzdata pam sqlite sqlite_unlock_notify" \ FORGEJO_VERSION="%{version}-%{release}" \ build @@ -52,35 +44,36 @@ make \ sed -i \ -e 's|^User=.*$|User=forgejo|g' \ -e 's|^Group=.*$|Group=forgejo|g' \ - -e 's|^WorkingDirectory=.*$|WorkingDirectory=/var/lib/forgejo|g' \ - -e 's|^ExecStart=.*$|ExecStart=%{_bindir}/forgejo web /etc/forgejo/app.ini|g' \ - -e 's|^Environment=.*$|Environment=USER=forgejo HOME=/var/lib/forgejo FORGEJO_WORK_DIR=/var/lib/forgejo|g' \ + -e 's|^WorkingDirectory=.*$|WorkingDirectory=%{_sharedstatedir}/forgejo|g' \ + -e 's|^ExecStart=.*$|ExecStart=%{_bindir}/forgejo web --config %{_sysconfdir}/forgejo/app.ini|g' \ + -e 's|^Environment=.*$|Environment=USER=forgejo HOME=%{_sharedstatedir}/forgejo FORGEJO_WORK_DIR=%{_sharedstatedir}/forgejo|g' \ contrib/systemd/forgejo.service %install -rm -rf %{buildroot} -%{__install} -d %{buildroot}%{_bindir} -%{__install} -d %{buildroot}%{_sysconfdir}/forgejo -%{__install} -d %{buildroot}/usr/lib/systemd/system -%{__install} -d %{buildroot}/var/lib/forgejo -%{__install} -d %{buildroot}/var/log/forgejo -%{__install} -p -m 0755 gitea %{buildroot}%{_bindir}/%{name} -%{__install} -p -m 0644 contrib/systemd/forgejo.service %{buildroot}/usr/lib/systemd/system/forgejo.service +install -d %{buildroot}%{_bindir} +install -d %{buildroot}%{_sysconfdir}/forgejo +install -d %{buildroot}%{_unitdir} +install -d %{buildroot}%{_sysusersdir} +install -d %{buildroot}%{_sharedstatedir}/forgejo +install -d %{buildroot}%{_localstatedir}/log/forgejo +install -p -m 0755 gitea %{buildroot}%{_bindir}/%{name} +install -p -m 0644 contrib/systemd/forgejo.service %{buildroot}%{_unitdir}/forgejo.service +install -p -m 0644 forgejo.sysusers %{buildroot}%{_sysusersdir}/forgejo.conf %pre -getent passwd forgejo > /dev/null 2>&1 || useradd -r -d /var/lib/forgejo -s /bin/bash forgejo - +%sysusers_create_compat forgejo.sysusers %post -if [ -x /usr/bin/systemctl ] -then - systemctl condrestart forgejo -elif [ -x /usr/sbin/service ] -then - service forgejo condrestart -fi +%systemd_post forgejo.service + +%preun +%systemd_preun forgejo.service + +%postun +%systemd_postun_with_restart forgejo.service + %files %license LICENSE @@ -89,14 +82,17 @@ fi %doc DCO %doc README.md %doc RELEASE-NOTES.md -%attr(0700, forgejo, forgejo) %dir /var/lib/forgejo -%attr(0700, forgejo, forgejo) %dir /var/log/forgejo +%attr(0700, forgejo, forgejo) %dir %{_sharedstatedir}/forgejo +%attr(0700, forgejo, forgejo) %dir %{_localstatedir}/log/forgejo %{_bindir}/%{name} -%attr(0644, root, root) /usr/lib/systemd/system/forgejo.service -%attr(-, forgejo, forgejo) %config(noreplace) %{_sysconfdir}/forgejo - +%{_unitdir}/forgejo.service +%{_sysusersdir}/forgejo.conf +%attr(0770, root, forgejo) %dir %{_sysconfdir}/forgejo %changelog +* Mon May 11 2026 Jason Rothstein +- packaging best practices for Fedora 44 + * Wed Apr 29 2026 Jason Rothstein - 11.0.13 diff --git a/forgejo.sysusers b/forgejo.sysusers new file mode 100644 index 0000000..ca045e1 --- /dev/null +++ b/forgejo.sysusers @@ -0,0 +1 @@ +u forgejo - "Forgejo Git Service" /var/lib/forgejo /sbin/nologin \ No newline at end of file