Accepting request 760937 from home:embar-:Lietukas
EarlyOOM is a user-space daemon for checking the amount of memory and swap frequency in order to trigger Linux's out-of-memory killer (oom-killer) sooner rather than before experiencing too much memory pressure that the Linux desktop hits responsiveness problems. OBS-URL: https://build.opensuse.org/request/show/760937 OBS-URL: https://build.opensuse.org/package/show/Base:System/earlyoom?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.osc
|
18
_service
Normal file
18
_service
Normal file
@@ -0,0 +1,18 @@
|
||||
<services>
|
||||
|
||||
<service name="tar_scm">
|
||||
<param name="scm">git</param>
|
||||
<param name="url">https://github.com/rfjakob/earlyoom</param>
|
||||
<param name="revision">refs/tags/v1.3</param>
|
||||
<param name="versionformat">@PARENT_TAG@</param>
|
||||
<param name="versionrewrite-pattern">^\D*([\d.]+)$</param>
|
||||
</service>
|
||||
|
||||
<service name="recompress">
|
||||
<param name="compression">bz2</param>
|
||||
<param name="file">*.tar</param>
|
||||
</service>
|
||||
|
||||
<service name="set_version"/>
|
||||
|
||||
</services>
|
3
_service:recompress:tar_scm:earlyoom-1.3.tar.bz2
Normal file
3
_service:recompress:tar_scm:earlyoom-1.3.tar.bz2
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dbc396661e0e5a0a3b7664b9469349342ef9b5d3904e0ec2a9b8bb61a0374b52
|
||||
size 28106
|
150
_service:set_version:earlyoom.spec
Normal file
150
_service:set_version:earlyoom.spec
Normal file
@@ -0,0 +1,150 @@
|
||||
%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: 1.3
|
||||
Release: 0%{?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
|
4
earlyoom.changes
Normal file
4
earlyoom.changes
Normal file
@@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jun 6 07:18:05 UTC 2019 - Alexander Evseev <aevseev@gmail.com>
|
||||
|
||||
- First build. Version - 1.3
|
69
earlyoom.init
Normal file
69
earlyoom.init
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# chkconfig: 345 11 89
|
||||
# description: Early OOM Killer daemon
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: earlyoom
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Early OOM Killer
|
||||
# Description: A userspace service that will kill the largest process
|
||||
# (by VmRSS residential size) when free RAM drops below 10%.
|
||||
### END INIT INFO
|
||||
|
||||
if [ -r /etc/rc.status ]; then
|
||||
source /etc/rc.status
|
||||
START="/sbin/startproc"
|
||||
STATUS="/sbin/checkproc"
|
||||
SUCCESS="echo \$rc_done"
|
||||
FAILURE="echo \$rc_failed"
|
||||
else
|
||||
source /etc/rc.d/init.d/functions
|
||||
START="daemon"
|
||||
STATUS="status"
|
||||
SUCCESS="success; echo"
|
||||
FAILURE="failure; echo"
|
||||
fi
|
||||
|
||||
[ -r /etc/sysconfig/earlyoom ] && source /etc/sysconfig/earlyoom || EARLYOOM_ARGS="-r 3 -m 10 -s 20 -n --avoid '(^|/)(systemd|Xorg|X|ssh|yast|yast2|zypper|rpm)$' --prefer '(^|/)(java|chromium|firefox|opera|akregator|thumbnail.so)$'"
|
||||
|
||||
EARLYOOM_BIN=/usr/bin/earlyoom
|
||||
EARLYOOM_PID=/var/run/earlyoom.pid
|
||||
|
||||
RETVAL=0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting earlyoom: "
|
||||
${START} ${EARLYOOM_BIN} ${EARLYOOM_ARGS}
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping earlyoom: "
|
||||
killproc -p ${EARLYOOM_PID} ${EARLYOOM_BIN}
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
unset RETVAL
|
||||
;;
|
||||
reload|force-reload)
|
||||
RETVAL=3
|
||||
;;
|
||||
status)
|
||||
echo -n "Status of earlyoom: "
|
||||
${STATUS} ${EARLYOOM_BIN} > /dev/null 2>&1
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|usage}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
[ -z ${RETVAL} ] && exit
|
||||
[ ${RETVAL} -eq 0 ] && eval "${SUCCESS}" || eval "${FAILURE}"
|
||||
exit ${RETVAL}
|
150
earlyoom.spec
Normal file
150
earlyoom.spec
Normal file
@@ -0,0 +1,150 @@
|
||||
%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
|
12
earlyoom.sysconfig
Normal file
12
earlyoom.sysconfig
Normal file
@@ -0,0 +1,12 @@
|
||||
## Path: System/Memory
|
||||
## Description: configuration for Early OOM Daemon
|
||||
|
||||
## Type: string
|
||||
## Default: "-r 3 -m 10 -s 20 -n --avoid '(^|/)(systemd|Xorg|X|ssh|yast|yast2|zypper|rpm)$' --prefer '(^|/)(java|chromium|firefox|opera|akregator|thumbnail.so)$'"
|
||||
## Config: earlyoom
|
||||
#
|
||||
# Command-line options to pass to earlyoom
|
||||
#
|
||||
# see man(1) earlyoom
|
||||
#
|
||||
EARLYOOM_ARGS="-r 3 -m 10 -s 20 -n --avoid '(^|/)(systemd|Xorg|X|ssh|yast|yast2|zypper|rpm)$' --prefer '(^|/)(java|chromium|firefox|opera|akregator|thumbnail.so)$'"
|
15
earlyoom.upstart
Normal file
15
earlyoom.upstart
Normal file
@@ -0,0 +1,15 @@
|
||||
description "Early OOM killer daemon"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
respawn
|
||||
|
||||
script
|
||||
mkfifo /tmp/earlyoom-log-fifo
|
||||
( logger -t earlyoom < /tmp/earlyoom-log-fifo & )
|
||||
exec >> /tmp/earlyoom-log-fifo 2>&1
|
||||
rm -f /tmp/earlyoom-log-fifo
|
||||
|
||||
. /etc/sysconfig/earlyoom
|
||||
exec /usr/bin/earlyoom ${EARLYOOM_ARGS:--r 60}
|
||||
end script
|
Reference in New Issue
Block a user