File NetworkManager.spec of Package NetworkManager

#
# spec file for package NetworkManager
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


# Use systemd
%define with_systemd 1
%define with_wimax 0

Name:           NetworkManager
Url:            http://www.gnome.org/projects/NetworkManager/
Version:        0.9.8.10
Release:        0
Summary:        Network Link Manager and User Applications
License:        GPL-2.0+
Group:          Productivity/Networking/System
Source0:        http://download.gnome.org/sources/NetworkManager/0.9/%{name}-%{version}.tar.xz
Source1:        nfs
Source2:        NetworkManager.conf
Source3:        baselibs.conf
Source99:       NetworkManager-rpmlintrc
# PATCH-FEATURE-OPENSUSE systemd-network-config.patch -- don't try to start NM under systemd if it is disabled in system configuration
Patch0:         systemd-network-config.patch
# PATCH-UGLY-HACK-OPENSUSE nm-remove-AP-always-on-device-disconnect.diff lnussel@suse.com -- avoid pw dialog if AP out of range, Disabled due to issues, see bnc#768564
Patch2:         nm-remove-AP-always-on-device-disconnect.diff
# PATCH-HACK-OPENSUSE nm-don-t-consider-not-needed-secrets-for-has_system_secr.diff lnussel@suse.com -- avoid polkit popups for 802.11x
Patch3:         nm-don-t-consider-not-needed-secrets-for-has_system_secr.diff
# PATCH-HACK-OPENSUSE nm-treat-not-saved-secrets-just-like-agent-owned-when-cl.diff lnussel@suse.com -- avoid polkit popups for 802.11x
Patch4:         nm-treat-not-saved-secrets-just-like-agent-owned-when-cl.diff
# PATCH-FIX-UPSTREAM nm-probe-radius-server-cert.patch bnc#574266 glin@suse.com -- Probe the RADIUS server certificate
Patch5:         nm-probe-radius-server-cert.patch
# PATCH-FIX-OPENSUSE NetworkManager-geoclue-interaction.patch dimstar@opensuse.org -- Allow the user "srvGeoClue" to query NetworkManager on the dbus
Patch6:         NetworkManager-geoclue-interaction.patch
# PATCH-FIX-UPSTREAM nm-core-fix-crash-during-Wi-Fi-rescan-by-emitting-NM_DE.patch fcrozat@suse.com -- Fix regression in 0.9.8.10 causing crash in Wifi rescan
Patch7:         nm-core-fix-crash-during-Wi-Fi-rescan-by-emitting-NM_DE.patch
BuildRequires:  fdupes
BuildRequires:  gobject-introspection-devel
BuildRequires:  gtk-doc
BuildRequires:  intltool
BuildRequires:  iptables
BuildRequires:  libtool
BuildRequires:  ppp-devel
# Do not use suse-release, it's very late in build chain and not needed
# all it does is netconfig and ifconfig enablement
#BuildRequires:  suse-release
# for /sbin/netconfig: integration with netconfig is required
BuildRequires:  sysconfig
BuildRequires:  translation-update-upstream
BuildRequires:  vala
BuildRequires:  wireless-tools
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(dbus-glib-1) >= 0.94
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gudev-1.0)
%if %{with_wimax}
BuildRequires:  pkgconfig(libiWmxSdk-0) >= 1.5.1
%endif
BuildRequires:  pkgconfig(libnl-3.0)
BuildRequires:  pkgconfig(libnl-genl-3.0)
BuildRequires:  pkgconfig(libnl-route-3.0)
BuildRequires:  pkgconfig(libsoup-2.4) >= 2.26
%if %{with_systemd}
BuildRequires:  pkgconfig(libsystemd-login)
%endif
BuildRequires:  pkgconfig(mm-glib) >= 0.7.991
BuildRequires:  pkgconfig(nss)
BuildRequires:  pkgconfig(polkit-gobject-1)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(uuid)
Requires:       dhcp-client
Requires:       iproute2
Requires:       iputils
Requires:       mozilla-nss
%requires_eq    ppp
Requires:       sysconfig >= 0.80.5
Requires:       wpa_supplicant >= 0.6.4
%{?systemd_requires}
Provides:       dhcdbd = 1.14
Obsoletes:      dhcdbd < 1.14
Recommends:     dnsmasq
Recommends:     iptables
Recommends:     NetworkManager-client
Recommends:     org.freedesktop.ModemManager
Recommends:     avahi-autoipd
Recommends:     %{name}-lang
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define _udevdir %(pkg-config --variable udevdir udev)

