File wicked.spec of Package wicked

#
# spec file for package wicked
#
# 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/
#


%define		release_prefix  %{?snapshot:%{snapshot}}%{!?snapshot:0}
Name:           wicked
Version:        0.5.26
Release:        %{release_prefix}.0.0
Summary:        Network configuration infrastructure
License:        GPL-2.0
Group:          System/Management
Url:            https://github.com/openSUSE/wicked
Source0:        %{name}-%{version}.tar.bz2
Source1:        wicked-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  make
Requires(pre):  libwicked0 = %{version}

%if 0%{?suse_version} >= 1230
%bcond_without  systemd
%bcond_with     dbusstart
%else
%bcond_with     systemd
%bcond_with     dbusstart
%endif

%bcond_with     wicked_devel

BuildRequires:  libnl3-devel
%if 0%{?suse_version} > 1110
BuildRequires:  libiw-devel
%else
BuildRequires:  wireless-tools
%endif
BuildRequires:  dbus-1-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  pkg-config

%if %{with systemd}
%{?systemd_requires}
BuildRequires:  pkgconfig(systemd)
%if 0%{?suse_version:1}
Requires(pre):  %fillup_prereq
Requires:       sysconfig-netconfig
%endif
Requires:       %{name}-service = %{version}
%else
%if 0%{?suse_version:1}
PreReq:         %fillup_prereq %insserv_prereq
%endif
%endif
%if %{defined _rundir}
%define         wicked_piddir   %_rundir/%{name}
%define         wicked_statedir %_rundir/%{name}
%else
%define         wicked_piddir   %_localstatedir/run/%{name}
%define         wicked_statedir %_localstatedir/run/%{name}
%endif
%define         wicked_storedir %_localstatedir/lib/%{name}

%description
Wicked is a network configuration infrastructure incorporating a number
of existing frameworks into a unified architecture, providing a DBUS
interface to network configuration.

%if %{with systemd}

%package service
Summary:        Network configuration infrastructure - systemd service
Group:          System/Management
Requires(pre):  %name = %{version}
Requires:       sysconfig >= 0.81.0
Provides:       /sbin/ifup
Provides:       sysvinit(network)
Conflicts:      otherproviders(/sbin/ifup)
Obsoletes:      sysconfig-network

%description service
Wicked is a network configuration infrastructure incorporating a number
of existing frameworks into a unified architecture, providing a DBUS
interface to network configuration.

This package provides the wicked systemd service files.

%else

%package service
Summary:        Network configuration infrastructure - SysVinit service
Group:          System/Management
Requires(pre):  %name = %{version}
Provides:       /sbin/ifup
Provides:       sysvinit(network)
# sysvinit test package only, unsupported -> no more deps

%description service
Wicked is a network configuration infrastructure incorporating a number
of existing frameworks into a unified architecture, providing a DBUS
interface to network configuration.

This package provides the wicked system V init scripts.

%endif

%if %{with wicked_devel}
%package devel
Summary:        Network configuration infrastructure - Development files
Group:          Development/Libraries/C and C++
Requires:       dbus-1-devel
Requires:       libnl3-devel
Requires:       libwicked0 = %{version}

%description devel
Wicked is a network configuration infrastructure incorporating a number
of existing frameworks into a unified architecture, providing a DBUS
interface to network configuration.

This package provides the wicked development files.
%endif

%package -n     libwicked0
Summary:        Network configuration infrastructure - Shared library
Group:          System/Management

%description -n libwicked0
Wicked is a network configuration infrastructure incorporating a number
of existing frameworks into a unified architecture, providing a DBUS
interface to network configuration.

This package provides the wicked shared library.


%prep
%setup

%build
test -x ./configure || autoreconf --force --install
export CFLAGS="$RPM_OPT_FLAGS"
%configure \
	--with-piddir=%{wicked_piddir}	\
	--with-statedir=%{wicked_statedir}\
	--with-storedir=%{wicked_storedir}\
	--with-compat=suse		\
%if %{with systemd}
	--enable-systemd		\
%else
	--enable-systemv		\
%endif
%if ! %{with dbusstart}
	--without-dbus-servicedir	\
