Автор Тема: earlyoom  (Прочитано 2618 раз)

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
earlyoom
« : 28.01.2019 14:03:49 »
Копипаст:
https://forum.altlinux.org/index.php?topic=6830.msg334553#msg334553

Таки собрал.

Изменено имя файла скрипта как Источника1
$ cp ~/RPM/SOURCES/earlyoom.init ~/RPM/SOURCES/earlyoom

В спэке:
- Изменена строка 13 с earlyoom.init на earlyoom
- Добавлены строки: 40, 41, 42, 54
$ cat -n ~/RPM/SPECS/earlyoom.spec
     1  Name:     earlyoom
     2  Version:  1.2
     3  Release:  alt2
     4
     5  Summary:  Early OOM Daemon for Linux
     6  License:  MIT
     7  Group:    Other
     8  Url:      http://github.com/rfjakob/earlyoom
     9
    10  Packager: Anton Midyukov <antohami@altlinux.org>
    11
    12  Source:   %name-%version.tar
    13  Source1:  %name
    14
    15  %ifarch %ix86 x86_64
    16  BuildRequires: pandoc
    17  %endif
    18
    19  %description
    20  The oom-killer generally has a bad reputation among Linux users.
    21  This may be part of the reason Linux invokes it only when it has
    22  absolutely no other choice. It will swap out the desktop
    23  environment, drop the whole page cache and empty every buffer
    24  before it will ultimately kill a process. At least that's what
    25  I think what it will do. I have yet to be patient enough to wait
    26  for it, sitting in front of an unresponsive system.
    27
    28  %prep
    29  %setup
    30  sed -e '/systemctl/d' -i Makefile
    31
    32  %build
    33  %make_build
    34
    35  %install
    36  %makeinstall_std \
    37      PREFIX=%_prefix \
    38      SYSCONFDIR=%_sysconfdir \
    39      SYSTEMDUNITDIR=%_unitdir
    40
    41  mkdir -p %buildroot%_initdir
    42  install -pm755 %SOURCE1 %buildroot%_initdir
    43
    44  %post
    45  %post_service %name
    46
    47  %preun
    48  %preun_service %name
    49
    50  %files
    51  %doc README.md LICENSE
    52  %_bindir/%name
    53  %_unitdir/%name.service
    54  %_initdir/%name
    55
    56
    57  %ifarch %ix86 x86_64
    58  %_man1dir/%name.*
    59  %endif
    60
    61  %config(noreplace) %_sysconfdir/default/%name
    62
    63  %changelog
    64  * Fri Jan 25 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt2
    65  - Added init script (Thanks Specyfighter)
    66
    67  * Sun Jan 20 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt1
    68  - Initial build (Closes: 35924)

Листинг спэка:
Name:     earlyoom
Version:  1.2
Release:  alt2

Summary:  Early OOM Daemon for Linux
License:  MIT
Group:    Other
Url:      http://github.com/rfjakob/earlyoom

Packager: Anton Midyukov <antohami@altlinux.org>

Source:   %name-%version.tar
Source1:  %name

%ifarch %ix86 x86_64
BuildRequires: pandoc
%endif

%description
The oom-killer generally has a bad reputation among Linux users.
This may be part of the reason Linux invokes it only when it has
absolutely no other choice. It will swap out the desktop
environment, drop the whole page cache and empty every buffer
before it will ultimately kill a process. At least that's what
I think what it will do. I have yet to be patient enough to wait
for it, sitting in front of an unresponsive system.

%prep
%setup
sed -e '/systemctl/d' -i Makefile

%build
%make_build

%install
%makeinstall_std \
    PREFIX=%_prefix \
    SYSCONFDIR=%_sysconfdir \
    SYSTEMDUNITDIR=%_unitdir

mkdir -p %buildroot%_initdir
install -pm755 %SOURCE1 %buildroot%_initdir

%post
%post_service %name

%preun
%preun_service %name