%description
NetworkManager attempts to keep an active network connection available
at all times.  The point of NetworkManager is to make networking
configuration and setup as painless and automatic as possible.	If
using DHCP, NetworkManager is intended to replace default routes,
obtain IP addresses from a DHCP server, and change name servers
whenever it sees fit.

%if %{with_wimax}
%package device-plugin-wimax
Summary:        WiMAX support for NetworkManager
Group:          Productivity/Networking/System
Supplements:    %{name}

%description device-plugin-wimax
NetworkManager attempts to keep an active network connection available
at all times.  The point of NetworkManager is to make networking
configuration and setup as painless and automatic as possible.	If
using DHCP, NetworkManager is intended to replace default routes,
obtain IP addresses from a DHCP server, and change name servers
whenever it sees fit.
%endif

%package devel
Summary:        Libraries and headers for adding NetworkManager support to applications
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}
Requires:       libnm-glib-vpn1 = %{version}
Requires:       libnm-glib4 = %{version}
Requires:       libnm-util2 = %{version}
Requires:       typelib-1_0-NMClient-1_0 = %{version}
Requires:       typelib-1_0-NetworkManager-1_0 = %{version}
Provides:       %{name}-doc = %{version}
Obsoletes:      %{name}-doc < %{version}

%description devel
This package contains various headers accessing some NetworkManager
functionality from applications.

%package -n libnm-util2
Summary:        Convenience library for clients of NetworkManager
Group:          System/Libraries

%description -n libnm-util2
This package contains the libraries that make it easier to use some
Network Manager functionality from applications that use glib.

%package -n libnm-glib4
Summary:        Convenience library for clients of NetworkManager
Group:          System/Libraries
Provides:       %{name}-glib = %{version}
Obsoletes:      %{name}-glib < %{version}

%description -n libnm-glib4
This package contains the libraries that make it easier to use some
Network Manager functionality from applications that use glib.

%package -n libnm-glib-vpn1
Summary:        Convenience library for NetworkManager VPN plugins
Group:          System/Libraries

%description -n libnm-glib-vpn1
This package contains the libraries that make it easier to use some
Network Manager functionality from applications that use glib.

%package -n typelib-1_0-NetworkManager-1_0
Summary:        Convenience library for clients of NetworkManager -- Introspection bindings
Group:          System/Libraries

%description -n typelib-1_0-NetworkManager-1_0
This package contains the gi-bindings that make it easier to use some
Network Manager functionality from applications that use glib.

This package provides the GObject Introspection bindings for the
NetworkManager library.

%package -n typelib-1_0-NMClient-1_0
Summary:        Convenience library for clients of NetworkManager -- Introspection bindings
Group:          System/Libraries

%description -n typelib-1_0-NMClient-1_0
This package contains the gi-bindings that make it easier to use some
Network Manager functionality from applications that use glib.

This package provides the GObject Introspection bindings for the
NetworkManager library.

%lang_package
%prep
%setup -n %{name}-%{version} -q
translation-update-upstream
%patch0 -p1
# Disabled due to issues, see bnc#768564
#patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1

