From 59dad2ca805aed87c943a277dee6c4cd520b3877 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Mon, 14 Dec 2015 16:26:31 -0800 Subject: [PATCH] debian: sync debian files with from upstream debian repo These include changes that were done to move ifupdown2 to use pybuild and some debian policy fixes Signed-off-by: Roopa Prabhu --- debian/changelog | 5 + debian/clean | 4 + debian/compat | 1 + debian/control | 31 +++ debian/copyright | 12 +- debian/ifupdown2.bash-completion | 1 + debian/ifupdown2.dirs | 1 + debian/ifupdown2.docs | 1 + debian/ifupdown2.examples | 1 + debian/ifupdown2.install | 2 + debian/ifupdown2.links | 6 + debian/ifupdown2.manpages | 5 + debian/ifupdown2.networking.service | 10 + ...-ifupdown2.postinst => ifupdown2.postinst} | 42 +--- ...thon-ifupdown2.postrm => ifupdown2.postrm} | 22 +-- debian/networking.default | 17 ++ debian/networking.init | 186 ++++++++++++++++++ debian/python-ifupdown2.preinst | 56 ------ debian/rules | 16 ++ debian/source/format | 1 + README.rst => docs/README.rst | 0 sbin/{ifupdown => ifupdown2} | 0 setup.py | 33 +--- 23 files changed, 310 insertions(+), 143 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/clean create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/ifupdown2.bash-completion create mode 100644 debian/ifupdown2.dirs create mode 100644 debian/ifupdown2.docs create mode 100644 debian/ifupdown2.examples create mode 100644 debian/ifupdown2.install create mode 100644 debian/ifupdown2.links create mode 100644 debian/ifupdown2.manpages create mode 100644 debian/ifupdown2.networking.service rename debian/{python-ifupdown2.postinst => ifupdown2.postinst} (59%) rename debian/{python-ifupdown2.postrm => ifupdown2.postrm} (61%) create mode 100644 debian/networking.default create mode 100644 debian/networking.init delete mode 100755 debian/python-ifupdown2.preinst create mode 100755 debian/rules create mode 100644 debian/source/format rename README.rst => docs/README.rst (100%) rename sbin/{ifupdown => ifupdown2} (100%) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..8b5f0dd --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +ifupdown2 (1.1) unstable; urgency=low + + * Initial release. + + -- Roopa Prabhu Thu, 20 Aug 2015 06:14:24 -0700 diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..0723a0c --- /dev/null +++ b/debian/clean @@ -0,0 +1,4 @@ +man/ifquery.8 +man/ifreload.8 +man/ifup.8 +man/ifupdown-addons-interfaces.5 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b84fbdf --- /dev/null +++ b/debian/control @@ -0,0 +1,31 @@ +Source: ifupdown2 +Section: admin +Priority: optional +Maintainer: Roopa Prabhu +Standards-Version: 3.9.6 +Build-Depends: python-setuptools, dh-python, python-all (>= 2.6.6-3), debhelper (>= 9~), python-docutils, dh-systemd +Homepage: https://github.com/CumulusNetworks/ifupdown2 +X-Python-Version: >= 2.6 + +Package: ifupdown2 +Architecture: all +Suggests: python-gvgen, python-mako +Replaces: ifupdown +Conflicts: ifupdown +Provides: ifupdown +Depends: ${python:Depends}, ${misc:Depends}, python-argcomplete, python-ipaddr +Description: Network Interface Management tool similar to ifupdown + ifupdown2 is ifupdown re-written in Python. It replaces ifupdown and provides + the same user interface as ifupdown for network interface configuration. + Like ifupdown, ifupdown2 is a high level tool to configure (or, respectively + deconfigure) network interfaces based on interface definitions in + /etc/network/interfaces. It is capable of detecting network interface + dependencies and comes with several new features which are available as + new command options to ifup/ifdown/ifquery commands. It also comes with a new + command ifreload to reload interface configuration with minimum + disruption. Most commands are also capable of input and output in JSON format. + It is backward compatible with ifupdown /etc/network/interfaces format and + supports newer simplified format. It also supports interface templates with + python-mako for large scale interface deployments. See + /usr/share/doc/ifupdown2/README.rst for details about ifupdown2. Examples + are available under /usr/share/doc/ifupdown2/examples. diff --git a/debian/copyright b/debian/copyright index f560d80..d4d78ea 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,13 +1,16 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: ifupdown2 +Upstream-Contact: Roopa Prabhu , Sam Tannous Source: http://www.cumulusnetworks.com Files: * -Copyright: 2013 Cumulus Networks +Copyright: 2014 Cumulus Networks License: GPL-2 Files: debian/* -Copyright: 2013 Cumulus Networks +Copyright: 2014 Cumulus Networks +License: GPL-2 + License: GPL-2 This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +26,3 @@ License: GPL-2 . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. -# Please avoid to pick license terms that are more restrictive than the -# packaged work, as it may make Debian's contributions unacceptable upstream. diff --git a/debian/ifupdown2.bash-completion b/debian/ifupdown2.bash-completion new file mode 100644 index 0000000..cf6dbfb --- /dev/null +++ b/debian/ifupdown2.bash-completion @@ -0,0 +1 @@ +completion/ifup diff --git a/debian/ifupdown2.dirs b/debian/ifupdown2.dirs new file mode 100644 index 0000000..e7493b1 --- /dev/null +++ b/debian/ifupdown2.dirs @@ -0,0 +1 @@ +/etc/network/interfaces.d/ diff --git a/debian/ifupdown2.docs b/debian/ifupdown2.docs new file mode 100644 index 0000000..5c86fa8 --- /dev/null +++ b/debian/ifupdown2.docs @@ -0,0 +1 @@ +docs/README.rst diff --git a/debian/ifupdown2.examples b/debian/ifupdown2.examples new file mode 100644 index 0000000..684a743 --- /dev/null +++ b/debian/ifupdown2.examples @@ -0,0 +1 @@ +docs/examples/* diff --git a/debian/ifupdown2.install b/debian/ifupdown2.install new file mode 100644 index 0000000..cffd8b9 --- /dev/null +++ b/debian/ifupdown2.install @@ -0,0 +1,2 @@ +sbin/ifupdown2 /usr/share/ifupdown2/ +debian/networking.default /etc/default/networking diff --git a/debian/ifupdown2.links b/debian/ifupdown2.links new file mode 100644 index 0000000..177c9d5 --- /dev/null +++ b/debian/ifupdown2.links @@ -0,0 +1,6 @@ +usr/share/ifupdown2/ifupdown2 sbin/ifup +usr/share/ifupdown2/ifupdown2 sbin/ifdown +usr/share/ifupdown2/ifupdown2 sbin/ifquery +usr/share/ifupdown2/ifupdown2 sbin/ifreload +usr/share/man/man8/ifup.8.gz usr/share/man/man8/ifdown.8.gz + diff --git a/debian/ifupdown2.manpages b/debian/ifupdown2.manpages new file mode 100644 index 0000000..b7d0fab --- /dev/null +++ b/debian/ifupdown2.manpages @@ -0,0 +1,5 @@ +man/ifup.8 +man/ifquery.8 +man/ifreload.8 +man/ifupdown-addons-interfaces.5 +man/interfaces.5 diff --git a/debian/ifupdown2.networking.service b/debian/ifupdown2.networking.service new file mode 100644 index 0000000..4bcc1ae --- /dev/null +++ b/debian/ifupdown2.networking.service @@ -0,0 +1,10 @@ +[Unit] +Description=ifupdown2 init script + +[Service] +Type=oneshot +ExecStart=/sbin/ifup -a +ExecStop=/sbin/ifdown -a + +[Install] +WantedBy=multi-user.target diff --git a/debian/python-ifupdown2.postinst b/debian/ifupdown2.postinst similarity index 59% rename from debian/python-ifupdown2.postinst rename to debian/ifupdown2.postinst index cf61919..e1df311 100644 --- a/debian/python-ifupdown2.postinst +++ b/debian/ifupdown2.postinst @@ -43,30 +43,9 @@ report_err() { report "Error: $*" >&2 ; } case "$1" in configure) - # Create /etc/network/run - [ -d /run/network ] || mkdir -p /run/network - - # for backward compatibility - if [ ! -f /etc/network/run ]; then - ln -sf /run/network /etc/network/run - fi - - ln -sf /usr/share/python-ifupdown2/generate_interfaces.py \ - /usr/share/doc/python-ifupdown2/examples/generate_interfaces.py - - [ -d /etc/network/if-pre-up.d ] || mkdir -p /etc/network/if-pre-up.d - [ -d /etc/network/if-up.d ] || mkdir -p /etc/network/if-up.d - [ -d /etc/network/if-post-up.d ] || mkdir -p /etc/network/if-post-up.d - - [ -d /etc/network/if-pre-down.d ] || mkdir -p /etc/network/if-pre-down.d - [ -d /etc/network/if-down.d ] || mkdir -p /etc/network/if-down.d - [ -d /etc/network/if-post-down.d ] || mkdir -p /etc/network/if-post-down.d - # Generic stuff done on all configurations if [ -f /etc/network/interfaces ] ; then - # TODO: This should be handled with debconf and the script - # could introduce the line there directly if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then report_warn "No 'iface lo' definition found in /etc/network/interfaces" fi @@ -85,30 +64,13 @@ case "$1" in fi fi - [ -e /sbin/ifup ] || ln -sf /sbin/ifupdown /sbin/ifup - [ -e /sbin/ifdown ] || ln -sf /sbin/ifupdown /sbin/ifdown - [ -e /sbin/ifquery ] || ln -sf /sbin/ifupdown /sbin/ifquery - [ -e /sbin/ifreload ] || ln -sf /sbin/ifupdown /sbin/ifreload - - (cd /usr/share/man/man8/ && ln -sf /usr/share/man/man8/ifup.8.gz ifdown.8.gz) - - mkdir -p /etc/network/interfaces.d/ process_udev - update-rc.d networking start 40 S . start 35 0 6 . >/dev/null - ;; - - abort-upgrade|abort-remove|abort-deconfigure) ;; - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; + purge) + ;; esac -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - #DEBHELPER# exit 0 diff --git a/debian/python-ifupdown2.postrm b/debian/ifupdown2.postrm similarity index 61% rename from debian/python-ifupdown2.postrm rename to debian/ifupdown2.postrm index 6e6ab05..e7bb6a2 100644 --- a/debian/python-ifupdown2.postrm +++ b/debian/ifupdown2.postrm @@ -20,28 +20,26 @@ set -e process_udev() { - udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null || true) - [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules - udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null || true) - [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules + if [ -e /etc/udev/rules.d/80-networking.rules ]; then + udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null || true) + [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules + fi + + if [ -e /etc/udev/rules.d/60-bridge-network-interface.rules ]; then + udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null || true) + [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules + fi } postrm_remove() { - rm -f /sbin/ifup /sbin/ifdown /sbin/ifquery process_udev - update-rc.d networking remove >/dev/null } # Note: We don't remove /etc/network/interfaces postrm_purge() { - rm -f /var/tmp/network/ifstatenew - if [ -L /etc/network/run ] ; then - rm -f /etc/network/run - elif [ -d /etc/network/run ] ; then - rmdir --ignore-fail-on-non-empty /etc/network/run - fi + rm -f /run/network/ifstatenew } case "$1" in diff --git a/debian/networking.default b/debian/networking.default new file mode 100644 index 0000000..8b0474c --- /dev/null +++ b/debian/networking.default @@ -0,0 +1,17 @@ +# +# +# Parameters for the /etc/init.d/networking script +# +# + +# Change the below to yes if you want verbose logging to be enabled +VERBOSE="no" + +# Change the below to yes if you want debug logging to be enabled +DEBUG="no" + +# Change the below to yes if you want logging to go to syslog +SYSLOG="no" + +# Exclude interfaces +EXCLUDE_INTERFACES= diff --git a/debian/networking.init b/debian/networking.init new file mode 100644 index 0000000..286102a --- /dev/null +++ b/debian/networking.init @@ -0,0 +1,186 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: networking ifupdown +# Required-Start: mountkernfs $local_fs urandom +# Required-Stop: $local_fs +# Default-Start: S +# Default-Stop: 0 1 6 +# Short-Description: Raise network interfaces. +# Description: Prepare /run/network directory, ifstate file and raise network interfaces, or take them down. +### END INIT INFO + +PATH="/sbin:/bin" +RUN_DIR="/run/network" +IFSTATE="$RUN_DIR/ifstate" + +NAME=networking +SCRIPTNAME=/etc/init.d/$NAME + +[ -x /sbin/ifup ] || exit 0 +[ -x /sbin/ifdown ] || exit 0 + +. /lib/lsb/init-functions + +CONFIGURE_INTERFACES=yes + +EXTRA_ARGS= + +[ -f /etc/default/networking ] && . /etc/default/networking + +[ "$VERBOSE" = yes ] && EXTRA_ARGS=-v +[ "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d" +[ "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog" + +perf_options() { + # At bootup lets set perfmode + [ -f /var/tmp/network/ifstatenew ] && echo -n "" && return + + echo -n "--perfmode" +} + +process_exclusions() { + set -- $EXCLUDE_INTERFACES + exclusions="" + for d + do + exclusions="-X $d $exclusions" + done + echo $exclusions +} + +check_network_file_systems() { + [ -e /proc/mounts ] || return 0 + + if [ -e /etc/iscsi/iscsi.initramfs ]; then + log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted." + exit 0 + fi + + while read DEV MTPT FSTYPE REST; do + case $DEV in + /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*) + log_warning_msg "not deconfiguring network interfaces: network devices still mounted." + exit 0 + ;; + esac + case $FSTYPE in + nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs) + log_warning_msg "not deconfiguring network interfaces: network file systems still mounted." + exit 0 + ;; + esac + done < /proc/mounts +} + +check_network_swap() { + [ -e /proc/swaps ] || return 0 + + while read DEV MTPT FSTYPE REST; do + case $DEV in + /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*) + log_warning_msg "not deconfiguring network interfaces: network swap still mounted." + exit 0 + ;; + esac + done < /proc/swaps +} + +ifup_hotplug () { + if [ -d /sys/class/net ] + then + ifaces=$(for iface in $(ifquery --list --allow=hotplug 2>/dev/null) + do + link=${iface##:*} + link=${link##.*} + if [ -e "/sys/class/net/$link" ] && [ "$(cat /sys/class/net/$link/operstate)" = up ] + then + echo "$iface" + fi + done) + if [ -n "$ifaces" ] + then + ifup $ifaces "$@" || true + fi + fi +} + +ifupdown_init() { + [ ! -e /run/network ] && mkdir -p /run/network &>/dev/null + [ ! -e /etc/network/run ] && \ + ln -sf /run/network /etc/network/run &>/dev/null +} + +case "$1" in +start) + ifupdown_init + if [ "$CONFIGURE_INTERFACES" = no ] + then + log_action_msg "Not configuring network interfaces, see /etc/default/networking" + exit 0 + fi + set -f + exclusions=$(process_exclusions) + perfoptions=$(perf_options) + log_action_begin_msg "Configuring network interfaces" + ifup -a $EXTRA_ARGS $exclusions $perfoptions + log_action_end_msg $? + ;; + +stop) + ifupdown_init + check_network_file_systems + check_network_swap + exclusions=$(process_exclusions) + + log_action_begin_msg "Deconfiguring network interfaces" + ifdown -a $EXTRA_ARGS $exclusions + log_action_end_msg $? + ;; + +reload) + + ifupdown_init + log_action_begin_msg "Reloading network interfaces configuration" + + ifreload -a $EXTRA_ARGS + log_action_end_msg $? + ;; + +reload-currently-up) + + ifupdown_init + log_action_begin_msg "Reloading currently up network interfaces configuration" + + ifreload --currently-up $EXTRA_ARGS + log_action_end_msg $? + ;; + +force-reload) + + ifupdown_init + + log_action_begin_msg "Reloading network interfaces configuration" + ifreload -f -a $EXTRA_ARGS + log_action_end_msg $? + ;; + +restart) + ifupdown_init + + set -f + exclusions=$(process_exclusions) + log_action_begin_msg "Reconfiguring network interfaces" + ifdown -a $EXTRA_ARGS $exclusions || true + ifup -a $EXTRA_ARGS $exclusions + log_action_end_msg $? + ;; + +*) + echo "Usage: /etc/init.d/networking {start|stop|reload|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 + +# vim: noet ts=8 diff --git a/debian/python-ifupdown2.preinst b/debian/python-ifupdown2.preinst deleted file mode 100755 index 3fcaed1..0000000 --- a/debian/python-ifupdown2.preinst +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# preinst script for newpkg -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `install' -# * `install' -# * `upgrade' -# * `abort-upgrade' -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - -preinst_upgrade() -{ - local oldver="$1" - local udev_user_rulesdir="/etc/udev/rules.d" - - # we have to fixup the filesystem here as previous packages of - # ifupdown2 introduced a bug in the postrm script that require - # these files to exist, otherwise the postrm script will always - # fail. - local badver="0.1-cl2.5+2" - if dpkg --compare-versions "${oldver}" "lt" "${badver}"; then - local files="${udev_user_rulesdir}/80-networking.rules - ${udev_user_rulesdir}/60-bridge-network-interface.rules" - for f in ${files}; do - echo "touching udev rule: ${f}" - test ! -e "${f}" && ln -s /dev/null "${f}" || \ - /bin/echo -e "\tudev rule exists leaving" - done - fi -} - -case "$1" in - install|upgrade) - preinst_upgrade "$2" - ;; - - abort-upgrade) - ;; - - *) - echo "preinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..25a747d --- /dev/null +++ b/debian/rules @@ -0,0 +1,16 @@ +#!/usr/bin/make -f + +#export DH_VERBOSE=1 +export PYBUILD_NAME=ifupdown2 +export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/ifupdown2 --install-scripts=/usr/share/ifupdown2 + +%: + dh $@ --with python2 --buildsystem=pybuild + +override_dh_installman: + ./scripts/genmanpages.sh ./man.rst ./man + dh_installman + +override_dh_installinit: + dh_systemd_enable --name=networking + dh_installinit --name=networking --no-start diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/README.rst b/docs/README.rst similarity index 100% rename from README.rst rename to docs/README.rst diff --git a/sbin/ifupdown b/sbin/ifupdown2 similarity index 100% rename from sbin/ifupdown rename to sbin/ifupdown2 diff --git a/setup.py b/setup.py index d98910e..3629a9a 100755 --- a/setup.py +++ b/setup.py @@ -1,39 +1,16 @@ from distutils.core import setup setup(name='ifupdown2', - version='0.1', + version='1.1', description = "ifupdown 2", author='Roopa Prabhu', author_email='roopa@cumulusnetworks.com', url='cumulusnetworks.com', packages=['ifupdown', 'ifupdownaddons'], - scripts = ['sbin/ifupdown'], - install_requires = ['python-gvgen', 'python-argcomplete', 'python-ipaddr'], - data_files=[('share/man/man8/', - ['man/ifup.8', 'man/ifquery.8', 'man/ifreload.8']), - ('share/man/man5/', - ['man/interfaces.5', 'man/ifupdown-addons-interfaces.5']), - ('/etc/init.d/', - ['init.d/networking']), - ('/sbin/', ['sbin/ifupdown']), - ('/etc/network/ifupdown2/', + data_files=[ ('/etc/network/ifupdown2/', ['config/ifupdown2.conf']), - ('/etc/default/', - ['config/networking']), - ('/usr/share/python-ifupdown2/', - ['docs/examples/generate_interfaces.py']), - ('/usr/share/doc/python-ifupdown2/examples/', - ['docs/examples/interfaces', - 'docs/examples/interfaces_bridge_template_func', - 'docs/examples/interfaces_with_template', - 'docs/examples/interfaces_bridge_igmp_mstp']), - ('/usr/share/doc/python-ifupdown2/examples/vlan_aware_bridges', - ['docs/examples/vlan_aware_bridges/interfaces.basic', - 'docs/examples/vlan_aware_bridges/interfaces.vlan_prune_and_access_ports', - 'docs/examples/vlan_aware_bridges/interfaces.with_bonds', - 'docs/examples/vlan_aware_bridges/interfaces.with_clag']), ('/etc/bash_completion.d/', ['completion/ifup']), - ('/usr/share/ifupdownaddons/', ['addons/bridge.py', + ('/usr/share/ifupdown2/addons/', ['addons/bridge.py', 'addons/bond.py', 'addons/vlan.py', 'addons/mstpctl.py', 'addons/address.py', 'addons/dhcp.py', 'addons/usercmds.py', @@ -41,8 +18,8 @@ setup(name='ifupdown2', 'addons/addressvirtual.py', 'addons/vxlan.py', 'addons/link.py', 'addons/bridgevlan.py']), - ('/var/lib/ifupdownaddons/', ['config/addons.conf']), - ('/var/lib/ifupdownaddons/policy.d/', []), + ('/etc/network/ifupdown2/', ['config/addons.conf']), + ('/var/lib/ifupdown2/policy.d/', []), ('/etc/network/ifupdown2/policy.d/', []) ] ) -- 2.39.2