File sysconfig.spec of Package sysconfig

#
# spec file for package sysconfig
#
# Copyright (c) 2013 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/
#


Name:           sysconfig
Version:        0.81.5
Release:        0
Summary:        The sysconfig scheme for traditional network scripts
License:        GPL-2.0+
Group:          System/Base
Url:            https://github.com/openSUSE/sysconfig
PreReq:         %fillup_prereq %insserv_prereq textutils fileutils gawk sed grep
BuildRequires:  libtool
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1230
BuildRequires:  pkgconfig(systemd)
%define         udevdir	/usr/lib/udev
%else
%define         udevdir	/lib/udev
%endif
Source:         %name-%version.tar.bz2
Requires:       /sbin/ifup
Requires:       /sbin/netconfig
Requires:       udevmountd = %{version}
Requires:       sysvinit(network)
Recommends:     sysconfig-network = %{version}
Patch1:         0001-bt878-card-causes-udevd-to-complain-bnc-800897.patch
Patch2:         sysconfig-0.81.5-netconfig-use_systemctl.patch
Patch3:         sysconfig-0.81.5-restore_selinux_context_on_RUN_FILES_BASE.patch
Patch4:         0004-blacklist-udlfb-because-only-udl-can-be-used-with-xr.patch
Patch5:         0005-fix-starting-dhcpcd-from-ifplugd-bnc-846031.patch

%description
This package provides the SuSE system configuration scheme for the
traditional "ifup" alias "netcontrol" network scripts.

Authors:
--------
    Olaf Kirch <okir@suse.de>
    Bjoern Jacke <bjoern@j3e.de>
    Mads Martin Joergensen <mmj@suse.de>
    Peter Poeml <poeml@suse.de>
    Arvin Schnell <arvin@suse.de>
    Michal Svec <msvec@suse.cz>
    Christian Zoz <zoz@suse.de>
    Werner Fink <werner@suse.de>
    Hannes Reinecke <hare@suse.de>
    Marius Tomaschewski <mt@suse.de>

%package -n udevmountd
Summary:        Automount daemon for udev
Group:          System/Base
Requires(pre):  sysconfig = %{version}

%description -n udevmountd
This package provides the udev mount daemon and its udev rule.

Authors:
--------
    Hannes Reinecke <hare@suse.de>


%package netconfig
Summary:        Script to apply network provided settings
Group:          System/Base
Requires(pre):  sysconfig = %{version}
Provides:       /sbin/netconfig

%description netconfig
This package provides the netconfig scripts to apply network
provided settings like DNS or NIS into system files.

Authors:
--------
    Michael Calmer <mc@suse.de>
    Marius Tomaschewski <mt@suse.de>
    Milisav Radmanic <radmanic@suse.de>


%package network
Summary:        Traditional network scripts
Group:          System/Base
Requires(pre):  sysconfig = %{version}
Requires:       /sbin/netconfig
Requires:       bridge-utils
Requires:       iproute2
Requires:       procps
Requires:       tunctl
Requires:       vlan
Provides:       /sbin/ifup
Conflicts:      otherproviders(/sbin/ifup)

%description network
This package provides the traditional "ifup" alias "netcontrol"
network scripts.

Authors:
--------
    Olaf Kirch <okir@suse.de>
    Bjoern Jacke <bjoern@j3e.de>
    Mads Martin Joergensen <mmj@suse.de>
    Peter Poeml <poeml@suse.de>
    Arvin Schnell <arvin@suse.de>
    Michal Svec <msvec@suse.cz>
    Christian Zoz <zoz@suse.de>
    Werner Fink <werner@suse.de>
    Hannes Reinecke <hare@suse.de>
    Marius Tomaschewski <mt@suse.de>


%prep
%setup -n sysconfig-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1

%build
autoreconf --force --install
CFLAGS="$RPM_OPT_FLAGS -fPIC" \
./configure --prefix=/ \
            --sbindir=/sbin \
            --libdir=/%_lib \
            --sysconfdir=%_sysconfdir \
            --mandir=%_mandir \
            --with-unitdir=%_unitdir \
            --with-udevdir=%udevdir \
            --with-fillup-templatesdir=/var/adm/fillup-templates