%files
%doc README.md LICENSE
%_bindir/%name
%_unitdir/%name.service
%_initdir/%name


%ifarch %ix86 x86_64
%_man1dir/%name.*
%endif

%config(noreplace) %_sysconfdir/default/%name

%changelog
* Fri Jan 25 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt2
- Added init script (Thanks Specyfighter)

* Sun Jan 20 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt1
- Initial build (Closes: 35924)

После сборки
$ rpm -ba --target i586 ~/RPM/SPECS/earlyoom.spec

пакет получился таким, каким и должен быть, - с sysv init-файлом:
$ rpm -qpl /home/user/RPM/SRPMS/earlyoom-1.2-alt2.src.rpm
earlyoom
earlyoom-1.2.tar
earlyoom.spec
$ rpm -qpvl /home/user/RPM/RPMS/i586/earlyoom-1.2-alt2.i586.rpm
-rw-r--r--    1 root    root              562 янв 26 02:02 /etc/default/earlyoom
-rwxr-xr-x    1 root    root             1412 янв 26 02:01 /etc/rc.d/init.d/earlyoom
-rw-r--r--    1 root    root              233 янв 26 02:02 /lib/systemd/system/earlyoom.service
-rwxr-xr-x    1 root    root            22108 янв 26 02:02 /usr/bin/earlyoom
drwxr-xr-x    2 root    root                0 янв 26 02:02 /usr/share/doc/earlyoom-1.2
-rw-r--r--    1 root    root             1087 окт 28 18:32 /usr/share/doc/earlyoom-1.2/LICENSE
-rw-r--r--    1 root    root            11756 окт 28 18:32 /usr/share/doc/earlyoom-1.2/README.md
-rw-r--r--    1 root    root             2160 янв 26 02:02 /usr/share/man/man1/earlyoom.1.xz

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
Re: earlyoom
« Ответ #1 : 28.01.2019 14:04:51 »
Копипаст:
https://forum.altlinux.org/index.php?topic=6830.msg334554#msg334554

После инсталляции
# md5sum /etc/rc.d/init.d/earlyoom
00d941e91f8d917b9fcc244facc4aeca  /etc/rc.d/init.d/earlyoom
# apt-get reinstall /home/user/RPM/RPMS/i586/earlyoom-1.2-alt2.i586.rpm
Чтение списков пакетов... Завершено
Построение дерева зависимостей... Завершено
Выбрано earlyoom для '/home/user/RPM/RPMS/i586/earlyoom-1.2-alt2.i586.rpm'
Следующие пакеты будут ОБНОВЛЕНЫ:
  earlyoom
1 будет обновлено, 0 новых установлено, 0 пакетов будет удалено и 87 не будет обновлено.
Необходимо получить 0B/20,0kB архивов.
После распаковки потребуется дополнительно 1412B дискового пространства.
Совершаем изменения...
Preparing...                             ##### [100%]
1: earlyoom                              ##### [100%]
Usage: earlyoom {start|stop|restart|status}
Running /usr/lib/rpm/posttrans-filetriggers
Завершено.

файл скрипта изменился
# md5sum /etc/rc.d/init.d/earlyoom
1b80e098df49bff1d7b5df7d9f9bca1a  /etc/rc.d/init.d/earlyoom
# ls -l $(find /etc/rc* -name *earlyoom)
-rwxr-xr-x 1 root root 1412 янв 26 02:01 /etc/rc.d/init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc0.d/K97earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc1.d/K97earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc2.d/S32earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc3.d/S32earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc4.d/S32earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc5.d/S32earlyoom -> ../init.d/earlyoom
lrwxrwxrwx 1 root root   18 янв 26 02:36 /etc/rc.d/rc6.d/K97earlyoom -> ../init.d/earlyoom

и был заменён sysv скриптом с LSB-хидером
# cat /etc/rc.d/init.d/earlyoom
#!/bin/sh
#
# chkconfig: 2345 32 97
# description: Early OOM Killer. \
#             A userspace service that will kill the largest process \
#             (by VmRSS residential size) when free RAM drops below 10%.
# processname: earlyoom
# config: /etc/default/earlyoom
#

