151 lines
3.4 KiB
RPMSpec
151 lines
3.4 KiB
RPMSpec
|
%define realname earlyoom
|
||
|
%define srcext tar.bz2
|
||
|
|
||
|
%if 0%{?suse_version} >= 1230 || 0%{?rhel} >= 7
|
||
|
%bcond_without systemd
|
||
|
%else
|
||
|
%bcond_with systemd
|
||
|
%endif
|
||
|
|
||
|
%if 0%{?rhel} && 0%{?rhel} == 6
|
||
|
%bcond_without upstart
|
||
|
%else
|
||
|
%bcond_with upstart
|
||
|
%endif
|
||
|
|
||
|
%if ! 0%{?_fillupdir:1}
|
||
|
%global _fillupdir /var/adm/fillup-templates
|
||
|
%endif
|
||
|
|
||
|
%global rpm_version %(rpm -q --qf %%{version} rpm)
|
||
|
|
||
|
# Common info
|
||
|
Name: %{realname}
|
||
|
Version: 0
|
||
|
Release: wiz%{?extraver:0.}1%{?dist}
|
||
|
License: MIT
|
||
|
Group: System/Daemons
|
||
|
URL: https://github.com/rfjakob/earlyoom
|
||
|
Summary: Early OOM Daemon for Linux
|
||
|
|
||
|
# Install-time parameters
|
||
|
Conflicts: oomd
|
||
|
%if %{lua:print(rpm.vercmp(rpm.expand('%rpm_version'), '4.13'))} >= 0
|
||
|
Recommends: libnotify%{?suse_version:-tools}
|
||
|
%endif
|
||
|
Requires(post): insserv-compat
|
||
|
|
||
|
# Build-time parameters
|
||
|
BuildRequires: pandoc
|
||
|
%if %{with systemd}
|
||
|
BuildRequires: pkgconfig(systemd)
|
||
|
%endif
|
||
|
BuildRoot: %{_tmppath}/%{name}-root
|
||
|
ExclusiveOS: Linux
|
||
|
Source0: %{realname}-%{version}.%{srcext}
|
||
|
Source11: earlyoom.sysconfig
|
||
|
Source12: earlyoom.init
|
||
|
Source13: earlyoom.upstart
|
||
|
|
||
|
%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).
|
||
|
|
||
|
# Preparation step (unpackung and patching if necessary)
|
||
|
%prep
|
||
|
%setup -q -n %{realname}-%{version}%{?extraver}
|
||
|
# Fix defaults file location
|
||
|
%{__sed} -i 's|/default/|/sysconfig/|' earlyoom.service.in
|
||
|
# CentOS' gzip does not have option `-k`
|
||
|
%{__sed} -i 's|gzip -f -k.*$|gzip -c $< > $@|' Makefile
|
||
|
# Fix LDFLAGS handling
|
||
|
%{__sed} -ri '/LDFLAGS/ s|$| -lrt|' Makefile
|
||
|
|
||
|
# Build step (compile/build binaries, documentation, etc)
|
||
|
%build
|
||
|
_CFLAGS='%{optflags} %{?gcc_lto} -Wall -Wextra -DVERSION=\"%{version}\" -fstack-protector-all -std=gnu99'
|
||
|
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}'
|
||
|
%{__make} %{?_smp_mflags} \
|
||
|
CFLAGS="$_CFLAGS" \
|
||
|
LDFLAGS="$_LDFLAGS"
|
||
|
|
||
|
# Install built stuff
|
||
|
%install
|
||
|
%{__make} install DESTDIR=%{buildroot} \
|
||
|
%if %{with systemd}
|
||
|
SYSTEMDUNITDIR=%{_unitdir} \
|
||
|
%endif
|
||
|
PREFIX=%{_prefix}
|
||
|
%if 0%{?suse_version}
|
||
|
%{__install} -D -m644 %{S:11} %{buildroot}%{_fillupdir}/sysconfig.%{name}
|
||
|
%else
|
||
|
%{__install} -D -m644 %{S:11} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
|
||
|
%endif
|
||
|
%if ! %{with systemd}
|
||
|
%if %{with upstart}
|
||
|
%{__install} -D -m644 %{S:13} %{buildroot}%{_sysconfdir}/init/%{name}
|
||
|
%else
|
||
|
%{__install} -D -m755 %{S:12} %{buildroot}%{_initrddir}/%{name}
|
||
|
%endif
|
||
|
%endif
|
||
|
|
||
|
# Cleanup
|
||
|
%clean
|
||
|
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
|
||
|
|
||
|
# Files list
|
||
|
%files
|
||
|
%defattr(-,root,root)
|
||
|
%doc LICENSE MANPAGE.md README.md
|
||
|
%{_bindir}/earlyoom
|
||
|
%if %{with systemd}
|
||
|
%{_unitdir}/%{name}.service
|
||
|
%else
|
||
|
%if %{with upstart}
|
||
|
%{_sysconfdir}/init/%{name}
|
||
|
%else
|
||
|
%{_initrddir}/%{name}
|
||
|
%endif
|
||
|
%exclude %{_sysconfdir}/systemd/system/earlyoom.service
|
||
|
%endif
|
||
|
%exclude %{_sysconfdir}/default/earlyoom
|
||
|
%if 0%{?suse_version}
|
||
|
%{_fillupdir}/sysconfig.%{name}
|
||
|
%else
|
||
|
%{_sysconfdir}/sysconfig/%{name}
|
||
|
%endif
|
||
|
%doc %{_mandir}/man1/earlyoom.1*
|
||
|
|
||
|
%if 0%{?suse_version}
|
||
|
|
||
|
%if 0%{?_unitdir:1}
|
||
|
%pre
|
||
|
%{service_add_pre %{name}.service}
|
||
|
%endif
|
||
|
|
||
|
%post
|
||
|
%if 0%{?_unitdir:1}
|
||
|
%{fillup_only %{name}}
|
||
|
%{service_add_post %{name}.service}
|
||
|
%else
|
||
|
%{fillup_and_insserv %{name}}
|
||
|
%endif
|
||
|
|
||
|
%preun
|
||
|
%if 0%{?_unitdir:1}
|
||
|
%{service_del_preun %{name}.service}
|
||
|
%else
|
||
|
%{stop_on_removal %{name}}
|
||
|
%endif
|
||
|
|
||
|
%postun
|
||
|
%if 0%{?_unitdir:1}
|
||
|
%{service_del_postun %{name}.service}
|
||
|
%else
|
||
|
%{restart_on_update %{name}}
|
||
|
%endif
|
||
|
%{insserv_cleanup}
|
||
|
|
||
|
%endif
|
||
|
%changelog
|