It was pointed out to me on IRC that while the existing init script code
would work with or without the new lsb-base, it would be a bit noisy. 
Here's an updated NMU patch that suppresses stderr from init_is_upstart, and
calls grep -q instead of just grep.

I've replaced the previous NMU in the DELAYED queue with this one.

-- 
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 -Nru udev-175/debian/changelog udev-175/debian/changelog
--- udev-175/debian/changelog	2012-08-17 03:24:27.000000000 -0700
+++ udev-175/debian/changelog	2012-11-04 23:58:16.000000000 -0800
@@ -1,3 +1,10 @@
+udev (175-7.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Add upstart support.  Closes: #686378.
+
+ -- Steve Langasek <steve.langa...@ubuntu.com>  Sun, 04 Nov 2012 23:58:14 -0800
+
 udev (175-7) unstable; urgency=low
 
   * Clean up better /etc/udev/rules.d/ on purge. (Closes: #685065)
diff -Nru udev-175/debian/rules udev-175/debian/rules
--- udev-175/debian/rules	2012-08-12 08:49:52.000000000 -0700
+++ udev-175/debian/rules	2012-11-04 23:55:06.000000000 -0800
@@ -179,6 +179,10 @@
 	dh_installinit --no-start --update-rcd-params='start 03 S .'
 	dh_installinit --no-start --update-rcd-params='start 36 S .' \
 		--name=udev-mtab
+	dh_installinit --name=udev-finish --no-start -- start 37 S .
+	dh_installinit --name=udevtrigger --no-start
+	dh_installinit --name=udevmonitor --no-start
+	dh_installinit --name=udev-fallback-graphics --no-start
 
 	dh_strip
 	dh_compress
diff -Nru udev-175/debian/udev.init udev-175/debian/udev.init
--- udev-175/debian/udev.init	2012-07-29 20:04:05.000000000 -0700
+++ udev-175/debian/udev.init	2012-11-08 16:04:14.000000000 -0800
@@ -160,6 +160,9 @@
 
 case "$1" in
     start)
+    if init_is_upstart 2>/dev/null; then
+	exit 1
+    fi
     if mountpoint -q $udev_root/; then
 	log_failure_msg "$udev_root is already mounted"
 	log_end_msg 1
@@ -189,6 +192,11 @@
 
     ;;
     stop)
+    # make sure a manual invocation of the init script doesn't stop an
+    # upstart-controlled instance of udev
+    if init_is_upstart 2>/dev/null && status udev | grep -q start; then
+	exit 0
+    fi
     log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
     if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
 	log_end_msg $?
@@ -206,6 +214,9 @@
     ;;
 
     restart)
+    if init_is_upstart 2>/dev/null; then
+	exit 1
+    fi
     log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
     if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
 	log_end_msg $?
@@ -246,6 +257,9 @@
 
 case "$1" in
     start)
+    if init_is_upstart 2>/dev/null; then
+	exit 1
+    fi
     if mountpoint -q $udev_root/; then
 	TMPFS_MOUNTED=1
     elif [ -e "$udev_root/.udev/" ]; then
@@ -314,6 +328,9 @@
     ;;
 
     restart)
+    if init_is_upstart 2>/dev/null; then
+	exit 1
+    fi
     log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
     if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
 	log_end_msg $?
diff -Nru udev-175/debian/udev.preinst udev-175/debian/udev.preinst
--- udev-175/debian/udev.preinst	2011-11-13 18:18:40.000000000 -0800
+++ udev-175/debian/udev.preinst	2012-11-04 23:57:40.000000000 -0800
@@ -198,10 +198,21 @@
   fi
 }
 
+stop_on_upstart_upgrade() {
+  if which initctl >/dev/null && initctl version | grep -q upstart
+  then
+    # We have to stop udev before we can restart it under upstart in the
+    # postinst.
+    invoke-rc.d udev stop
+  fi
+}
+
 check_version() {
   # $2 is non-empty when installing from the "config-files" state
   [ "$2" ] || return 0
 
+  if dpkg --compare-versions $2 lt 175-7.1; then
+
   if dpkg --compare-versions $2 lt 175-1; then
 
   if dpkg --compare-versions $2 lt 168-2; then
@@ -262,6 +273,9 @@
   rm_conffile /etc/modprobe.d/blacklist.conf
 
   fi # 175-1
+
+  stop_on_upstart_upgrade
+  fi # 175-7.1
 }
 
 case "$1" in
