ergo-rpm/ergo.spec

205 lines
5.8 KiB
RPMSpec
Raw Normal View History

#
# spec file for package ergo
#
# Copyright (c) 2021 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/
#
2021-06-04 11:47:59 +02:00
%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
%global provider_prefix github.com/ergochat/ergo
%global import_path %{provider_prefix}
# Make go-rpm-macros happy!
%if 0%{?fedora}
%global goipath github.com/ergochat/ergo
%global debug_package %{nil}
%endif
Name: ergo
Version: 2.9.1
Release: 0
Summary: IRCv3 Server
License: MIT
Group: Productivity/Networking/IRC
URL: https://oragono.io
#Original source:
#https://github.com/ergochat/ergo/tree/master
#Modified source (custom ircd.yaml configuration and systemd unit file):
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Patch0: default.yaml.patch
Patch1: ergo.service.patch
# Dependencies for openSUSE:
%if 0%{?suse_version}
BuildRequires: fdupes
BuildRequires: go >= 1.18
BuildRequires: golang-packaging
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
Requires(pre): %{_bindir}/getent
Requires(pre): %{_sbindir}/useradd
%endif
# Dependencies for Fedora:
%if 0%{?fedora}
BuildRequires: fdupes
BuildRequires: go-rpm-macros
BuildRequires: golang >= 1.17
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
Requires(pre): %{_bindir}/getent
Requires(pre): %{_sbindir}/useradd
%endif
2021-06-04 11:47:59 +02:00
# Okay openSUSE, let's stretch first!
%if 0%{?suse_version}
%{go_nostrip}
%{go_provides}
%endif
# Come on Fedora, you go along!
%if 0%{?fedora}
%gopkg
%endif
%description
Ergo is a modern IRC server written in Go.
2021-06-04 11:47:59 +02:00
#A pretty cool one, that is!
%pre
# Introducing Ms. Oragono!
%{_bindir}/getent group ergo || %{_sbindir}/groupadd -r ergo
%{_bindir}/getent passwd ergo || %{_sbindir}/useradd -r -g ergo -d %{_sysconfdir}/ergo -s /sbin/nologin ergo
2021-06-04 11:47:59 +02:00
%if 0%{?suse_version}
%service_add_pre ergo.service
%endif
%prep
# Alright openSUSE, here we go!
%setup -q
2021-06-04 11:47:59 +02:00
%patch0 -p1
%patch1 -p1
2021-06-04 11:47:59 +02:00
# Oh Fedora, you having bit of an headstart, eh?
%if 0%{?fedora}
%goprep
%endif
%setup -q -T -D -a 1
%build
export GOFLAGS="-mod=vendor"
# "I'm prepping too now!! Don't rush me!", shouts openSUSE
%if 0%{?suse_version}
%goprep %{import_path}
%gobuild .
%endif
# S'ok! I've got some extra work here...
%if 0%{?fedora}
rm -rf "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
ln -s "%{_builddir}/%{name}-%{version}" "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
%gobuild -o %{gobuilddir}/bin/%{name} %{goipath}/irc
%endif
%install
# And.. installaction!
%if 0%{?suse_version}
%goinstall
%gosrc
%endif
# "Lame", moans Fedora, "I'm lifting some extra weights, not use some weird macro for my copyjobs!"
%if 0%{?fedora}
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
%endif
# However after a short fight between the two, they continue doing some tasks in common, and achieve great teamwork.
install -d -m 700 %{buildroot}%{_sysconfdir}/%{name}
install -d -m 700 %{buildroot}%{_sharedstatedir}/%{name}
install -D -m 600 %{_builddir}/%{name}-%{version}/default.yaml %{buildroot}%{_sysconfdir}/%{name}/ircd.yaml
install -D -m 644 %{_builddir}/%{name}-%{version}/distrib/systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
2021-06-04 11:47:59 +02:00
install -d -m 755 %{buildroot}%{_sbindir}
#ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
2021-06-04 11:47:59 +02:00
%check
# Let's see who made their job well...
%if 0%{?suse_version}
%gotest %{import_path}
%endif
%if 0%{?fedora}
%gocheck
%endif
# Alright, time to sum things up!!
# "Hah, I have a nice filelist ready to go!"
%if 0%{?suse_version}
%gofilelist
2021-06-04 11:47:59 +02:00
%files -f file.lst
%endif
# "Says the one WHO NEEDS a filelist!"
%if 0%{?fedora}
%files
%endif
%license LICENSE
%doc README.md
%attr(750,ergo,ergo) %{_bindir}/%{name}
%dir %attr (700,ergo,ergo) %{_sysconfdir}/%{name}
%dir %attr (700,ergo,ergo) %{_sharedstatedir}/%{name}
2021-06-04 11:47:59 +02:00
%attr (-,ergo,ergo) %config(noreplace) %{_sysconfdir}/%{name}/ircd.yaml
%{_unitdir}/%{name}.service
#%{_sbindir}/rc%{name}
2021-06-04 11:47:59 +02:00
%post
# Some finishing touches, Fedora and openSUSE walk hand in hand, through filesystem's wonderland!
%if 0%{?suse_version}
%service_add_post ergo.service
%endif
%if 0%{?fedora}
%systemd_post ergo.service
%endif
install -d -o ergo -g ergo -m 700 %{_sysconfdir}/ssl/ergo
2021-06-04 11:47:59 +02:00
%{_bindir}/%{name} mkcerts --conf %{_sysconfdir}/%{name}/ircd.yaml || true
%{_bindir}/%{name} initdb --conf %{_sysconfdir}/%{name}/ircd.yaml || true
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/crt
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/key
chown ergo:ergo %{_sharedstatedir}/%{name}/ircd.db
chmod 600 %{_sharedstatedir}/%{name}/ircd.db
2021-06-04 11:47:59 +02:00
# Nice! All the distros cheer in excitement about the newly installed package!
echo "Welcome to Ergo!"
echo "To enable the service (auto-start): sudo systemctl enable ergo"
echo "To start the service now: sudo systemctl start ergo"
echo "The configuration is located in %{_sysconfdir}/ergo/ircd.yaml"
2021-06-04 11:47:59 +02:00
%preun
%if 0%{?suse_version}
%service_del_preun ergo.service
%endif
%if 0%{?fedora}
%systemd_preun ergo.service
%endif
%postun
#%if 0%{?suse_version}
#%service_del_postun_without_restart ergo.service
#%endif
%if 0%{?fedora}
%systemd_postun ergo.service
%endif
echo "NOTE - The ergo.service does NOT restart automatically."
# Rants from some h00man
%changelog