%build
pppddir=`ls -1d /usr/%_lib/pppd/2*`
test -n "$pppddir" || exit 1
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
%configure\
    --disable-static\
    --with-crypto=nss \
    --enable-ifcfg-suse \
    --with-docs\
    --with-netconfig=yes \
    --enable-more-warnings=no \
    --with-pppd-plugin-dir=$pppddir \
    --with-dhclient=/sbin/dhclient \
    --with-udev-dir=%{_udevdir} \
    --with-modem-manager-1 \
    --enable-concheck \
%if %{with_systemd}
    --with-session-tracking=systemd \
%endif
%if %{with_wimax}
    --enable-wimax
%else
    --disable-wimax
%endif
# Fail if netconfig was not detected. Avoids future occurences of bnc#817592
if grep "with_netconfig='no'" config.log; then
  print netconfig support was not found -- BUILD ABORTED
  false
fi
%__make %{?_smp_mflags} nmrundir="/run/%{name}"

%install
%makeinstall nmrundir="/run/%{name}"
find %{buildroot} -type f -name "*.la" -delete -print
%find_lang %{name}
%fdupes %{buildroot}%{_datadir}/gtk-doc/
mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/VPN
mkdir -p $RPM_BUILD_ROOT/var/log/
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/NetworkManager
touch $RPM_BUILD_ROOT/var/log/NetworkManager
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/system-connections
install -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/

%if 0%{suse_version} > 1140
# drop on demand activation, it is handled as a system service
rm -f $RPM_BUILD_ROOT%{_datadir}/dbus-1/system-services/org.freedesktop.NetworkManager.service

%pre
%service_add_pre NetworkManager.service

%post
%service_add_post NetworkManager.service
# bnc#803058:
# sysconfig creates this file while update from openSUSE < 12.3,
# which were using the NETWORKMANAGER=yes/no sysconfig variable.
# When it exists and NETWORKMANAGER were enabled, force enable to
# ensure, the network.service alias link exists points to us.
if [ -f /dev/.sysconfig/network/migrate_nm_variable ] ; then
	. /dev/.sysconfig/network/migrate_nm_variable
	if [ "X$NETWORKMANAGER" = "Xyes" ] ; then
		# In running system "--force enable" is sufficient to
		# create the network.service alias link regardless if
		# the network.service is masked or not.
		# While 12.2 -> 12.3 dist update, enable seems to be
		# unable to create the alias... no idea why. Kick it
		rm -f /etc/systemd/system/network.service
		/usr/bin/systemctl --system daemon-reload || :
		/usr/bin/systemctl --force enable NetworkManager.service || :
		# and create the alias when enable failed to make it.
		if [ ! -e /etc/systemd/system/network.service ] ; then
			ln -sf	%{_unitdir}/NetworkManager.service \
				/etc/systemd/system/network.service
		fi
		/usr/bin/systemctl --system daemon-reload || :
	fi
	rm -f /dev/.sysconfig/network/migrate_nm_variable
fi

%preun
%service_del_preun NetworkManager.service

%postun
%service_del_postun NetworkManager.service
%endif

%post -n libnm-util2 -p /sbin/ldconfig

%postun -n libnm-util2 -p /sbin/ldconfig

%post -n libnm-glib4 -p /sbin/ldconfig

%postun -n libnm-glib4 -p /sbin/ldconfig

%post -n libnm-glib-vpn1 -p /sbin/ldconfig

