forked from pool/earlyoom
- Refreshed spec-file via spec-cleaner and manual optimizated. * Reduced to the standard github URL. * Added -p flag to all install commands. - Updated file earlyoom.sysconfig with actual firefox process names. - Updated to 1.7 * Updated file earlyoom.1 (MANPAGE.md -s -t man > earlyoom.1). * https://github.com/rfjakob/earlyoom#changelog * Added -N flag to run a script every time a process is killed. * Added -g flag to kill whole process group. * Removed -i flag, it does not work properly on Linux kernels 5.9+. * Droped ambient capabilities on startup. OBS-URL: https://build.opensuse.org/request/show/977983 OBS-URL: https://build.opensuse.org/package/show/Base:System/earlyoom?expand=0&rev=37
107 lines
3.1 KiB
RPMSpec
107 lines
3.1 KiB
RPMSpec
#
|
|
# spec file for package earlyoom
|
|
#
|
|
# Copyright (c) 2022 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/
|
|
#
|
|
|
|
|
|
# the tests are quite flaky in a VM
|
|
%bcond_with tests
|
|
%if ! 0%{?_fillupdir:1}
|
|
%global _fillupdir %{_localstatedir}/adm/fillup-templates
|
|
%endif
|
|
Name: earlyoom
|
|
Version: 1.7
|
|
Release: 0
|
|
Summary: Early OOM Daemon for Linux
|
|
License: MIT
|
|
Group: System/Daemons
|
|
URL: https://github.com/rfjakob/%{name}
|
|
Source0: https://github.com/rfjakob/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
|
Source1: %{name}.sysconfig
|
|
# Inject pre-build earlyoom.1, built on x86_64 machine, as pandoc does not exist on all archs
|
|
Source2: earlyoom.1
|
|
BuildRequires: pkgconfig
|
|
BuildRequires: pkgconfig(systemd)
|
|
Conflicts: oomd
|
|
%if %{with tests}
|
|
BuildRequires: go
|
|
%endif
|
|
|
|
%description
|
|
earlyoom checks the amount of available memory and free swap, and if both are
|
|
below critical level, it will kill the largest process (highest oom_score).
|
|
|
|
%prep
|
|
%autosetup -p1
|
|
# Test if our pre-build earloom.1 is newer than README.md; if not, fail
|
|
# in case of fail, rebuild the earlyoom.1 out of the build system using
|
|
# pandoc MANPAGE.md -s -t man > earlyoom.1
|
|
test %{SOURCE2} -nt README.md
|
|
|
|
# Fix defaults file location
|
|
sed -i 's|/default/|/sysconfig/|' earlyoom.service.in
|
|
|
|
# remove calls to systemctl in install
|
|
sed -e '/systemctl/d' -i Makefile
|
|
|
|
%if %{with tests}
|
|
# fix version test
|
|
sed -i 's|stderrContains: "earlyoom v",|stderrContains: "earlyoom %{version}",|' testsuite_cli_test.go
|
|
%endif
|
|
|
|
%build
|
|
CFLAGS='%{?build_cflags}%{!?build_cflags:%optflags} -DVERSION=\"%{version}\" -std=gnu99'
|
|
CPPFLAGS='%{?build_cxxflags}%{!?build_cxxflags:%optflags}'
|
|
LDFLAGS="-lrt ${RPM_LD_FLAGS}"
|
|
%make_build CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" PREFIX=%{_prefix}
|
|
|
|
%check
|
|
%if %{with tests}
|
|
%make_build test
|
|
%endif
|
|
|
|
%install
|
|
%make_install PREFIX=%{_prefix} SYSTEMDUNITDIR=%{_unitdir}
|
|
install -Dpm0644 %{SOURCE1} %{buildroot}%{_fillupdir}/sysconfig.%{name}
|
|
install -Dpm0644 %{SOURCE2} %{buildroot}%{_mandir}/man1/%{name}.1
|
|
|
|
mkdir -p %{buildroot}%{_sbindir}
|
|
ln -s service %{buildroot}%{_sbindir}/rc%{name}
|
|
|
|
%files
|
|
%license LICENSE
|
|
%doc MANPAGE.md README.md
|
|
%{_bindir}/%{name}
|
|
%{_unitdir}/%{name}.service
|
|
%exclude %{_sysconfdir}/default/%{name}
|
|
%{_fillupdir}/sysconfig.%{name}
|
|
%{_sbindir}/rc%{name}
|
|
%{_mandir}/man1/%{name}.1%{?ext_man}
|
|
|
|
%pre
|
|
%{service_add_pre %{name}.service}
|
|
|
|
%post
|
|
%{fillup_only %{name}}
|
|
%{service_add_post %{name}.service}
|
|
|
|
%preun
|
|
%{service_del_preun %{name}.service}
|
|
|
|
%postun
|
|
%{service_del_postun %{name}.service}
|
|
|
|
%changelog
|