diff -Nru udev-175/debian/udev.udev-fallback-graphics.upstart udev-175/debian/udev.udev-fallback-graphics.upstart
--- udev-175/debian/udev.udev-fallback-graphics.upstart	1969-12-31 16:00:00.000000000 -0800
+++ udev-175/debian/udev.udev-fallback-graphics.upstart	2012-11-04 23:55:06.000000000 -0800
@@ -0,0 +1,21 @@
+# fallback-graphics - take actions to initiate fallback graphics
+#
+# if we have cold plugged everything and not yet seen a valid graphics
+# device,
+# shove a fallback framebuffer into the mix and hope for the best.
+
+description	"load fallback graphics devices"
+
+# We only want this job to happen once per boot, hence 'startup and ...'.
+start on (startup and 
+	  (graphics-device-added PRIMARY_DEVICE_FOR_DISPLAY=1
+           or drm-device-added PRIMARY_DEVICE_FOR_DISPLAY=1
+           or stopped udevtrigger or container))
+
+task
+
+script
+    if [ "$PRIMARY_DEVICE_FOR_DISPLAY" = "" ]; then
+        modprobe -q -b vesafb
+    fi
+end script
diff -Nru udev-175/debian/udev.udev-finish.upstart udev-175/debian/udev.udev-finish.upstart
--- udev-175/debian/udev.udev-finish.upstart	1969-12-31 16:00:00.000000000 -0800
+++ udev-175/debian/udev.udev-finish.upstart	2012-11-04 23:55:06.000000000 -0800
@@ -0,0 +1,30 @@
+# udev-finish - save udev log and update rules
+#
+# While udev runs we not only create the log file of initial device
+# creation but udev rules may be generated, we need to copy both of
+# these out of /dev and onto the root filesystem.
+
+description	"save udev log and update rules"
+
+start on (startup
+	  and filesystem
+	  and started udev
+	  and stopped udevtrigger
+	  and stopped udevmonitor)
+
+task
+script
+    # Save udev log in /var/log/udev
+    if [ -e /dev/.udev.log ]
+    then
+	mv -f /dev/.udev.log /var/log/udev || :
+    fi
+
+    # Copy any rules generated while the root filesystem was read-only
+    for file in /dev/.udev/tmp-rules--*
+    do
+	[ -e "$file" ] || continue
+	cat "$file" >> "/etc/udev/rules.d/${file##*tmp-rules--}"
+	rm -f "$file"
+    done
+end script
diff -Nru udev-175/debian/udev.udevmonitor.upstart udev-175/debian/udev.udevmonitor.upstart
--- udev-175/debian/udev.udevmonitor.upstart	1969-12-31 16:00:00.000000000 -0800
+++ udev-175/debian/udev.udevmonitor.upstart	2012-11-04 23:55:06.000000000 -0800
@@ -0,0 +1,13 @@
+# udevmonitor - log initial device creation
+#
+# The set of devices created in the "cold plug" pass is generally
+# useful for debugging, so we monitor this and create a log file
+# from that.
+
+description	"log initial device creation"
+
+start on (startup
+	  and starting udevtrigger)
+stop on stopped udevtrigger
+
+exec /sbin/udevadm monitor -e >/dev/.udev.log
diff -Nru udev-175/debian/udev.udevtrigger.upstart udev-175/debian/udev.udevtrigger.upstart
--- udev-175/debian/udev.udevtrigger.upstart	1969-12-31 16:00:00.000000000 -0800
+++ udev-175/debian/udev.udevtrigger.upstart	2012-11-04 23:55:06.000000000 -0800
@@ -0,0 +1,16 @@
+# udevtrigger - cold plug devices
+#
+# By the time udevd starts, we've already missed all of the events for
+# the devices populated in /sys.  This task causes the kernel to resend
+# them.
+
+description	"cold plug devices"
+
+start on (startup
+	  and started udev
+	  and not-container)
+
+task
+
+exec udevadm trigger --action=add
+post-stop exec udevadm settle
diff -Nru udev-175/debian/udev.upstart udev-175/debian/udev.upstart
--- udev-175/debian/udev.upstart	1969-12-31 16:00:00.000000000 -0800
+++ udev-175/debian/udev.upstart	2012-11-04 23:55:06.000000000 -0800
@@ -0,0 +1,14 @@
+# udev - device node and kernel event manager
+#
+# The udev daemon receives events from the kernel about changes in the
+# /sys filesystem and manages the /dev filesystem.
+
+description	"device node and kernel event manager"
+
+start on virtual-filesystems
+stop on runlevel [06]
+
+expect fork
+respawn
+
+exec /sbin/udevd --daemon

Attachment: signature.asc
Description: Digital signature

Reply via email to