%postun -n libnm-glib-vpn1 -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc COPYING ChangeLog NEWS AUTHORS README CONTRIBUTING TODO
%{_bindir}/nm-online
%{_bindir}/nm-tool
%{_bindir}/nmcli
%{_datadir}/bash-completion/completions/nmcli
%{_sbindir}/NetworkManager
%{_datadir}/dbus-1/system-services/org.freedesktop.nm_dispatcher.service
%{_datadir}/polkit-1/actions/org.freedesktop.NetworkManager.policy
%attr(0700,root,root) %{_localstatedir}/lib/NetworkManager
%doc %{_mandir}/man1/nm-online.*
%doc %{_mandir}/man1/nm-tool.*
%doc %{_mandir}/man1/nmcli.*
%doc %{_mandir}/man5/NetworkManager.conf.5%{?ext_man}
%doc %{_mandir}/man5/nm-settings.5%{?ext_man}
%doc %{_mandir}/man5/nm-system-settings.conf.5%{?ext_man}
%doc %{_mandir}/man8/NetworkManager.*
%dir %{_libdir}/NetworkManager/
%{_libdir}/NetworkManager/libnm-settings-plugin-ifcfg-suse.so
%dir %{_libdir}/pppd/2.*
%{_libdir}/pppd/2.*/nm-pppd-plugin.*
%{_libexecdir}/nm-avahi-autoipd.action
%{_libexecdir}/nm-dhcp-client.action
%{_libexecdir}/nm-dispatcher.action
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.NetworkManager.conf
%{_sysconfdir}/dbus-1/system.d/nm-avahi-autoipd.conf
%{_sysconfdir}/dbus-1/system.d/nm-dhcp-client.conf
%{_sysconfdir}/dbus-1/system.d/nm-dispatcher.conf
%dir %{_sysconfdir}/NetworkManager
%dir %{_sysconfdir}/NetworkManager/VPN
%dir %{_sysconfdir}/NetworkManager/dispatcher.d
%dir %{_sysconfdir}/NetworkManager/system-connections
%config(noreplace) %{_sysconfdir}/NetworkManager/NetworkManager.conf
%attr(0755,root,root) %{_sysconfdir}/NetworkManager/dispatcher.d/nfs
%{_unitdir}/NetworkManager.service
%{_unitdir}/NetworkManager-dispatcher.service
%{_unitdir}/NetworkManager-wait-online.service
%{_udevdir}/rules.d/77-nm-olpc-mesh.rules
%ghost %config(noreplace) /var/log/NetworkManager

%if %{with_wimax}
%files device-plugin-wimax
%defattr(-,root,root)
%{_libdir}/NetworkManager/libnm-device-plugin-wimax.so
%endif

%files devel
%defattr(-,root,root)
%{_includedir}/NetworkManager/
%{_includedir}/libnm-glib/
%{_datadir}/gir-1.0/*.gir
%dir %{_datadir}/vala/vapi
%{_datadir}/vala/vapi/libnm-glib.deps
%{_datadir}/vala/vapi/libnm-glib.vapi
%{_datadir}/vala/vapi/libnm-util.deps
%{_datadir}/vala/vapi/libnm-util.vapi
%{_libdir}/libnm-util.so
%{_libdir}/libnm-glib.so
%{_libdir}/libnm-glib-vpn.so
%{_libdir}/pkgconfig/NetworkManager.pc
%{_libdir}/pkgconfig/libnm-util.pc
%{_libdir}/pkgconfig/libnm-glib.pc
%{_libdir}/pkgconfig/libnm-glib-vpn.pc
%doc %{_datadir}/gtk-doc/html/NetworkManager/
%doc %{_datadir}/gtk-doc/html/libnm-glib/
%doc %{_datadir}/gtk-doc/html/libnm-util/

%files -n libnm-util2
%defattr(-,root,root)
%{_libdir}/libnm-util.so.*

%files -n libnm-glib4
%defattr(-,root,root)
%{_libdir}/libnm-glib.so.*

%files -n libnm-glib-vpn1
%defattr(-,root,root)
%{_libdir}/libnm-glib-vpn.so.*

%files -n typelib-1_0-NetworkManager-1_0
%defattr(-,root,root)
%{_libdir}/girepository-1.0/NetworkManager-1.0.typelib

%files -n typelib-1_0-NMClient-1_0
%defattr(-,root,root)
%{_libdir}/girepository-1.0/NMClient-1.0.typelib

%files lang -f %{name}.lang

%changelog