File sysconfig.spec of Package sysconfig

# spec file for package sysconfig
# Copyright (c) 2016 SUSE LINUX 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

%if 0%{?suse_version} >= 1230
%define         udevdir	%{_prefix}/lib/udev
BuildRequires:  pkgconfig(systemd)
%define         udevdir	/lib/udev
Name:           sysconfig
Version:        0.84.0
Release:        0
Summary:        The sysconfig scheme for traditional network scripts
License:        GPL-2.0+
Group:          System/Base
Source:         %{name}-%{version}.tar.bz2
BuildRequires:  libtool
BuildRequires:  pkgconfig
Requires:       /sbin/ifup
Requires:       /sbin/netconfig
Requires:       sysvinit(network)
PreReq:         %fillup_prereq %insserv_prereq textutils fileutils gawk sed grep
Recommends:     wicked-service
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

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

%package netconfig
Summary:        Script to apply network provided settings
Group:          System/Base
Requires:       /bin/logger
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.

%setup -q

autoreconf -fvi
CFLAGS="%{optflags} -fPIC" \
%configure --prefix=/ \
            --sbindir=/sbin \
            --libdir=/%{_lib} \
            --sysconfdir=%{_sysconfdir} \
            --mandir=%{_mandir} \
            --with-unitdir=%{_unitdir} \
            --with-udevdir=%{udevdir} \
make %{?_smp_mflags}

make %{?_smp_mflags} check

make %{?_smp_mflags} DESTDIR=%{buildroot} install
touch %{buildroot}%{_sysconfdir}/sysconfig/network/config
touch %{buildroot}%{_sysconfdir}/sysconfig/network/dhcp
mkdir -p %{buildroot}/sbin
ln -s /sbin/service %{buildroot}/sbin/rcnetwork

%dir %{_sysconfdir}/modprobe.d
%config %{_sysconfdir}/modprobe.d/50-blacklist.conf
%config %{_sysconfdir}/sysconfig/network/ifcfg.template
%ghost %{_sysconfdir}/sysconfig/network/config
%ghost %{_sysconfdir}/sysconfig/network/dhcp
%dir %{_docdir}/sysconfig
%doc %{_docdir}/sysconfig/Contents
%doc %{_docdir}/sysconfig/COPYING
%dir %attr(0750,root,dialout) %{_sysconfdir}/ppp
%dir %{_sysconfdir}/ppp/ip-up.d
%dir %{_sysconfdir}/ppp/ip-down.d
%dir %{_sysconfdir}/ppp/ipv6-up.d
%dir %{_sysconfdir}/ppp/ipv6-down.d
%dir %{_sysconfdir}/ppp/pre-start.d
%dir %{_sysconfdir}/ppp/post-stop.d

%files netconfig
%dir %{_sysconfdir}/netconfig.d
%doc %{_docdir}/sysconfig/netconfig.png

# package update ?
if [ ${1:-0} -gt 1 ]; then
	# trigger update from < 0.80.x only (-> openSUSE 12.3),
	# (guard for variable added to network/config later...)
	if [ -x %{_sbindir}/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 || :

## 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
# remove obsolete sysconfig-network specific variables
sysconfig_remove_and_set network/config NOZEROCONF
sysconfig_remove_and_set network/config LINKLOCAL_INTERFACES
sysconfig_remove_and_set network/config IFPLUGD_OPTIONS
sysconfig_remove_and_set network/config DEFAULT_BROADCAST
sysconfig_remove_and_set network/config FORCE_PERSISTENT_NAMES
sysconfig_remove_and_set network/config MANDATORY_DEVICES
sysconfig_remove_and_set network/config USE_SYSLOG
sysconfig_remove_and_set network/dhcp   DHCLIENT_BIN
sysconfig_remove_and_set network/dhcp   DHCLIENT6_BIN
sysconfig_remove_and_set network/dhcp   DHCLIENT_DEBUG
sysconfig_remove_and_set network/dhcp   DHCLIENT_WAIT_LINK
sysconfig_remove_and_set network/dhcp   DHCLIENT_USER_OPTIONS
sysconfig_remove_and_set network/dhcp   DHCLIENT_PRIMARY_DEVICE
sysconfig_remove_and_set network/dhcp   DHCLIENT6_USER_OPTIONS
sysconfig_remove_and_set network/dhcp   DHCPCD_USER_OPTIONS
sysconfig_remove_and_set network/dhcp   DHCP6C_USER_OPTIONS
%{fillup_only -dns dhcp network network}
%{fillup_only -dns config network network}
# remove obsolete dhcp and per interface variables
for file in etc/sysconfig/network/dhcp etc/sysconfig/network/ifcfg-* ; do
	case $name in
	(lo|""|*" "*|*~|*.old|*.rpmnew|*.rpmsave|*.scpmbackup) continue ;;
	case $file in
		(*/ifcfg-*) umask 0177 ;;
	sysconfig_remove_and_set -b "" $file \
	umask $_umask
# be a little bit paranoid and set the correct mode even we set umask
chmod 0600 etc/sysconfig/network/ifcfg-* 2>/dev/null || :
# bnc#803058: migrate from NETWORKMANAGER=yes/no variable to
#             network.service alias link masking rcnetwork.
if [ -f /dev/.sysconfig/network/migrate_nm_variable -a -x %{_bindir}/systemctl ] ; then
	. /dev/.sysconfig/network/migrate_nm_variable
		# NetworkManager.service were always started before; stop
		# and disable it, so %{_initddir}/network isn't masked...
		# kill all, NM is using KillMode=Process (bnc#895447)
		%{_bindir}/systemctl --kill-who=all kill NetworkManager.service || :
		%{_bindir}/systemctl stop NetworkManager.service || :
		%{_bindir}/systemctl --force disable NetworkManager.service || :
		rm -f /dev/.sysconfig/network/migrate_nm_variable || :
		# Keep the /dev/.sysconfig/network/migrate_nm_variable file,
		# as hint for migration in NetworkManager post-install ...
		# Mask %{_initddir}/network service until NM update is done.
		%{_bindir}/systemctl --force mask network.service || :
	# cleanup obsolete NETWORKMANAGER variable
	sysconfig_remove_and_set network/config NETWORKMANAGER

%postun -p /sbin/ldconfig
if test "$1" = "0" -a -x %{_initddir}/network ; then
	%{_initddir}/network stop-all-dhcp-clients 2>/dev/null || :