%endif
	--disable-static
make %{?_smp_mflags}

%install
make install DESTDIR=${RPM_BUILD_ROOT}
# install /sbin/{ifup,ifown,ifstatus,ifprobe} links
%if "%_sbindir" != "/sbin"
%__mkdir_p -m 0755 ${RPM_BUILD_ROOT}/sbin
%__ln_s %_sbindir/ifup	${RPM_BUILD_ROOT}/sbin/ifup
%endif
%__ln_s %_sbindir/ifup	${RPM_BUILD_ROOT}/sbin/ifdown
%__ln_s %_sbindir/ifup	${RPM_BUILD_ROOT}/sbin/ifstatus
%__ln_s %_sbindir/ifup  ${RPM_BUILD_ROOT}/sbin/ifprobe
# remove libwicked.a and la
%__rm -f ${RPM_BUILD_ROOT}%_libdir/libwicked*.*a
# create reboot-persistent (leases) store directory
%__mkdir_p -m 0750 ${RPM_BUILD_ROOT}%{wicked_storedir}
%if %{with systemd}
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwicked
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwickedd
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwickedd-nanny
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwickedd-dhcp6
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwickedd-dhcp4
ln -sf %_sbindir/service ${RPM_BUILD_ROOT}%_sbindir/rcwickedd-auto4
%else
ln -sf %_sysconfdir/init.d/wickedd ${RPM_BUILD_ROOT}%_sbindir/rcwickedd
ln -sf %_sysconfdir/init.d/network ${RPM_BUILD_ROOT}%_sbindir/rcnetwork
%endif

%if %{without wicked_devel}
pushd $RPM_BUILD_ROOT
rm -rfv \
	.%_libdir/libwicked*.so \
	.%_datadir/pkgconfig/wicked.pc \
	.%_mandir/man7/wicked.7* \
	.%_includedir/wicked
popd
%endif

%if %{with systemd}

%pre service
_id=`/usr/bin/systemctl --no-pager -p Id show network.service 2>/dev/null` || :
if test "x${_id#Id=}" = "xnetwork.service" -a -x /etc/init.d/network ; then
	/etc/init.d/network stop-all-dhcp-clients || :
fi
%{service_add_pre wicked.service}

%post service
%{service_add_post wicked.service}
# See bnc#843526: presets do not apply for upgrade / are not sufficient
#                 to handle sysconfig-network|wicked -> wicked migration
_id=`/usr/bin/systemctl --no-pager -p Id show network.service 2>/dev/null` || :
case "${_id#Id=}" in
""|wicked.service|network.service)
	/usr/bin/systemctl --system daemon-reload || :
	/usr/bin/systemctl --force enable wicked.service || :
;;
esac

%preun service
# stop the daemons on removal
%{service_del_preun wickedd.service}
%{service_del_preun wickedd-auto4.service}
%{service_del_preun wickedd-dhcp4.service}
%{service_del_preun wickedd-dhcp6.service}
%{service_del_preun wickedd-nanny.service}

%postun service
%{service_del_postun wickedd.service}

%else

%post service
%{fillup_and_insserv wickedd}

%preun service
if test -x /etc/init.d/wicked ; then
	%stop_on_removal wickedd
fi

%postun service
if test -x /etc/init.d/wicked ; then
	%restart_on_update wickedd
fi
%insserv_cleanup

%endif

%post -n libwicked0
/sbin/ldconfig

%postun -n libwicked0
/sbin/ldconfig

%post
%{fillup_only -dns config wicked network}

