forgejo/forgejo.spec

136 lines
4.8 KiB
RPMSpec
Raw Normal View History

#
# spec file for package forgejo
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define gitea_version 1.21.8
%define forgejo_version 0
Name: forgejo
Version: %{gitea_version}+%{forgejo_version}
Release: 0
Summary: Self-hostable forge
License: MIT
Group: Development/Tools/Version Control
URL: https://forgejo.org
Source0: https://codeberg.org/forgejo/forgejo/releases/download/v%{gitea_version}-%{forgejo_version}/%{name}-src-%{gitea_version}-%{forgejo_version}.tar.gz
Source1: https://codeberg.org/forgejo/forgejo/releases/download/v%{gitea_version}-%{forgejo_version}/%{name}-src-%{gitea_version}-%{forgejo_version}.tar.gz.asc
Source2: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xeb114f5e6c0dc2bcdd183550a4b61a2dc5923710#/forgejo.keyring
Source3: package-lock.json
Source4: node_modules.spec.inc
%include %{_sourcedir}/node_modules.spec.inc
Source5: forgejo.service
Source6: forgejo.sysusers
Source7: apparmor-usr.bin.forgejo
Source99: get-sources.sh
Patch0: custom-app.ini.patch
BuildRequires: golang-packaging
BuildRequires: go >= 1.21
## node >= 20
%if 0%{?suse_version} == 1500
BuildRequires: nodejs-devel-default
BuildRequires: npm-default
%else
BuildRequires: nodejs-packaging
%endif
BuildRequires: local-npm-registry
BuildRequires: make
BuildRequires: systemd-rpm-macros
BuildRequires: sysuser-tools
BuildRequires: apparmor-abstractions
BuildRequires: apparmor-parser
BuildRequires: apparmor-rpm-macros
Requires: git-core
Requires: git-lfs
Requires: (%{name}-apparmor if apparmor)
Requires(pre): shadow
%{systemd_requires}
%{sysusers_requires}
%package apparmor
Summary: Apparmor profile for %{name}
Supplements: (%{name} and apparmor)
Requires: apparmor
Recommends: apparmor-abstractions
%description apparmor
This package includes the apparmor profile for %{name}
%description
Providing Git hosting for your project, friends, company or community? Forgejo (/for'd͡ʒe.jo/ inspired by forĝejo
the Esperanto word for forge) has you covered with its intuitive interface, light and easy hosting and a lot of builtin functionality.
%prep
%autosetup -p1 -n %{name}-src-%{gitea_version}-%{forgejo_version}
local-npm-registry %{_sourcedir} install --also=dev
%build
%sysusers_generate_pre %{SOURCE6} %{name} %{name}.conf
export EXTRA_GOFLAGS="-buildmode=pie -mod=vendor"
export TAGS="bindata timetzdata sqlite sqlite_unlock_notify"
%{make_build}
%install
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_sysconfdir}/apparmor.d
install -d %{buildroot}%{_datadir}/forgejo
install -d %{buildroot}%{_datadir}/forgejo/{conf,https,mailer}
ln -s %{name} %{buildroot}%{_bindir}/gitea
install -d %{buildroot}%{_sharedstatedir}/%{name}/{data,https,indexers,queues,repositories}
install -d %{buildroot}%{_sysconfdir}/%{name}
install -d %{buildroot}%{_localstatedir}/log/%{name}
install -D -m 0644 %{_builddir}/%{name}-src-%{gitea_version}-%{forgejo_version}/custom/conf/app.example.ini %{buildroot}%{_sysconfdir}/%{name}/conf/app.ini
install -D -m 0755 %{_builddir}/%{name}-src-%{gitea_version}-%{forgejo_version}/gitea %{buildroot}%{_bindir}/forgejo
install -D -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/forgejo.service
install -D -m 0644 %{SOURCE6} %{buildroot}%{_sysusersdir}/%{name}.conf
install -m 0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/apparmor.d/usr.bin.forgejo
%pre -f %{name}.pre
%service_add_pre forgejo.service
%post
%service_add_post forgejo.service
%apparmor_reload %{_sysconfdir}/apparmor.d/usr.bin.forgejo
%preun
%service_del_preun forgejo.service
%postun
%service_del_postun forgejo.service
%check
#right now broken, see https://github.com/openSUSE/obs-service-node_modules/issues/22
#make test
%files
%license LICENSE
%doc CHANGELOG.md README.md RELEASE-NOTES.md CONTRIBUTING.md
%{_unitdir}/%{name}.service
%{_bindir}/%{name}
%{_bindir}/gitea
%defattr(0660,root,forgejo,770)
%config(noreplace) %{_sysconfdir}/%{name}/conf/app.ini
%{_sysconfdir}/%{name}
%{_localstatedir}/log/%{name}
%defattr(0660,forgejo,forgejo,750)
%{_datadir}/forgejo
%{_sharedstatedir}/%{name}
%{_sysusersdir}/%{name}.conf
%files apparmor
%config %{_sysconfdir}/apparmor.d/usr.bin.forgejo
%changelog