diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9548c04 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/needrestart-2.11.tar.gz diff --git a/02-install-restart-d.diff b/02-install-restart-d.diff new file mode 100644 index 0000000..ddc0267 --- /dev/null +++ b/02-install-restart-d.diff @@ -0,0 +1,16 @@ +# Makefile: Fix installation of restart.d/ scripts. +# Closes: #851866 + +diff --git a/Makefile b/Makefile +index 0e3855a..430958d 100644 +--- a/Makefile ++++ b/Makefile +@@ -16,7 +16,7 @@ install: all + mkdir -p "$(DESTDIR)/etc/needrestart/notify.d" + cp ex/notify.d/* "$(DESTDIR)/etc/needrestart/notify.d/" + mkdir -p "$(DESTDIR)/etc/needrestart/restart.d" +- cp ex/notify.d/* "$(DESTDIR)/etc/needrestart/restart.d/" ++ cp ex/restart.d/* "$(DESTDIR)/etc/needrestart/restart.d/" + + which apt-get > /dev/null && \ + mkdir -p "$(DESTDIR)/etc/apt/apt.conf.d" && cp ex/apt/needrestart-apt_d "$(DESTDIR)/etc/apt/apt.conf.d/99needrestart" && \ diff --git a/03-perl-warning.diff b/03-perl-warning.diff new file mode 100644 index 0000000..77a18da --- /dev/null +++ b/03-perl-warning.diff @@ -0,0 +1,14 @@ +# Fix warning in Perl 5.20.x. Not triggered in 5.24.x. + +diff -Naur needrestart-2.11.orig/ex/needrestart.conf needrestart-2.11/ex/needrestart.conf +--- needrestart-2.11.orig/ex/needrestart.conf 2017-01-17 16:00:20.000000000 +0100 ++++ needrestart-2.11/ex/needrestart.conf 2017-02-06 10:40:29.008100902 +0100 +@@ -150,7 +150,7 @@ + qr(^/\[aio\]), + + # Oil Runtime Compiler's JIT files +- qr(/orcexec\.[\w\d]+( \(deleted\))?$), ++ qr#/orcexec\.[\w\d]+( \(deleted\))?$#, + ]; + + # Verify mapped files in fileystem: diff --git a/README.md b/README.md deleted file mode 100644 index a1afcc5..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# needrestart - -The needrestart package \ No newline at end of file diff --git a/debconf__needrestart.templates b/debconf__needrestart.templates new file mode 100644 index 0000000..39895af --- /dev/null +++ b/debconf__needrestart.templates @@ -0,0 +1,80 @@ +Template: needrestart/ui-query_pkgs_title +Type: title +Description: Daemons using outdated libraries +Description-de.UTF-8: Dienste, die veraltete Bibliotheken nutzen +Description-ru.UTF-8: Демоны, использующие устаревшие библиотеки + +Template: needrestart/ui-query_pkgs +Type: multiselect +Choices: ${PKGS} +Description: Which services should be restarted? +Description-de.UTF-8: Welche Dienste sollen neu gestartet werden? +Description-ru.UTF-8: Какие службы должны быть перезапущены? + +Template: needrestart/ui-kernel_announce_abi +Type: note +Description: Newer kernel available + The currently running kernel version is ${KVERSION} and there is an ABI + compatible upgrade pending. + . + Restarting the system to load the new kernel will not be handled + automatically, so you should consider rebooting. +Description-de.UTF-8: Neuer Kernel vorhanden + Für die aktuelle Kernel-Version ${KVERSION} ist ein ABI-kompatibles Update vorhanden. + . + Das System wird nicht automatisch neu gestartet, um den neuen Kernel zu laden. Ein Neustart sollte durchgeführt werden. +Description-ru.UTF-8: Доступно новое ядро + Версия текущего ядра: ${KVERSION}, имеется незаконченное обновление, несовместимое на уровне ABI. + . + Перезапуск системы для загрузки нового ядра не производится автоматически, поэтому запланируйте перезагрузку. + +Template: needrestart/ui-kernel_announce_ver +Type: note +Description: Newer kernel available + The currently running kernel version is ${KVERSION} which is not the + expected kernel version ${EVERSION}. + . + Restarting the system to load the new kernel will not be handled + automatically, so you should consider rebooting. +Description-de.UTF-8: Neuer Kernel vorhanden + Die aktuelle Kernel-Version ist ${KVERSION}, es wird jedoch die Version ${EVERSION} erwartet. + . + Das System wird nicht automatisch neu gestartet, um den neuen Kernel zu laden. Ein Neustart sollte durchgeführt werden. +Description-ru.UTF-8: Доступно новое ядро + Версия текущего ядра: ${KVERSION}, что отлично от ожидаемой версии ${EVERSION}. + . + Перезапуск системы для загрузки нового ядра не производится автоматически, поэтому запланируйте перезагрузку. + +Template: needrestart/ui-kernel_title +Type: title +Description: Pending kernel upgrade +Description-de.UTF-8: Ausstehendes Kernel-Upgrade +Description-ru.UTF-8: Ожидается обновление ядра + +Template: needrestart/ui-ehint_title +Type: title +Description: Restart pending... +Description-de.UTF-8: Ausstehender Neustart... +Description-ru.UTF-8: Ожидается перезапуск... + +Template: needrestart/ui-ehint_announce +Type: note +Description: This system runs ${EHINT} - you should consider rebooting! + For more details, run «needrestart -m a». +Description-de.UTF-8: Das System verwendet ${EHINT} - ein Neustart sollte durchgeführt werden. + Der Befehl »needrestart -m a« zeigt mehr Details. +Description-ru.UTF-8: Эта система использует ${EHINT} - запланируйте перезагрузку! + Для получения подробностей выполните «needrestart -m a». + +Template: needrestart/ui-query_conts_title +Type: title +Description: Containers using outdated libraries +Description-de.UTF-8: Container, die veraltete Bibliotheken nutzen +Description-ru.UTF-8: Контейнеры, использующие устаревшие библиотеки + +Template: needrestart/ui-query_conts +Type: multiselect +Choices: ${CONTS} +Description: Which containers should be restarted? +Description-de.UTF-8: Welche Container sollen neu gestartet werden? +Description-ru.UTF-8: Какие контейнеры должны быть перезапущены? diff --git a/dnf__plugin.py b/dnf__plugin.py new file mode 100644 index 0000000..0d63ad8 --- /dev/null +++ b/dnf__plugin.py @@ -0,0 +1,26 @@ +import dnf +import subprocess + + +class NeedRestart(dnf.Plugin): + name = 'needrestart' + need_check = False + + def __init__(self, base, cli): + super(NeedRestart, self).__init__(base, cli) + self.base = base + self.cli = cli + + def resolved(self): + tx = self.base.transaction + if tx.install_set or tx.remove_set: + self.need_check = True + + def transaction(self): + if self.need_check: + try: + subprocess.call(['needrestart']) + except OSError: + # this tool is being removed + pass + diff --git a/needrestart.spec b/needrestart.spec new file mode 100644 index 0000000..53c862a --- /dev/null +++ b/needrestart.spec @@ -0,0 +1,125 @@ +Name: needrestart +Version: 2.11 +Release: 6 +Summary: Restart daemons after library updates + +License: GPLv2+ +URL: https://github.com/liske/%{name} +Source0: https://github.com/liske/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz +Source1: debconf__needrestart.templates +Source2: restart.d__auditd.service +Source3: yum__plugin.py +Source4: dnf__plugin.py +# borrowed from Debian, so keeping the original name to ease sync +Patch0: 02-install-restart-d.diff +Patch1: 03-perl-warning.diff + +BuildArch: noarch +BuildRequires: perl +BuildRequires: gettext +BuildRequires: perl(ExtUtils::MakeMaker) +BuildRequires: debconf +BuildRequires: po-debconf +%if 0%{?fedora} +BuildRequires: python3-devel +Requires: python3-dnf +%else +Requires: yum +%endif +Requires: perl(Module::Find) +Requires: perl(Module::ScanDeps) +Requires: perl(Locale::TextDomain) +Requires: perl(Proc::ProcessTable) +Requires: perl(Sort::Naturally) +Requires: perl(Term::ReadKey) +Requires: perl(Debconf::Client::ConfModule) +Requires: xz + +%{?perl_default_filter} + + +%description +needrestart checks which daemons need to be restarted after library +upgrades. It is inspired by checkrestart from the debian-goodies +package. + + +%prep +%autosetup -n %{name}-%{version} -p 1 + +%build +%make_build + + +%install +%make_install +mkdir -p %{buildroot}/%{_mandir}/man1 +cp man/needrestart.1 %{buildroot}/%{_mandir}/man1/ +%find_lang %{name} +%find_lang needrestart-notify +# useless files +rm -rf %{buildroot}/%{perl_archlib} +# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1489569 +cp %{SOURCE1} %{buildroot}/%{_datadir}/%{name}/needrestart.templates +# workaround for https://github.com/liske/needrestart/issues/75 +cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/%{name}/restart.d/auditd.service +chmod a+x %{buildroot}/%{_sysconfdir}/%{name}/restart.d/auditd.service +%if 0%{?fedora} +mkdir -p %{buildroot}/%{_sysconfdir}/dnf/plugins %{buildroot}/%{python3_sitelib}/dnf-plugins +echo -e "[main]\nenabled=1\n" >%{buildroot}/%{_sysconfdir}/dnf/plugins/needrestart.conf +cp %{SOURCE4} %{buildroot}/%{python3_sitelib}/dnf-plugins/needrestart.py +%else +mkdir -p %{buildroot}/%{_sysconfdir}/yum/pluginconf.d %{buildroot}/usr/lib/yum-plugins +echo -e "[main]\nenabled=1\n" >%{buildroot}/%{_sysconfdir}/yum/pluginconf.d/needrestart.conf +cp %{SOURCE3} %{buildroot}/usr/lib/yum-plugins/needrestart.py +%endif + + +# About executable files in the /etc directory: +# The 'README.needrestart' files in /etc/needrestart/restart.d/ and +# /etc/needrestart/notify.d/ explicitly say the files will only be +# considered if they are executables. There's nothing said for +# /etc/needrestart/hook.d/ but I guess this is the same logic. +%files -f %{name}.lang -f needrestart-notify.lang +%license COPYING +%doc README.md README.batch.md README.Cont.md README.Interp.md README.nagios.md NEWS ChangeLog +%config(noreplace) %{_sysconfdir}/%{name} +%{_sbindir}/%{name} +%{perl_vendorlib}/* +# %{_libdir} resolves to /usr/lib64 on 64-bits systems, but the software does not handle this +/usr/lib/%{name} +%{_datadir}/%{name} +%{_datadir}/polkit-1 +%{_mandir}/man1/needrestart.1* +%if 0%{?fedora} +%config(noreplace) %{_sysconfdir}/dnf/plugins/needrestart.conf +%{python3_sitelib} +%else +%config(noreplace) %{_sysconfdir}/yum/pluginconf.d/needrestart.conf +/usr/lib/yum-plugins +%endif + + +%changelog +* Thu Sep 28 2017 Marc Dequènes (Duck) - 2.11-6 +- Thanks Matthias Runge Mauchin for the review +- break description line too long + +* Thu Sep 28 2017 Marc Dequènes (Duck) - 2.11-5 +- add dependency on respective YUM/DNF packages to avoid unowned directories + +* Wed Sep 27 2017 Marc Dequènes (Duck) - 2.11-4 +- make the changelog more readable + +* Fri Sep 22 2017 Marc Dequènes (Duck) - 2.11-3 +- YUM plugin: call needrestart in close_hook to avoid RPMDB mess +- fix conditional to install DNF plugin instead of YUM plugin +- build depends on python3-devel to get the related macros +- fix DNF plugin directory creation + +* Fri Sep 15 2017 Marc Dequènes (Duck) - 2.11-2 +- update YUM and DNF plugins: don't crash when needrestart itself is being removed + +* Thu Sep 07 2017 Marc Dequènes (Duck) - 2.11-1 +- initial packaging + diff --git a/restart.d__auditd.service b/restart.d__auditd.service new file mode 100644 index 0000000..296ef78 --- /dev/null +++ b/restart.d__auditd.service @@ -0,0 +1,3 @@ +#!/bin/sh + +true diff --git a/sources b/sources new file mode 100644 index 0000000..6f64a77 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (needrestart-2.11.tar.gz) = e987ebafe77aba6920645088fa12e609b52f55edfd545ede1c0a93ee1d6b91ed3ea84cb8db69cd067aaabe8ba973b366da61301b5527ec176a29e3ba30605311 diff --git a/yum__plugin.py b/yum__plugin.py new file mode 100644 index 0000000..821217a --- /dev/null +++ b/yum__plugin.py @@ -0,0 +1,23 @@ +from yum.plugins import TYPE_INTERACTIVE +import subprocess + + +requires_api_version = '2.3' +plugin_type = (TYPE_INTERACTIVE) + +check_needed = False + +def posttrans_hook(conduit): + check_needed = True + +# acting in posttrans_hook is too early, we need to be sure the RPMDB is closed to avoid things like: +# « Rpmdb changed underneath us » followed by failure to open the database on the next YUM call +def close_hook(conduit): + if not check_needed: + return + try: + subprocess.call(['needrestart']) + except OSError: + # this tool is being removed + pass +