%{__make} %{?_smp_mflags}

%check
make check

%clean
rm -rf $RPM_BUILD_ROOT

%install
make DESTDIR=$RPM_BUILD_ROOT install
touch $RPM_BUILD_ROOT/etc/sysconfig/network/config
touch $RPM_BUILD_ROOT/etc/sysconfig/network/dhcp
# remove template dir
rm -rf $RPM_BUILD_ROOT/etc/sysconfig/network/ifservices.template/

%files
%defattr(-,root,root)
%dir /etc/modprobe.d
%config /etc/modprobe.d/50-blacklist.conf
%config /etc/sysconfig/network/ifcfg.template
%ghost /etc/sysconfig/network/config
%ghost /etc/sysconfig/network/dhcp
%config(noreplace) %attr(600,root,root) /etc/sysconfig/network/ifcfg-lo
%config(noreplace) /etc/sysconfig/network/ifroute-lo
%dir /usr/share/doc/packages/sysconfig
%doc /usr/share/doc/packages/sysconfig/Contents
%doc /usr/share/doc/packages/sysconfig/COPYING

%files network
%defattr(-,root,root)
%config(noreplace) /etc/ppp/ip-up
%config(noreplace) /etc/ppp/ip-down
%config(noreplace) /etc/ppp/ipv6-up
%config(noreplace) /etc/ppp/ipv6-down
/etc/ppp/poll.tcpip
%udevdir/rules.d/77-network.rules
/etc/sysconfig/network/scripts/functions
/etc/sysconfig/network/scripts/functions.common
/etc/sysconfig/network/scripts/functions.rpm-utils
/etc/sysconfig/network/scripts/extradebug
/etc/sysconfig/network/scripts/if*
/etc/sysconfig/network/scripts/convert*
/etc/sysconfig/network/scripts/move_shm_sysconfig.sh
/etc/sysconfig/network/scripts/create-ifservices-directory
/etc/sysconfig/network/scripts/dhcpcd-hook
/etc/sysconfig/network/scripts/link_wait
/etc/sysconfig/network/if-up.d/ndp-proxy
/etc/sysconfig/network/if-down.d/ndp-proxy
/usr/share/omc/svcinfo.d/network.xml
/var/adm/fillup-templates/sysconfig.dhcp-network
/var/adm/fillup-templates/sysconfig.config-network
%dir /usr/share/doc/packages/sysconfig
%doc /usr/share/doc/packages/sysconfig/Network
%doc /usr/share/doc/packages/sysconfig/README*
%_mandir/*/if*
%_mandir/*/routes*
%_unitdir/network@.service
%_unitdir/network.service
/etc/init.d/network
/sbin/if*
/sbin/autoip
/sbin/rcnetwork