### 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

# Source function library.
WITHOUT_RC_COMPAT=1
. /etc/init.d/functions

# Source earlyoom configuration.
SourceIfNotEmpty /etc/default/earlyoom

LOGFILE=/var/log/earlyoom.log
LOCKFILE=/run/lock/subsys/earlyoom
RETVAL=0


start()
{
        start_daemon --lockfile "$LOCKFILE" --background --expect-user root -- earlyoom $EARLYOOM_ARGS 2> "$LOGFILE"
        RETVAL=$?
        return $RETVAL
}

stop()
{
        stop_daemon --lockfile "$LOCKFILE" --expect-user root -- earlyoom
        RETVAL=$?
        return $RETVAL
}

restart()
{
        stop
        start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        status --lockfile "$LOCKFILE" --expect-user root -- earlyoom
        RETVAL=$?
        ;;
  *)
        msg_usage "${0##*/} {start|stop|restart|status}"
        RETVAL=1
esac

exit $RETVAL

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
Re: earlyoom
« Ответ #2 : 28.01.2019 14:17:40 »
Готовый пакет:
Исправлена инсталляция sysv сервиса
Сборка пакетов во вложении выполнялась в p8/branch
# rpm -qpivl --changelog /home/user/RPM/RPMS/i586/earlyoom-1.2-alt3.i586.rpm
Name        : earlyoom                     Relocations: (not relocatable)
Version     : 1.2                               Vendor: ALT Linux Team
Release     : alt3                          Build Date: Пн 28 янв 2019 13:49:50
Install date: (not installed)               Build Host: blackhole
Group       : Другие                  Source RPM: earlyoom-1.2-alt3.src.rpm
Size        : 39318                            License: MIT
Packager    : Anton Midyukov <antohami@altlinux.org>
URL         : http://github.com/rfjakob/earlyoom
Summary     : Early OOM Daemon for Linux
Description :
The oom-killer generally has a bad reputation among Linux users.
This may be part of the reason Linux invokes it only when it has
absolutely no other choice. It will swap out the desktop
environment, drop the whole page cache and empty every buffer
before it will ultimately kill a process. At least that's what
I think what it will do. I have yet to be patient enough to wait
for it, sitting in front of an unresponsive system.
* Пн янв 28 2019 Speccyfighter <zxwarior@yandex.ru> 1.2-alt3
- Fix install sysv service

* Пт янв 25 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt2
- Added init script (Thanks Specyfighter)

* Вс янв 20 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt1
- Initial build (Closes: 35924)

-rw-r--r--    1 root    root              562 янв 28 13:49 /etc/default/earlyoom
-rwxr-xr-x    1 root    root             1412 янв 26 02:01 /etc/rc.d/init.d/earlyoom
-rw-r--r--    1 root    root              233 янв 28 13:49 /lib/systemd/system/earlyoom.service
-rwxr-xr-x    1 root    root            22108 янв 28 13:49 /usr/bin/earlyoom
drwxr-xr-x    2 root    root                0 янв 28 13:49 /usr/share/doc/earlyoom-1.2
-rw-r--r--    1 root    root             1087 окт 28 18:32 /usr/share/doc/earlyoom-1.2/LICENSE
-rw-r--r--    1 root    root            11756 окт 28 18:32 /usr/share/doc/earlyoom-1.2/README.md
-rw-r--r--    1 root    root             2160 янв 28 13:49 /usr/share/man/man1/earlyoom.1.xz
# rpm -qpivl --changelog /home/user/RPM/SRPMS/earlyoom-1.2-alt3.src.rpm
Name        : earlyoom                     Relocations: (not relocatable)
Version     : 1.2                               Vendor: ALT Linux Team
Release     : alt3                          Build Date: Пн 28 янв 2019 13:49:50
Install date: (not installed)               Build Host: blackhole
Group       : Другие                  Source RPM: (none)
Size        : 105361                           License: MIT
Packager    : Anton Midyukov <antohami@altlinux.org>
URL         : http://github.com/rfjakob/earlyoom
Summary     : Early OOM Daemon for Linux
Description :
The oom-killer generally has a bad reputation among Linux users.
This may be part of the reason Linux invokes it only when it has
absolutely no other choice. It will swap out the desktop
environment, drop the whole page cache and empty every buffer
before it will ultimately kill a process. At least that's what
I think what it will do. I have yet to be patient enough to wait
for it, sitting in front of an unresponsive system.
* Пн янв 28 2019 Speccyfighter <zxwarior@yandex.ru> 1.2-alt3
- Fix install sysv service

