Hi Andrew,

Please find attached an updated version of this patch, rebased on the
current upload and with an improved 'networking' upstart job.

I have spoken with the release team about my intention to have upstart
support in wheezy, and have been given tentative approval for these changes
to be unblocked.  So I would appreciate a response on whether you would
consider including this change in a future upload for wheezy, or if I should
look at NMUing instead.

I would also still be interested to know whether you think the 'upstart'
ifupdown hook should be included in ifupdown, or if it should be moved to
the upstart package itself.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -r 04447c456b21 debian/changelog
--- a/debian/changelog	Thu Aug 16 23:23:11 2012 +0200
+++ b/debian/changelog	Fri Aug 31 10:46:07 2012 -0700
@@ -1,3 +1,9 @@
+ifupdown (0.7.3) UNRELEASED; urgency=low
+
+  * Add upstart support.
+
+ -- Steve Langasek <vor...@debian.org>  Thu, 28 Jun 2012 15:23:57 -0700
+
 ifupdown (0.7.2) unstable; urgency=low
 
   * Don't install /etc/default/networking as executable (Closes: #679623).
diff -r 04447c456b21 debian/control
--- a/debian/control	Thu Aug 16 23:23:11 2012 +0200
+++ b/debian/control	Fri Aug 31 10:46:07 2012 -0700
@@ -4,7 +4,7 @@
 Maintainer: Andrew O. Shadura <bugzi...@tut.by>
 Uploaders: Petter Reinholdtsen <p...@debian.org>
 Standards-Version: 3.9.3
-Build-Depends: debhelper (>= 8.1.0~), noweb
+Build-Depends: debhelper (>= 9.20120410~), noweb
 Vcs-Hg: http://anonscm.debian.org/hg/collab-maint/ifupdown/
 Vcs-Browser: http://anonscm.debian.org/hg/collab-maint/ifupdown/
 