%files netconfig
%defattr(-,root,root)
%dir /etc/netconfig.d
/etc/netconfig.d/*
/etc/sysconfig/network/scripts/functions.netconfig
/sbin/netconfig
/usr/share/man/man8/netconfig.8.gz
%doc /usr/share/doc/packages/sysconfig/netconfig.png

%files -n udevmountd
%defattr(-,root,root)
%dir %udevdir
%udevdir/udevmountd
%dir %udevdir/rules.d
%udevdir/rules.d/81-mount.rules

%pre network
# package update ?
if [ ${1:-0} -gt 1 ]; then
	# update to >= 0.72.1 (-> openSUSE 11.2)
	if [ ! -f etc/sysconfig/network/scripts/move_shm_sysconfig.sh ] ; then
		touch etc/sysconfig/network/__move_shm_sysconfig__
	fi
	# trigger update from < 0.80.x only (-> openSUSE 12.3),
	# (guard for variable added to network/config later...)
	if [ -x /usr/sbin/NetworkManager ] && grep -qs "^NETWORKMANAGER=" \
		var/adm/fillup-templates/sysconfig.config-network ; then
		mkdir -p /dev/.sysconfig/network/ && \
		grep -s "^NETWORKMANAGER=" etc/sysconfig/network/config \
			> /dev/.sysconfig/network/migrate_nm_variable || :
	elif [ -f /dev/.sysconfig/network/migrate_nm_variable ] ; then
		rm -f /dev/.sysconfig/network/migrate_nm_variable || :
	fi
fi

%post network
# * update to >= 0.72.1: before anything else, move state
#   files from dev/shm/sysconfig to dev/.sysconfig/network
if [ -f etc/sysconfig/network/__move_shm_sysconfig__ ] ; then
	etc/sysconfig/network/scripts/move_shm_sysconfig.sh .
	rm -f etc/sysconfig/network/__move_shm_sysconfig__
fi
#
## we provide own, improved variant of the remove_and_set suse
## rpm macro that is able to handle files in subdirs, and more
. etc/sysconfig/network/scripts/functions.rpm-utils
#
%{fillup_and_insserv -fY network}
%{fillup_only -dns dhcp network network}
%{fillup_only -dns config network network}
/sbin/ldconfig
echo "Removing old autogenerated device configuration files:"
#
# * update to >= 11.1 / SLE11:
#
# convert dns / modify_resolvconf to netconfig
if [ -e etc/sysconfig/network/scripts/convert_to_netconfig_dns ] ; then
    ROOT=$PWD bash etc/sysconfig/network/scripts/convert_to_netconfig_dns
fi
# convert nis / dhclient variables to netconfig
if [ -e etc/sysconfig/network/scripts/convert_to_netconfig_nis ] ; then
    ROOT=$PWD bash etc/sysconfig/network/scripts/convert_to_netconfig_nis
fi
# remove ntp variables obsoleted by netconfig (new default is "yes")
# as well as some another obsolete dhcp variables
_umask=`umask`
for file in etc/sysconfig/network/dhcp etc/sysconfig/network/ifcfg-* ; do
	name="${file##*\/ifcfg-}"
	case $name in
	(lo|""|*" "*|*~|*.old|*.rpmnew|*.rpmsave|*.scpmbackup) continue ;;
	esac
	case $file in
		(*/ifcfg-*) umask 0177 ;;
	esac
	sysconfig_remove_and_set -b "" $file \
		DHCLIENT_MODIFY_NTP_CONF     \
		DHCLIENT_ADDITIONAL_OPTIONS  \
		DHCLIENT_SCRIPT_EXE
	umask $_umask
done
# be a little bit paranoid and set the correct mode even we set umask
chmod 0600 etc/sysconfig/network/ifcfg-*
# bnc#803058: migrate from NETWORKMANAGER=yes/no variable to
#             network.service alias link masking rcnetwork.
enable=yes
if [ -f /dev/.sysconfig/network/migrate_nm_variable -a -x /usr/bin/systemctl ] ; then
	. /dev/.sysconfig/network/migrate_nm_variable
	case $NETWORKMANAGER in
	no)
		# NetworkManager.service were always started before; stop
		# and disable it, so /etc/init.d/network isn't masked...
		/usr/bin/systemctl stop NetworkManager.service || :
		/usr/bin/systemctl --force disable NetworkManager.service || :
		rm -f /dev/.sysconfig/network/migrate_nm_variable || :
	;;
	yes)
		# Keep the /dev/.sysconfig/network/migrate_nm_variable file,
		# as hint for migration in NetworkManager post-install ...
		# Mask /etc/init.d/network service until NM update is done.
		/usr/bin/systemctl --force mask network.service || :
		enable=no
	;;
	esac
else
	# cleanup obsolete NETWORKMANAGER variable
	sysconfig_remove_and_set network/config NETWORKMANAGER
fi
if test "$enable" = "yes" -a -x /usr/bin/systemctl ; then
	_id=`/usr/bin/systemctl --no-pager -p Id show network.service 2>/dev/null` || :
	case "${_id#Id=}" in
	""|network.service)
		/usr/bin/systemctl --system daemon-reload || :
		/usr/bin/systemctl --force enable network.service || :
	;;
	esac
fi

%postun network
%{insserv_cleanup}
/sbin/ldconfig

%preun network
if test "$1" = "0" -a -x /etc/init.d/network ; then
	/etc/init.d/network stop-all-dhcp-clients || :
fi

%changelog
openSUSE Build Service is sponsored by