* Пт янв 25 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt2
- Added init script (Thanks Specyfighter)

* Вс янв 20 2019 Anton Midyukov <antohami@altlinux.org> 1.2-alt1
- Initial build (Closes: 35924)

-rw-r--r--    1 builder builder          1412 янв 26 02:01 earlyoom
-rw-r--r--    1 builder builder        102400 янв 25 19:11 earlyoom-1.2.tar
-rw-r--r--    1 builder builder          1549 янв 28 13:47 earlyoom.spec

# apt-get install /home/user/RPM/RPMS/i586/earlyoom-1.2-alt3.i586.rpm
Чтение списков пакетов... Завершено
Построение дерева зависимостей... Завершено
Выбрано earlyoom для '/home/user/RPM/RPMS/i586/earlyoom-1.2-alt3.i586.rpm'
Следующие пакеты будут ОБНОВЛЕНЫ:
  earlyoom
1 будет обновлено, 0 новых установлено, 0 пакетов будет удалено и 87 не будет обновлено.
Необходимо получить 0B/20,0kB архивов.
После распаковки потребуется дополнительно 0B дискового пространства.
Совершаем изменения...
Preparing...                             ##### [100%]
1: earlyoom                              ##### [100%]
Usage: earlyoom {start|stop|restart|status}
Running /usr/lib/rpm/posttrans-filetriggers
Завершено.
# /etc/rc.d/init.d/earlyoom restart
Stopping earlyoom service:      [ DONE ]
Starting earlyoom service:      [ DONE ]
# /etc/rc.d/init.d/earlyoom status
earlyoom is running

Пакеты во вложении.
« Последнее редактирование: 28.01.2019 14:34:30 от Speccyfighter »

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
Re: earlyoom
« Ответ #3 : 28.01.2019 14:23:07 »

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
Re: earlyoom
« Ответ #4 : 28.01.2019 14:28:47 »
Базовые архивы которые использовались для исправления как основа, - вложение.
Также см. пакеты в сизифе.

Оффлайн Speccyfighter

  • Мастер
  • ***
  • Сообщений: 10 259
Re: earlyoom
« Ответ #5 : 28.01.2019 14:46:46 »
Что делает пакет earlyoom:
Если заполнение памяти хуже указанных в конфиге /etc/default/earlyoom параметров, то для предотвращения фриза, убивает наиболее тяжёлый процесс освобождая память.

С такими параметрами, убьёт наиболее тяжёлый процесс, если свободная память будет менее 15% не допуская заполнения swap:
# grep -v '^$\|^#' /etc/default/earlyoom
EARLYOOM_ARGS="-m 15 -s 100"

Ссылка на проект в выбросах.
« Последнее редактирование: 28.01.2019 14:53:32 от Speccyfighter »

Оффлайн Антон Мидюков

  • alt linux team
  • ***
  • Сообщений: 5 183
  • antohami@
Re: earlyoom
« Ответ #6 : 28.01.2019 15:23:42 »
Пакет в задании 219650 (в нём был сначала alt1). Извиняюсь, что не написал. Тестирование пакет только что прошёл. Вероятно, уже завтра будет в p8.