Package: ifupdown
Version: 0.7.1
Severity: wishlist
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch quantal

Hi Andrew,

With the latest upstream version of plymouth now uploaded to unstable, and
the mountall package in the NEW queue, we are close to being able to have a
modern version of upstart in the Debian archive.  The next steps required
are to have support for upstart-based network and device initialization in
the archive (ifupdown and udev).

Would you consider including the attached patch for ifupdown in wheezy?  I
realize this is quite close to the freeze deadline and understand if you
don't think it should go in.  If not, I would still appreciate having it in
for sid post-freeze.

This patch has a potential boot-time impact on non-upstart-using systems, in
that it installs ifupdown hooks that are only needed / appropriate when pid
1 is upstart.  I think the ifupdown package is the logical place for these
hooks to live, but you may disagree.  How would you prefer that I handle
these?  I can either move them to the upstart package, or I can make them
no-ops on non-upstart systems.

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 3852b8ca1fb8 debian/changelog
--- a/debian/changelog	Thu Jun 28 23:07:29 2012 +0200
+++ b/debian/changelog	Thu Jun 28 17:37:56 2012 -0700
@@ -1,3 +1,9 @@
+ifupdown (0.7.2) UNRELEASED; urgency=low
+
+  * Add upstart support.
+
+ -- Steve Langasek <vor...@debian.org>  Thu, 28 Jun 2012 15:23:57 -0700
+
 ifupdown (0.7.1) unstable; urgency=low
 
   * Supply metric setting to dhclient (Closes: #279741, #364581, #676323).
diff -r 3852b8ca1fb8 debian/control
--- a/debian/control	Thu Jun 28 23:07:29 2012 +0200
+++ b/debian/control	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/ifupdown.network-interface-container.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface-container.upstart	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/ifupdown.network-interface-security.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface-security.upstart	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/ifupdown.network-interface.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.network-interface.upstart	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/ifupdown.networking.upstart
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.networking.upstart	Thu Jun 28 17:37:56 2012 -0700
@@ -0,0 +1,18 @@
+# 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))
+
+task
+
+pre-start exec mkdir -p /run/network
+
+exec ifup -a
diff -r 3852b8ca1fb8 debian/ifupdown.upstart.if-down
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.upstart.if-down	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/ifupdown.upstart.if-up
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/ifupdown.upstart.if-up	Thu Jun 28 17:37:56 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 3852b8ca1fb8 debian/rules
--- a/debian/rules	Thu Jun 28 23:07:29 2012 +0200
+++ b/debian/rules	Thu Jun 28 17:37:56 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