File nohang.spec of Package nohang
#
# spec file for nohang
# Based on spec file contributed upstream and released under MIT License
#
# Copyright (c) 2019 Artem Polishchuk <ego.cordatus@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
%global shortcommit 953b41a
Name: nohang
Version: 0.2.0
Release: 0
Summary: Sophisticated low memory handler
License: MIT
URL: https://github.com/hakavlad/nohang
Source0: %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: unzip
BuildRequires: systemd-rpm-macros
Requires: logrotate
Recommends: %{name}-desktop
%{?systemd_requires}
%description
Nohang is a highly configurable daemon for Linux which is able to correctly
prevent out of memory (OOM) and keep system responsiveness in low
memory conditions.
To enable and start:
systemctl enable --now %{name}
%package desktop
Summary: Desktop version of %{name}
BuildArch: noarch
Requires: %{name} = %{version}
Requires: libnotify
%description desktop
Desktop version of %{name}.
%prep
%autosetup -p1
# Corrects version as well as including README & CHANGELOG files
sed -i '
s|-git describe.* >|echo "v%{version}-0-g%{shortcommit}" >|;
s|chcon -t.*|true|;
s|systemctl.*|true|;
s|.*README.md.*||;
s|.*CHANGELOG.md.*||;
' \
Makefile
%build
# not required
%install
%make_install BINDIR=%{_bindir} PREFIX=%{_prefix} MANDIR=%{_mandir} \
SYSCONFDIR=%{_sysconfdir} SYSTEMDUNITDIR=%{_unitdir}
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun_with_restart %{name}.service
### Desktop
%post desktop
%systemd_post %{name}-desktop.service
%preun desktop
%systemd_preun %{name}-desktop.service
%postun desktop
%systemd_postun_with_restart %{name}-desktop.service
%files
%license LICENSE
%doc README.md CHANGELOG.md
%{_sbindir}/%{name}
%{_bindir}/oom-sort
%{_bindir}/psi-top
%{_bindir}/psi2log
%{_mandir}/man1/*
%{_mandir}/man8/*
%{_datadir}/%{name}/version
%{_sysconfdir}/logrotate.d/%{name}
%{_unitdir}/%{name}.service
%dir %{_sysconfdir}/%{name}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/%{name}.conf
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%files desktop
%{_unitdir}/%{name}-desktop.service
%{_datadir}/%{name}/%{name}-desktop.conf
%config(noreplace) %{_sysconfdir}/%{name}/%{name}-desktop.conf
%changelog