Control: tags -1 patch

Aurelien,

Thanks for this.

I have a proposed patch for this (see attached). I have also taken the
opportunity to rework and cleanup the sysvinit-core postinst.

Any comments are welcome.

On Sat, Jun 01, 2024 at 11:38:04PM +0200, Aurelien Jarno wrote:
> At some point this will allow us to drop the corresponding part
> of the libc6 postinst.

Until that happens, does that mean that sysvinit will be restarted twice, once 
by
libc6 postinst and once by the libc-upgrade trigger?

Best wishes

Mark
diff --git a/debian/sysvinit-core.postinst b/debian/sysvinit-core.postinst
index f6d00490..21c565b7 100755
--- a/debian/sysvinit-core.postinst
+++ b/debian/sysvinit-core.postinst
@@ -1,44 +1,12 @@
 #! /bin/sh
 #
-# sysvinit postinst
+# sysvinit-core postinst
 #
 
 set -e
 
-# Restart init, and migrate to /run/initctl if needed.
+# Restart init.
 do_restart() {
-	INITCTL=/run/initctl
-	case "$(uname -s)" in
-	  *FreeBSD)
-		OLDINITCTL=/etc/.initctl
-		;;
-	  *)
-		OLDINITCTL=/dev/initctl
-		;;
-	esac
-
-	# PID of init; may not always be 1 but this code isn't run in
-	# these cases (Hurd).  Use for sending signals and checking if
-	# init is running.
-	PID=1
-
-	# Create /run/initctl if not present, and also create compatibility
-	# symlinks
-	if [ ! -p "$INITCTL" ]
-	then
-		# Create new control channel
-		echo "sysvinit: creating $INITCTL"
-		rm -f $INITCTL
-		mkfifo -m 600 $INITCTL
-        fi
-
-	# Replace old control channel with symlink
-	ln -s "$INITCTL" "$OLDINITCTL.new"
-	mv "$OLDINITCTL.new" "$OLDINITCTL"
-
-	# Reopen control channel (uses new channel).
-	kill -s USR1 "$PID"
-
 	# Tell init to re-exec itself.  We loop on failure to reduce
 	# the chance of a race before the new control channel is
 	# opened.
@@ -59,57 +27,47 @@ do_restart() {
 			fi
 		fi
 	done
-
-	# Remove old pipe if present.  No longer in use after re-exec.
-	if [ -p "$OLDINITCTL" ]
-	then
-	        rm -f "$OLDINITCTL"
-	fi
 }
 
+umask 022
+
 case "$1" in
-  configure)
-	oldver=$2
+    configure)
+	if [ -z "$2" ]; then
+	    # New installation
+	    skip_restart=1
+	fi
+
+	rm -f "$DPKG_ROOT/etc/ioctl.save"
+
+	if [ ! -f "$DPKG_ROOT/etc/inittab" ]; then
+	    cp -p "$DPKG_ROOT/usr/share/sysvinit/inittab" "$DPKG_ROOT/etc/inittab"
+	fi
 	;;
-  abort-upgrade|abort-remove|abort-deconfigure)
+    triggered)
+	# Restart, if possible
+	;;
+    abort-upgrade|abort-remove|abort-deconfigure)
 	exit 0
 	;;
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+	;;
 esac
 
-umask 022
-
-rm -f "$DPKG_ROOT/etc/ioctl.save"
-
-if [ ! -f "$DPKG_ROOT/etc/inittab" ]
+if ischroot --default-true ||
+	[ -n "${DPKG_ROOT:-}" ] ||
+	[ -d "$DPKG_ROOT/run/systemd/system" ] ||
+	[ "$(uname -s)" = "GNU" ]
 then
-	cp -p "$DPKG_ROOT/usr/share/sysvinit/inittab" "$DPKG_ROOT/etc/inittab"
-fi
-
-restart=yes
-
-if [ -z "${oldver}" ]; then
-    restart=no
-fi
-if ischroot --default-true ; then
-	restart=no
-fi
-if [ -n "${DPKG_ROOT:-}" ]; then
-	restart=no
-fi
-
-# If systemd is running, don't restart init or doing any initctl
-# migration.
-if [ -d "$DPKG_ROOT/run/systemd/system" ]; then
-	restart=no
-fi
-if [ "$(uname -s)" = "GNU" ]; then
-	restart=no
+    skip_restart=1
 fi
 
-if [ "$restart" = "yes" ]; then
-	do_restart
+if [ "$skip_restart" ]; then
+    echo "Not restarting sysvinit"
 else
-	echo "Not restarting sysvinit"
+    do_restart
 fi
 
 #DEBHELPER#
diff --git a/debian/sysvinit-core.triggers b/debian/sysvinit-core.triggers
new file mode 100644
index 00000000..ac00c071
--- /dev/null
+++ b/debian/sysvinit-core.triggers
@@ -0,0 +1 @@
+interest-noawait libc-upgrade

Reply via email to