%global debug_package %{nil}
%global build_ldflags %{nil}

Name: forgejo-lts
Version: 7.0.14
Release: 1%{?dist}
Summary: Beyond coding, we forge
License: MIT
URL: https://codeberg.org/forgejo/forgejo
Source0: %{URL}/releases/download/v%{version}/forgejo-src-%{version}.tar.gz

BuildRequires: golang
BuildRequires: nodejs
BuildRequires: make
Requires: git
Requires: git-lfs

%description
Forgejo is a self-hosted lightweight software forge. Easy to install and low
maintenance, it just does the job.

%prep
%setup -q -n forgejo-src-%{version}

%build
TAGS="bindata timetzdata sqlite sqlite_unlock_notify" make build

%install
install -Dm755 gitea --target-directory %{buildroot}%{_bindir}
install -Dm644 contrib/systemd/forgejo.service --target-directory %{buildroot}%{_prefix}/lib/systemd/system
mv %{buildroot}%{_bindir}/gitea %{buildroot}%{_bindir}/forgejo

%post
groupadd --system git
useradd --system --shell /sbin/nologin --comment "Git Version Control" --gid git -M git
passwd --delete --lock git

%postun
# uninstall only
if [ $1 == 0 ]; then
    systemctl stop forgejo
    groupdel git
    userdel -r git
fi

%files
%license LICENSE
%{_prefix}/lib/systemd/system/forgejo.service
%{_bindir}/forgejo

%changelog