# spec from Gary T. Giesen <ggiesen@giesen.me> from COPR
# Do not try to package empty debug_package
%global debug_package %{nil}

Name:		gitea
Version:	1.22.4
Release:	1%{?dist}
Summary:	Gitea is a painless self-hosted Git service

License:	MIT
URL:		https://gitea.io
Source0:	https://github.com/go-gitea/gitea/archive/v%{version}.tar.gz
Source1:	app.ini
Source2:	gitea.service
Source3:	gitea.conf

BuildRequires:	golang >= 1.22
BuildRequires:	nodejs >= 1:18
BuildRequires:	npm
BuildRequires:	sqlite-devel
BuildRequires:	pam-devel
BuildRequires:	systemd
BuildRequires:	git

Requires:	git

%description
Gitea is a painless self-hosted Git service written in Go

%prep
%setup -q  -n %{name}-%{version}

%build
TAGS="bindata sqlite sqlite_unlock_notify" make build

%install
%{__rm} -rf %{buildroot}
install -d -m 0755 %{buildroot}%{_bindir}
install -m 755 gitea %{buildroot}%{_bindir}/%{name}
install -d -m 0755 %{buildroot}%{_datarootdir}/%{name}
install -m 664 custom/conf/app.example.ini %{buildroot}%{_datarootdir}/%{name}/app.example.ini
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}
install -m 660 %{SOURCE1}  %{buildroot}%{_sysconfdir}/%{name}/app.ini
install -d -m 0755 %{buildroot}/%{_unitdir}
install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -d -m 0755 %{buildroot}%{_sysconfdir}/sysconfig
install -m 0664 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name}
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}

%clean
%{__rm} -rf %{buildroot}

%pre
getent group %{name} > /dev/null || groupadd -r %{name}
getent passwd %{name} > /dev/null || \
	useradd -r -g %{name} -s /bin/bash \
	-d %{_sharedstatedir}/%{name} \
	-c "Gitea git account" %{name}

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun %{name}.service

%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_datarootdir}/%{name}/app.example.ini
%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%attr(0664,%{name},%{name}) %config(noreplace) %{_sysconfdir}/%{name}/app.ini
%attr(0755,%{name},%{name}) %dir %{_localstatedir}/log/%{name}
%attr(0755,%{name},%{name}) %dir %{_sharedstatedir}/%{name}

%changelog
* Fri Dec 6 2024 voidanix <voidanix@keyedlimepie.org> 1.22.4-1
- Update to 1.22.4

* Sun Mar 24 2024 voidanix <voidanix@keyedlimepie.org> 1.21.9-1
- Update to 1.21.9

* Wed May 3 2023 voidanix <voidanix@keyedlimepie.org> 1.19.3-1
- Update to 1.19.3

* Wed May 3 2023 voidanix <voidanix@keyedlimepie.org> 1.19.2-1
- Update to 1.19.2
- Bump golang requirement to 1.19

* Wed Oct 19 2022 voidanix <voidanix@keyedlimepie.org> 1.17.3-1
- Update to 1.17.3
- Bump golang and nodejs requirements

* Sat May 14 2022 voidanix <voidanix@keyedlimepie.org> 1.16.7-1
- Update to 1.16.7

* Sun Apr 24 2022 voidanix <voidanix@keyedlimepie.org> 1.16.6-1
- Update to 1.16.6

* Sun Nov 28 2021 voidanix <voidanix@keyedlimepie.org> 1.15.6-1
- Update to 1.15.6
- Add npm (nodejs subpackage) as dependency

* Sun Oct 10 2021 voidanix <voidanix@keyedlimepie.org> 1.15.4-1
- Update to 1.15.4
- Bump golang and nodejs requirements

* Sun Jul 4 2021 voidanix <voidanix@keyedlimepie.org> 1.14.3-1
- Update to 1.14.3

* Fri May 28 2021 voidanix <voidanix@keyedlimepie.org> 1.14.2-1
- Update to 1.14.2

* Wed Mar 31 2021 voidanix <voidanix@keyedlimepie.org> 1.13.6-1
- Update to 1.13.6

* Sat Mar 13 2021 voidanix <voidanix@keyedlimepie.org> 1.13.4-1
- Update to 1.13.4

* Thu Mar 4 2021 voidanix <voidanix@keyedlimepie.org> 1.13.3-1
- Update to 1.13.3

* Sat Feb 13 2021 voidanix <voidanix@keyedlimepie.org> 1.13.2-1
- Initial build