File needrestart.spec of Package needrestart
#
# spec file for package needrestart
#
# Copyright (c) 2025 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 https://bugs.opensuse.org/
#
%define original_name NeedRestart
Name: needrestart
Version: 3.11
Release: 4%{?dist}
Summary: Restart daemons/services after library updates without rebooting OS
Group: System/Management
License: GPL-2.0-or-later
URL: https://github.com/liske/%{name}
Source0: https://github.com/liske/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: zypper-full-upgrade+restarts.bash
Source2: %{name}.rpmlintrc
BuildArch: noarch
# For SUSE Leap 16.0 / 15.6 / 15.5 Only
%if 0%{?suse_version} == 1600 && 0%{?is_opensuse} || 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse}
BuildRequires: gettext-tools
BuildRequires: gzip
BuildRequires: make
BuildRequires: perl
BuildRequires: perl-ExtUtils-MakeMaker
BuildRequires: perl-Module-Build
BuildRequires: perl-Module-Find
BuildRequires: perl-Module-ScanDeps
BuildRequires: perl-Proc-ProcessTable
BuildRequires: perl-Term-ProgressBar
BuildRequires: perl-base
BuildRequires: perl-gettext
BuildRequires: perl-libintl-perl
BuildRequires: polkit
BuildRequires: polkit-default-privs
BuildRequires: polkit-devel
BuildRequires: pkgconfig(polkit-agent-1)
Requires: gettext-runtime
Requires: perl
Requires: perl-ExtUtils-MakeMaker
Requires: perl-Module-Build
Requires: perl-Module-Find
Requires: perl-Module-ScanDeps
Requires: perl-Proc-ProcessTable
Requires: perl-Term-ProgressBar
Requires: perl-base
Requires: perl-gettext
Requires: perl-libintl-perl
Requires: polkit
Requires: polkit-default-privs
Requires: (ucode-amd or ucode-intel)
Recommends: shfmt
Provides: zypper-full-upgrade+restarts
%endif
#
# For SUSE TumbleWeed Only
%if 0%{?suse_version} > 1600
BuildRequires: gettext-tools
BuildRequires: gzip
BuildRequires: make
BuildRequires: perl
BuildRequires: perl-ExtUtils-MakeMaker
BuildRequires: perl-Module-Build
BuildRequires: perl-Module-Find
BuildRequires: perl-Module-ScanDeps
BuildRequires: perl-Package-Generator
BuildRequires: perl-Proc-ProcessTable
BuildRequires: perl-Sort-Naturally
BuildRequires: perl-Term-ProgressBar
BuildRequires: perl-base
BuildRequires: perl-gettext
BuildRequires: perl-libintl-perl
BuildRequires: perl-rpm-packaging
BuildRequires: polkit
BuildRequires: polkit-default-privs
BuildRequires: polkit-devel
BuildRequires: pkgconfig(polkit-agent-1)
Requires: gettext-runtime
Requires: perl
Requires: perl-ExtUtils-MakeMaker
Requires: perl-Module-Build
Requires: perl-Module-Find
Requires: perl-Module-ScanDeps
Requires: perl-Package-Generator
Requires: perl-Proc-ProcessTable
Requires: perl-Sort-Naturally
Requires: perl-Term-ProgressBar
Requires: perl-base
Requires: perl-gettext
Requires: perl-libintl-perl
Requires: polkit
Requires: polkit-default-privs
Requires: (ucode-amd or ucode-intel)
Recommends: python313-rpm-spec-language-server
Recommends: shfmt
Provides: zypper-full-upgrade+restarts
%endif
#
Requires: xz
Recommends: cpuid
Recommends: cpuinfo
Recommends: iucode-tool
%{?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.
* Features:
- Supports (but does NOT require) SystemD
- Binary blacklisting (i.e. display managers)
- Tries to detect required restarts of interpreter based daemons
(supports Java, Perl, Python, Ruby)
- Tries to detect required restarts of containers (Docker, LXC)
- Tries to detect pending kernel upgrades
- Tries to detect pending microcode upgrades for AMD/Intel CPUs
- Could be used as Nagios check_command
- Fully integrated into APT/DPKG/DNF/YUM/PACMAN using hooks/plugins
- Added Zypper Full Upgrade script/command to integrate Zypper with NeedRestart straight away
%prep
%autosetup
# Rename ChangeLog to CHANGELOG
mv "%{_builddir}/%{name}-%{version}/ChangeLog" "%{_builddir}/%{name}-%{version}/CHANGELOG"
#
%build
# Ensure /usr/sbin/ is in the BINARY PATH.
export PATH=$PATH:%{_prefix}/sbin/
#
%make_build
%install
# Binary Install Path is Hardcoded in the Makefile
# Ensure /usr/sbin/ is in the BINARY PATH.
export PATH=$PATH:%{_prefix}/sbin/
#
%make_install
# Convert & Install MAN Page(s)
gzip "man/%{name}.1"
install -Dm644 "man/%{name}.1.gz" -t "%{buildroot}/%{_mandir}/man1/"
#
# Look for and Adjust Languages
%find_lang %{name}
%find_lang "%{name}-notify"
#
# SUSE-Specific Processes and Files
%if 0%{?suse_version} > 1600 || 0%{?suse_version} == 1600 && 0%{?is_opensuse} || 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse}
#
# Install ZYPPER-FULL-UPGRADE+RESTARTS from SOURCE to SYSTEM
install -Dm755 %{SOURCE1} "%{buildroot}/%{_sbindir}/zypper-full-upgrade+restarts"
#
# Create SYMLINK from '/usr/sbin/' to '/usr/bin/' for SUSE
mkdir -p %{buildroot}/%{_bindir}/
ln -fs %{_sbindir}/%{name} -t %{buildroot}/%{_bindir}/
ln -fs "%{_sbindir}/zypper-full-upgrade+restarts" -t %{buildroot}/%{_bindir}/
%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.
# Remove the RPM hooks which might potentially conflict with SYSTEM package managers
rm -f "%{buildroot}/%{_sysconfdir}/%{name}/hook.d/20-rpm"
#
#
# Remove `dbus-broker.service` because it is treated as HARDLINK instead of SOFTLINK
rm -f "%{buildroot}/%{_sysconfdir}/%{name}/restart.d/dbus-broker.service"
#
# Relink `dbus.service` with `dbus-broker.service` again as SOFTLINK
ln -fs "%{_sysconfdir}/%{name}/restart.d/dbus.service" "%{buildroot}/%{_sysconfdir}/%{name}/restart.d/dbus-broker.service"
#
# Clean Up PERL Types of Files that Are Automatically Generated When Installing Perl Modules -- ExtUtils::MakeMaker + Module::Build
%perl_process_packlist
find %{buildroot}/ -type f -name .packlist -delete
find %{buildroot}/ -type f -name perllocal.pod -delete
find %{buildroot}/ -type d -empty -delete
#
# Run the set_polkit_default_privs command on the installed policy file to update it.
# set_polkit_default_privs
# "${buildroot}${_datadir}/polkit-1/actions/net.fiasko-nw.needrestart.policy"
# can't open /etc/polkit-1/rules.d/90-default-privs.rules.new: Permission denied
# --<< rules.d/ directory should be: root root ($USER $GROUP)
# and not: root srvGeoClue ($USER $GROUP)
# Ownership BUG in /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/etc/polkit-1:
# `drwxr-x--- 1 root srvGeoClue /etc/polkit-1/rules.d/`
# rules.d/ directory should be: root root ($USER $GROUP) and not: root srvGeoClue ($USER $GROUP)
%files -f "%{name}.lang" -f "%{name}-notify.lang"
%license COPYING
%doc "README.md" "README.batch.md" "README.Cont.md" "README.Interp.md"
%doc "README.nagios.md" "README.uCode.md" NEWS CHANGELOG AUTHORS
%config(noreplace) %{_sysconfdir}/%{name}
%{_bindir}/%{name}
%{_sbindir}/%{name}
"%{_bindir}/zypper-full-upgrade+restarts"
"%{_sbindir}/zypper-full-upgrade+restarts"
%dir "%{_datadir}/locale/"
%{_datadir}/locale/*
%dir "%{_datadir}/polkit-1"
%dir "%{_datadir}/polkit-1/actions"
"%{_datadir}/polkit-1"
"%{_datadir}/polkit-1/actions/net.fiasko-nw.%{name}.policy"
%{_mandir}/man1/%{name}.1*%{?ext_man}*
# ${_libdir} Resolves to '/usr/lib64/' on 64-bits Systems, but we Need the '/usr/lib/' Path
%dir "%{_prefix}/lib/%{name}/"
%{_prefix}/lib/%{name}/*
%{perl_vendorlib}/*
%changelog