Productionize
- Remove superfluous comments - Adjust permissions - Improve post-hooks Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
ffd9f04249
commit
3505aad592
74
ergo.spec
74
ergo.spec
@ -19,7 +19,6 @@
|
|||||||
%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
|
%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
|
||||||
%global provider_prefix github.com/ergochat/ergo
|
%global provider_prefix github.com/ergochat/ergo
|
||||||
%global import_path %{provider_prefix}
|
%global import_path %{provider_prefix}
|
||||||
# Make go-rpm-macros happy!
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%global goipath github.com/ergochat/ergo
|
%global goipath github.com/ergochat/ergo
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
@ -30,7 +29,7 @@ Release: 0
|
|||||||
Summary: IRCv3 Server
|
Summary: IRCv3 Server
|
||||||
License: MIT
|
License: MIT
|
||||||
Group: Productivity/Networking/IRC
|
Group: Productivity/Networking/IRC
|
||||||
URL: https://oragono.io
|
URL: https://ergo.chat/
|
||||||
#Original source:
|
#Original source:
|
||||||
#https://github.com/ergochat/ergo/tree/master
|
#https://github.com/ergochat/ergo/tree/master
|
||||||
#Modified source (custom ircd.yaml configuration and systemd unit file):
|
#Modified source (custom ircd.yaml configuration and systemd unit file):
|
||||||
@ -38,7 +37,7 @@ Source0: %{name}-%{version}.tar.gz
|
|||||||
Source1: vendor.tar.gz
|
Source1: vendor.tar.gz
|
||||||
Patch0: default.yaml.patch
|
Patch0: default.yaml.patch
|
||||||
Patch1: ergo.service.patch
|
Patch1: ergo.service.patch
|
||||||
# Dependencies for openSUSE:
|
# Dependencies for openSUSE and SLES:
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: go >= 1.18
|
BuildRequires: go >= 1.18
|
||||||
@ -58,36 +57,30 @@ BuildRequires: systemd-rpm-macros
|
|||||||
Requires(pre): %{_bindir}/getent
|
Requires(pre): %{_bindir}/getent
|
||||||
Requires(pre): %{_sbindir}/useradd
|
Requires(pre): %{_sbindir}/useradd
|
||||||
%endif
|
%endif
|
||||||
# Okay openSUSE, let's stretch first!
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%{go_nostrip}
|
%{go_nostrip}
|
||||||
%{go_provides}
|
%{go_provides}
|
||||||
%endif
|
%endif
|
||||||
# Come on Fedora, you go along!
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%gopkg
|
%gopkg
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Ergo is a modern IRC server written in Go.
|
Ergo is a modern IRC server written in Go.
|
||||||
#A pretty cool one, that is!
|
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
# Introducing Ms. Oragono!
|
%{_bindir}/getent group ergo > /dev/null || %{_sbindir}/groupadd -r ergo
|
||||||
%{_bindir}/getent group ergo || %{_sbindir}/groupadd -r ergo
|
%{_bindir}/getent passwd ergo > /dev/null || %{_sbindir}/useradd -r -g ergo -d %{_sysconfdir}/ergo -s /sbin/nologin ergo
|
||||||
%{_bindir}/getent passwd ergo || %{_sbindir}/useradd -r -g ergo -d %{_sysconfdir}/ergo -s /sbin/nologin ergo
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%service_add_pre ergo.service
|
%service_add_pre ergo.service
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
# Alright openSUSE, here we go!
|
|
||||||
%setup -q
|
%setup -q
|
||||||
|
|
||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
|
|
||||||
# Oh Fedora, you having bit of an headstart, eh?
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%goprep
|
%goprep
|
||||||
%endif
|
%endif
|
||||||
@ -95,13 +88,11 @@ Ergo is a modern IRC server written in Go.
|
|||||||
|
|
||||||
%build
|
%build
|
||||||
export GOFLAGS="-mod=vendor"
|
export GOFLAGS="-mod=vendor"
|
||||||
# "I'm prepping too now!! Don't rush me!", shouts openSUSE
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%goprep %{import_path}
|
%goprep %{import_path}
|
||||||
%gobuild .
|
%gobuild .
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# S'ok! I've got some extra work here...
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
rm -rf "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
|
rm -rf "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
|
||||||
ln -s "%{_builddir}/%{name}-%{version}" "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
|
ln -s "%{_builddir}/%{name}-%{version}" "%{_builddir}/%{extractdir0}/_build/src/github.com/ergochat/ergo"
|
||||||
@ -109,28 +100,23 @@ ln -s "%{_builddir}/%{name}-%{version}" "%{_builddir}/%{extractdir0}/_build/src/
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%install
|
%install
|
||||||
# And.. installaction!
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%goinstall
|
%goinstall
|
||||||
%gosrc
|
%gosrc
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# "Lame", moans Fedora, "I'm lifting some extra weights, not use some weird macro for my copyjobs!"
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
install -m 0755 -vd %{buildroot}%{_bindir}
|
install -m 0755 -vd %{buildroot}%{_bindir}
|
||||||
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
|
install -m 0755 -vp %{gobuilddir}/bin/%{name} %{buildroot}%{_bindir}/
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# However after a short fight between the two, they continue doing some tasks in common, and achieve great teamwork.
|
install -d -m 755 %{buildroot}%{_sysconfdir}/%{name}
|
||||||
install -d -m 700 %{buildroot}%{_sysconfdir}/%{name}
|
|
||||||
install -d -m 700 %{buildroot}%{_sharedstatedir}/%{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 660 %{_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
|
install -D -m 644 %{_builddir}/%{name}-%{version}/distrib/systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
|
||||||
install -d -m 755 %{buildroot}%{_sbindir}
|
install -d -m 755 %{buildroot}%{_sbindir}
|
||||||
#ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
|
|
||||||
|
|
||||||
%check
|
%check
|
||||||
# Let's see who made their job well...
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%gotest %{import_path}
|
%gotest %{import_path}
|
||||||
%endif
|
%endif
|
||||||
@ -139,49 +125,63 @@ install -d -m 755 %{buildroot}%{_sbindir}
|
|||||||
%gocheck
|
%gocheck
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# Alright, time to sum things up!!
|
|
||||||
|
|
||||||
# "Hah, I have a nice filelist ready to go!"
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%gofilelist
|
%gofilelist
|
||||||
|
|
||||||
%files -f file.lst
|
%files -f file.lst
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# "Says the one WHO NEEDS a filelist!"
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%files
|
%files
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%doc README.md
|
%doc README.md
|
||||||
%attr(750,ergo,ergo) %{_bindir}/%{name}
|
%attr(755,ergo,ergo) %{_bindir}/%{name}
|
||||||
%dir %attr (700,ergo,ergo) %{_sysconfdir}/%{name}
|
%dir %attr (755,ergo,ergo) %{_sysconfdir}/%{name}
|
||||||
%dir %attr (700,ergo,ergo) %{_sharedstatedir}/%{name}
|
%dir %attr (700,ergo,ergo) %{_sharedstatedir}/%{name}
|
||||||
%attr (-,ergo,ergo) %config(noreplace) %{_sysconfdir}/%{name}/ircd.yaml
|
%attr (-,ergo,ergo) %config(noreplace) %{_sysconfdir}/%{name}/ircd.yaml
|
||||||
%{_unitdir}/%{name}.service
|
%{_unitdir}/%{name}.service
|
||||||
#%{_sbindir}/rc%{name}
|
|
||||||
|
|
||||||
%post
|
%post
|
||||||
# Some finishing touches, Fedora and openSUSE walk hand in hand, through filesystem's wonderland!
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%service_add_post ergo.service
|
%service_add_post ergo.service
|
||||||
%endif
|
%endif
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%systemd_post ergo.service
|
%systemd_post ergo.service
|
||||||
%endif
|
%endif
|
||||||
install -d -o ergo -g ergo -m 700 %{_sysconfdir}/ssl/ergo
|
install -d -o ergo -g ergo -m 750 %{_sysconfdir}/ssl/ergo
|
||||||
%{_bindir}/%{name} mkcerts --conf %{_sysconfdir}/%{name}/ircd.yaml || true
|
if [ $1 -eq 1 ]
|
||||||
%{_bindir}/%{name} initdb --conf %{_sysconfdir}/%{name}/ircd.yaml || true
|
then
|
||||||
|
if %{_bindir}/%{name} mkcerts --conf %{_sysconfdir}/%{name}/ircd.yaml --quiet
|
||||||
|
then
|
||||||
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/crt
|
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/crt
|
||||||
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/key
|
chown ergo:ergo %{_sysconfdir}/ssl/%{name}/key
|
||||||
|
echo "Generated a self signed certificate. Please replace /etc/ssl/%{name}/crt and /etc/ssl/%{name}/key for production use."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f %{_sharedstatedir}/%{name}/ircd.db ]
|
||||||
|
then
|
||||||
|
%{_bindir}/%{name} upgradedb --conf %{_sysconfdir}/%{name}/ircd.yaml
|
||||||
|
fi
|
||||||
|
if [ ! -f %{_sharedstatedir}/%{name}/ircd.db ]
|
||||||
|
then
|
||||||
|
if %{_bindir}/%{name} initdb --conf %{_sysconfdir}/%{name}/ircd.yaml --quiet
|
||||||
|
then
|
||||||
chown ergo:ergo %{_sharedstatedir}/%{name}/ircd.db
|
chown ergo:ergo %{_sharedstatedir}/%{name}/ircd.db
|
||||||
chmod 600 %{_sharedstatedir}/%{name}/ircd.db
|
chmod 600 %{_sharedstatedir}/%{name}/ircd.db
|
||||||
# Nice! All the distros cheer in excitement about the newly installed package!
|
fi
|
||||||
|
fi
|
||||||
|
if [ $1 -eq 1 ]
|
||||||
|
then
|
||||||
echo "Welcome to Ergo!"
|
echo "Welcome to Ergo!"
|
||||||
echo "To enable the service (auto-start): sudo systemctl enable ergo"
|
echo "To enable the service (auto-start): \`sudo systemctl enable ergo\`"
|
||||||
echo "To start the service now: sudo systemctl start ergo"
|
echo "To start the service now: \`sudo systemctl start ergo\`"
|
||||||
echo "The configuration is located in %{_sysconfdir}/ergo/ircd.yaml"
|
echo "The configuration is located in %{_sysconfdir}/ergo/ircd.yaml"
|
||||||
|
fi
|
||||||
|
if [ $1 -eq 2 ]
|
||||||
|
then
|
||||||
|
echo "Restart IRC daemon using \`systemctl restart ergo\` to complete upgrade."
|
||||||
|
fi
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
@ -198,7 +198,5 @@ echo "The configuration is located in %{_sysconfdir}/ergo/ircd.yaml"
|
|||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%systemd_postun ergo.service
|
%systemd_postun ergo.service
|
||||||
%endif
|
%endif
|
||||||
echo "NOTE - The ergo.service does NOT restart automatically."
|
|
||||||
|
|
||||||
# Rants from some h00man
|
|
||||||
%changelog
|
%changelog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user