On 21/06/18 12:34, Felipe Sateler wrote:

Patches welcome. If you decide to implement this, make sure that the code is only active with a running sysvinit (ie, don't affect chroots). It is not trivial, which is why I didn't implement it myself. You probably need to integrate ucf to handle all the corner cases.

Patch attached. I haven't gone through all the steps of integrating ucf - the disable autospawn file isn't currently marked in the package as a conffile, so this patch, while it works in my limited testing, could still be improved on there.

LMK what you think - if you're happy with this approach and will integrate it, I can work on ucf integration as well.

Mike
--- /var/lib/dpkg/info/pulseaudio.postinst	2018-04-05 19:55:56.000000000 +0100
+++ pulseaudio.postinst	2018-06-28 23:01:17.801244088 +0100
@@ -16,6 +16,34 @@
 
 PULSEAUDIO=/usr/bin/pulseaudio
 
+check_sysvinit() {
+  # Get the major/minor numbers for the root device
+  local rdev=$(printf %04.0f $(stat -c %D /) | sed 's/../&:/')
+  # Get the default target triplet for the system
+  local arch=$(gcc -print-multiarch)
+  # Retrieve PID 1's mapped binaries from the root fs
+  local binmaps=`awk "/$rdev/ {print \\$6}" /proc/1/maps | grep -v $arch | uniq | xargs`
+
+  local status
+  status=$(dpkg -s sysvinit 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
+
+  # If the sysvinit package is installed, and it's binary is mapped as PID 1,
+  # then we can assume we are on a sysvinit system, and not simply in a chroot
+  # environment.
+  if  [ -n "$status" ] && [ "$status" == "installed" ]; then
+	  if  [ -n "$binmaps" ] && [ "$binmaps" == "/sbin/init" ]; then
+		  return 0
+	  fi
+  fi
+  return 1
+}
+
+config_autospawn() {
+	if check_sysvinit; then
+		rm -f /etc/pulse/client.conf.d/00-disable-autospawn.conf
+	fi
+}
+
 trigger_udev() {
 	if ! which udevadm >/dev/null 2>&1 ; then
 		return 0;
@@ -36,6 +64,7 @@
       addgroup --quiet --system pulse-access
     fi
     trigger_udev
+    config_autospawn
   ;;
   abort-upgrade|abort-remove|abort-deconfigure)
   ;;

Reply via email to