From 28d2c07661f6e8c4305a5a7f66db346b09a607e2 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 21 May 2018 17:40:41 +0200 Subject: rpm: install alternative implementations of ifup/ifdown Unless the initscripts package too old to allow alternatives is present, install nmcli as an alternative implementation of ifup and ifdown. The triggerin scriptlet allow us to do the right thing regardless of which initscripts version is installed or even when it's upgraded. The initscripts patch was included in Fedora 29: https://github.com/fedora-sysv/initscripts/pull/197 --- contrib/fedora/rpm/NetworkManager.spec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index c6f265c217..7289bc4fc2 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -116,7 +116,9 @@ Source3: 20-connectivity-fedora.conf #Patch1: 0001-some.patch Requires(post): systemd +Requires(post): /sbin/update-alternatives Requires(preun): systemd +Requires(preun): /sbin/update-alternatives Requires(postun): systemd Requires: dbus >= %{dbus_version} @@ -565,6 +567,8 @@ mkdir -p %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version} cp valgrind.suppressions %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version} %endif +touch %{buildroot}%{_sbindir}/ifup %{buildroot}%{_sbindir}/ifdown + %check %if %{with test} @@ -588,6 +592,15 @@ fi %systemd_post NetworkManager.service NetworkManager-wait-online.service NetworkManager-dispatcher.service +%triggerin -- initscripts +if [ -f %{_sbindir}/ifup -a ! -L %{_sbindir}/ifup ]; then + # initscripts package too old, won't let us set an alternative + /usr/sbin/update-alternatives --remove ifup %{_libexecdir}/nm-ifup >/dev/null 2>&1 || : +else + /usr/sbin/update-alternatives --install %{_sbindir}/ifup ifup %{_libexecdir}/nm-ifup 50 \ + --slave %{_sbindir}/ifdown ifdown %{_libexecdir}/nm-ifdown +fi + %preun if [ $1 -eq 0 ]; then # Package removal, not upgrade @@ -595,6 +608,8 @@ if [ $1 -eq 0 ]; then # Don't kill networking entirely just on package remove #/bin/systemctl stop NetworkManager.service >/dev/null 2>&1 || : + + /usr/sbin/update-alternatives --remove ifup %{_libexecdir}/nm-ifup >/dev/null 2>&1 || : fi %systemd_preun NetworkManager-wait-online.service NetworkManager-dispatcher.service @@ -628,6 +643,10 @@ fi %dir %{_sysconfdir}/%{name}/dnsmasq-shared.d %config(noreplace) %{_sysconfdir}/%{name}/NetworkManager.conf %{_bindir}/nm-online +%{_libexecdir}/nm-ifup +%ghost %{_sbindir}/ifup +%{_libexecdir}/nm-ifdown +%ghost %{_sbindir}/ifdown %{_libexecdir}/nm-dhcp-helper %{_libexecdir}/nm-dispatcher %{_libexecdir}/nm-iface-helper -- cgit v1.2.1