diff -r 04447c456b21 debian/ifupdown.network-interface-container.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface-container.upstart	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,19 @@
+# network-interface-container - woarkound for missing events in container
+#
+# This service emits missing net-device-added events for containers.
+# It's needed in cases where devices are created before the container
+# starts and so won't get a udev event.
+
+description "workaround for missing events in container"
+start on container
+
+emits net-device-added
+
+task
+script
+    case "$CONTAINER" in
+        lxc|lxc-libvirt)
+            initctl emit --no-wait net-device-added INTERFACE=lo || true
+        ;;
+    esac
+end script
diff -r 04447c456b21 debian/ifupdown.network-interface-security.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface-security.upstart	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,34 @@
+# network-interface-security - configure network device security
+#
+# This is a one-time start-up script to load AppArmor profiles needed
+# before the network comes up.
+
+description	"configure network device security"
+
+# In order to avoid upstart bug LP: #447654, we cannot have an AND
+# statement here (with the ORs).  An "and virtual-filesystems" is desired
+# here to make sure that the securityfs is mounted, but since each of the
+# ORed services already require virtual-filesystems be mounted, this is safe:
+start on (starting network-interface
+          or starting network-manager
+          or starting networking)
+
+# In order to handle the lack of upstart feature LP: #568860, we need to
+# run multiple times, for each of the above "starting" service instances, or
+# else another one might run while we're running, and not wait for us to
+# finish.
+instance $JOB${INTERFACE:+/}${INTERFACE:-}
+
+# Since we need these profiles to be loaded before any of the above services
+# begin running, this service must be a pre-start so that its pre-start
+# script finishes before the above services' start scripts begin.
+pre-start script
+    [ -f /run/network-interface-security ] && exit 0 # already ran
+    [ -d /rofs/etc/apparmor.d ]  && exit 0 # do not load on liveCD
+    [ -d /sys/module/apparmor ]  || exit 0 # do not load without AppArmor
+    [ -x /sbin/apparmor_parser ] || exit 0 # do not load without parser
+    for link in /etc/apparmor/init/network-interface-security/* ; do
+        [ -L $link ] && /sbin/apparmor_parser -r -W $link || true
+    done
+    > /run/network-interface-security
+end script
diff -r 04447c456b21 debian/ifupdown.network-interface.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface.upstart	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,30 @@
+# network-interface - configure network device
+#
+# This service causes network devices to be brought up or down as a result
+# of hardware being added or removed, including that which isn't ordinarily
+# removable.
+
+description	"configure network device"
+
+emits net-device-up
+emits net-device-down
+emits static-network-up
+
+start on net-device-added
+stop on net-device-removed INTERFACE=$INTERFACE
+
+instance $INTERFACE
+export INTERFACE
+
+pre-start script
+    if [ "$INTERFACE" = lo ]; then
+	# bring this up even if /etc/network/interfaces is broken
+	ifconfig lo 127.0.0.1 up || true
+	initctl emit -n net-device-up \
+	    IFACE=lo LOGICAL=lo ADDRFAM=inet METHOD=loopback || true
+    fi
+    mkdir -p /run/network
+    exec ifup --allow auto $INTERFACE
+end script
+
+post-stop exec ifdown --allow auto $INTERFACE
diff -r 04447c456b21 debian/ifupdown.networking.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.networking.upstart	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,66 @@
+# networking - configure virtual network devices
+#
+# This task causes virtual network devices that do not have an associated
+# kernel object to be started on boot.
+
+description	"configure virtual network devices"
+
+emits static-network-up
+emits net-device-up
+
+start on (local-filesystems
+      and (stopped udevtrigger or container))
+stop on unmounted-remote-filesystems
+
+pre-start script
+    mkdir -p /run/network
+    ifup -a
+end script
+
+post-stop script
+    log_warning_msg() {
+        echo $*
+    }
+
+    # These checks were taken from the Debian ifupdown.networking.init script
+    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
+    }
+
+    check_network_file_systems
+    check_network_swap
+    ifdown -a
+end script
diff -r 04447c456b21 debian/ifupdown.upstart.if-down
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.upstart.if-down	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+initctl emit -n net-device-down \
+	"IFACE=$IFACE" \
+	"LOGICAL=$LOGICAL" \
+	"ADDRFAM=$ADDRFAM" \
+	"METHOD=$METHOD"
diff -r 04447c456b21 debian/ifupdown.upstart.if-up
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.upstart.if-up	Fri Aug 31 10:46:07 2012 -0700
@@ -0,0 +1,43 @@
+#!/bin/sh
+MARK_DEV_PREFIX="/run/network/ifup."
+MARK_STATIC_NETWORK_EMITTED="/run/network/static-network-up-emitted"
+
+set -e
+
+# lo emission handled by /etc/init/network-interface.conf
+if [ "$IFACE" != lo ]; then
+    initctl emit -n net-device-up \
+        "IFACE=$IFACE" \
+        "LOGICAL=$LOGICAL" \
+        "ADDRFAM=$ADDRFAM" \
+        "METHOD=$METHOD"
+fi
+
+get_auto_interfaces() {
+	# write to stdout a list of interfaces configured as 'auto' in interfaces(5)
+	local found=""
+	# stderr redirected as it outputs things like:
+	# Ignoring unknown interface eth0=eth0.
+	found=$(ifquery --list --allow auto 2>/dev/null) || return
+	set -- ${found}
+	echo "$@"
+}
+
+all_interfaces_up() {
+	# return true if all interfaces listed in /etc/network/interfaces as 'auto'
+	# are up.  if no interfaces are found there, then "all [given] were up"
+	local prefix="$1" iface=""
+	for iface in $(get_auto_interfaces); do
+		# if cur interface does is not up, then all have not been brought up
+		[ -f "${prefix}${iface}" ] || return 1
+	done
+	return 0
+}
+
+# touch our own "marker" indicating that this interface has been brought up.
+: > "${MARK_DEV_PREFIX}$IFACE"
+
+if all_interfaces_up "${MARK_DEV_PREFIX}" &&
+	mkdir "${MARK_STATIC_NETWORK_EMITTED}" 2>/dev/null; then
+	initctl emit --no-wait static-network-up
+fi
diff -r 04447c456b21 debian/rules
--- a/debian/rules	Thu Aug 16 23:23:11 2012 +0200
+++ b/debian/rules	Fri Aug 31 10:46:07 2012 -0700
@@ -52,6 +52,13 @@
 override_dh_installinit:
 	dh_installinit --name=networking --no-start -- start 40 S . start 35 0 6 .
 	install -p -m 0644 debian/networking.defaults $(DESTDIR)/etc/default/networking
+	dh_installinit --name=network-interface-container --noscripts
+	dh_installinit --name=network-interface-security --noscripts
+	dh_installinit --name=network-interface --noscripts
+	dh_installinit --name=networking --noscripts
+
+override_dh_installifupdown:
+	dh_installifupdown --name=upstart
 
 override_dh_auto_clean:
 	$(MAKE) clean

Attachment: signature.asc
Description: Digital signature

Reply via email to