File earlyoom.spec of Package earlyoom

# spec file for package earlyoom
# Copyright (c) 2020 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

%if ! 0%{?_fillupdir:1}
%global _fillupdir %{_localstatedir}/adm/fillup-templates
Name:           earlyoom
Version:        1.4
Release:        0
Summary:        Early OOM Daemon for Linux
License:        MIT
Group:          System/Daemons
Source11:       earlyoom.sysconfig
# pandoc only for `pandoc -s -t man > earlyoom.1`
BuildRequires:  pandoc
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(systemd)
Requires(post): insserv-compat
Recommends:     libnotify%{?suse_version:-tools}
Conflicts:      oomd

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).

%setup -q

# Fix defaults file location
sed -i 's|/default/|/sysconfig/|'

# Fix LDFLAGS handling
sed -ri '/LDFLAGS/ s|$| -lrt|' Makefile

CFLAGS='%{optflags} -DVERSION=\"%{version}\" -std=gnu99'
%make_build CFLAGS="$CFLAGS" PREFIX=%{_prefix}

%make_install PREFIX=%{_prefix} SYSTEMDUNITDIR=%{_unitdir}
install -D -m644 %{SOURCE11} %{buildroot}%{_fillupdir}/sysconfig.%{name}

%license LICENSE
%exclude %{_sysconfdir}/default/%{name}

%{service_add_pre %{name}.service}

%{fillup_only %{name}}
%{service_add_post %{name}.service}

%{service_del_preun %{name}.service}

%{service_del_postun %{name}.service}

openSUSE Build Service is sponsored by