%files
%defattr (-,root,root)
%doc ChangeLog ANNOUNCE COPYING README TODO samples
%_sbindir/wicked
%_sbindir/wickedd
%_sbindir/wickedd-nanny
%dir %_libexecdir/%{name}
%dir %_libexecdir/%{name}/bin
%_libexecdir/%{name}/bin/wickedd-auto4
%_libexecdir/%{name}/bin/wickedd-dhcp4
%_libexecdir/%{name}/bin/wickedd-dhcp6
%dir %_sysconfdir/wicked
%config(noreplace) %_sysconfdir/wicked/common.xml
%config(noreplace) %_sysconfdir/wicked/client.xml
%config(noreplace) %_sysconfdir/wicked/server.xml
%config(noreplace) %_sysconfdir/wicked/nanny.xml
%dir %_sysconfdir/wicked/extensions
%config(noreplace) %_sysconfdir/wicked/extensions/*
%dir %_sysconfdir/wicked/ifconfig
%dir %_sysconfdir/dbus-1
%dir %_sysconfdir/dbus-1/system.d
%config(noreplace) %_sysconfdir/dbus-1/system.d/org.opensuse.Network.conf
%config(noreplace) %_sysconfdir/dbus-1/system.d/org.opensuse.Network.AUTO4.conf
%config(noreplace) %_sysconfdir/dbus-1/system.d/org.opensuse.Network.DHCP4.conf
%config(noreplace) %_sysconfdir/dbus-1/system.d/org.opensuse.Network.DHCP6.conf
%config(noreplace) %_sysconfdir/dbus-1/system.d/org.opensuse.Network.Nanny.conf
%if %{with dbusstart}
%dir %_datadir/dbus-1
%dir %_datadir/dbus-1/system-services
%_datadir/dbus-1/system-services/org.opensuse.Network.*.service
%endif
%dir %_datadir/wicked
%dir %_datadir/wicked/schema
%_datadir/wicked/schema/*.xml
%_mandir/man5/wicked-config.5*
%_mandir/man5/ifcfg-bonding.5*
%_mandir/man5/ifcfg-bridge.5*
%_mandir/man5/ifcfg-dummy.5*
%_mandir/man5/ifcfg-macvlan.5*
%_mandir/man5/ifcfg-macvtap.5*
%_mandir/man5/ifcfg-tunnel.5*
%_mandir/man5/ifcfg-vlan.5*
%_mandir/man5/ifcfg-wireless.5*
%_mandir/man5/ifcfg.5*
%_mandir/man5/ifroute.5*
%_mandir/man5/ifsysctl.5*
%_mandir/man5/routes.5*
%_mandir/man8/wicked.8*
%_mandir/man8/wickedd.8*
%_mandir/man8/ifdown.8*
%_mandir/man8/ifstatus.8*
%_mandir/man8/ifup.8*
%_localstatedir/adm/fillup-templates/sysconfig.config-wicked
%attr(0750,root,root) %dir        %wicked_storedir

%if %{with systemd}

%files service
%defattr (-,root,root)
%_unitdir/wickedd-auto4.service
%_unitdir/wickedd-dhcp4.service
%_unitdir/wickedd-dhcp6.service
%_unitdir/wickedd-nanny.service
%_unitdir/wickedd.service
%_unitdir/wicked.service
%attr(0600,root,root) %config /etc/sysconfig/network/ifcfg-lo
%_sbindir/ifup
%if "%_sbindir" != "/sbin"
/sbin/ifup
%endif
/sbin/ifdown
/sbin/ifstatus
/sbin/ifprobe
%_sbindir/rcwickedd-nanny
%_sbindir/rcwickedd-dhcp6
%_sbindir/rcwickedd-dhcp4
%_sbindir/rcwickedd-auto4
%_sbindir/rcwickedd
%_sbindir/rcwicked

%else

%files service
%defattr (-,root,root)
%_sysconfdir/init.d/wickedd
%_sysconfdir/init.d/network
%_sbindir/rcwickedd
%_sbindir/rcnetwork
%attr(0600,root,root) %config /etc/sysconfig/network/ifcfg-lo
%_sbindir/ifup
%if "%_sbindir" != "/sbin"
/sbin/ifup
%endif
/sbin/ifdown
/sbin/ifstatus
/sbin/ifprobe

%endif

%if %{with wicked_devel}
%files devel
%defattr (-,root,root)
%dir %_includedir/wicked
%_includedir/wicked/*
%_libdir/libwicked*.so
%_datadir/pkgconfig/wicked.pc
%_mandir/man7/wicked.7*
%endif

%files -n libwicked0
%defattr (-,root,root)
%_libdir/libwicked*.so.*

%changelog
openSUSE Build Service is sponsored by