[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#447609: ldconfig triggerisation



Source: glibc
Version: 2.6.1-6
Severity: wishlist
Tags: patch

The attached patch triggerises the invocation of ldconfig by package
maintainer scripts.

By `triggerises' I mean that the patch arranges for ldconfig
invocations by maintainer scripts to call dpkg-trigger instead of
ldconfig.  ldconfig will be actually run out of glibc's maintainer
script during trigger processing.  The consequence is that all of the
ldconfig invocations during a dpkg run are deferred, and instead
ldconfig is run once at the end.

The understanding on which we base this approach is that after library
installation (which is when ldconfig is used in maintainer scripts) it
is always safe to defer the execution of ldconfig.  Ie, that after a
new library has been installed or an existing library upgraded,
programs which link against the library will work even though ldconfig
hasn't been run.  We understand that not running ldconfig will incur
some performance penalty during the upgrade process but in practice
this is far outweighed by the cost of repeatedly running ldconfig.

We took the approach of renaming ldconfig to ldconfig.real and
replacing it with a wrapper script.  This is unfortunately necessary
because maintainer scripts are in the habit of calling ldconfig
directly.  An alternative approach would be to change all of the
packages not to call ldconfig but instead to call a new script but
this would involve a much more complicated and lengthy transition.

The patch is safe to use with a non-triggers-supporting dpkg and in
all transitional states: where the trigger system is not properly set
up yet, ldconfig is run as normal.  Note that sid's dpkg does not yet
have the triggers patch merged but there has been extensive discussion
of the design and interfaces for triggers and the API should IMO be
considered stable.

These changes have been tested and released as part of Ubuntu 7.10 aka
`gutsy gibbon'.  The patch below is the consilidation of the results
of our testing.

So we believe that this patch can and should be safely applied to
sid's glibc straight away.

Ian.

diff --exclude='*.orig' -ruN orig/glibc-2.6.1/debian/debhelper.in/libc.postinst glibc-2.6.1/debian/debhelper.in/libc.postinst
--- orig/glibc-2.6.1/debian/debhelper.in/libc.postinst	2007-10-22 15:40:11.000000000 +0100
+++ glibc-2.6.1/debian/debhelper.in/libc.postinst	2007-10-22 15:38:11.000000000 +0100
@@ -5,6 +5,15 @@
 type=$1
 preversion=$2
 
+if [ "x$type" = xtriggered ]
+then
+	LDCONFIG_NOTRIGGER=y
+	export LDCONFIG_NOTRIGGER
+	echo ldconfig deferred processing now taking place
+	ldconfig
+	exit 0
+fi
+
 package_name()
 {
     echo LIBC
diff --exclude='*.orig' -ruN orig/glibc-2.6.1/debian/debhelper.in/libc.triggers glibc-2.6.1/debian/debhelper.in/libc.triggers
--- orig/glibc-2.6.1/debian/debhelper.in/libc.triggers	1970-01-01 01:00:00.000000000 +0100
+++ glibc-2.6.1/debian/debhelper.in/libc.triggers	2007-10-22 15:38:11.000000000 +0100
@@ -0,0 +1 @@
+interest ldconfig
diff --exclude='*.orig' -ruN orig/glibc-2.6.1/debian/local/ldconfig_wrap glibc-2.6.1/debian/local/ldconfig_wrap
--- orig/glibc-2.6.1/debian/local/ldconfig_wrap	1970-01-01 01:00:00.000000000 +0100
+++ glibc-2.6.1/debian/local/ldconfig_wrap	2007-10-22 15:39:01.000000000 +0100
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if  test $# = 0							\
+    && test x"$LDCONFIG_NOTRIGGER" = x				\
+ && test x"$DPKG_MAINTSCRIPT_PACKAGE" != x			\
+ && dpkg-trigger --check-supported 2>/dev/null			\
+ && dpkg --compare-versions "$DPKG_RUNNING_VERSION" ge '1.14.5ubuntu10~~'
+then
+	if dpkg-trigger --no-await ldconfig; then
+		if test x"$LDCONFIG_TRIGGER_DEBUG" != x; then
+			echo "ldconfig: wrapper deferring update (trigger activated)"
+		fi
+		exit 0
+	fi	
+fi
+
+exec /sbin/ldconfig.real "$@"
diff --exclude='*.orig' -ruN orig/glibc-2.6.1/debian/rules.d/debhelper.mk glibc-2.6.1/debian/rules.d/debhelper.mk
--- orig/glibc-2.6.1/debian/rules.d/debhelper.mk	2007-10-22 15:40:11.000000000 +0100
+++ glibc-2.6.1/debian/rules.d/debhelper.mk	2007-10-22 15:38:11.000000000 +0100
@@ -59,6 +59,13 @@
 	    dh_install -p$(curpass) debian/bug/$(curpass) usr/share/bug; \
 	fi
 
+	set -ex; case $(curpass) in libc6|libc6.1) \
+		mv debian/$(curpass)/sbin/ldconfig \
+			debian/$(curpass)/sbin/ldconfig.real; \
+		install -m755 -o0 -g0 debian/local/ldconfig_wrap \
+			debian/$(curpass)/sbin/ldconfig; \
+		;; esac
+
 	# extra_debhelper_pkg_install is used for debhelper.mk only.
 	# when you want to install extra packages, use extra_pkg_install.
 	$(call xx,extra_debhelper_pkg_install)
@@ -118,6 +125,11 @@
 			debian/$(curpass)/usr/share/lintian/overrides/$(curpass) ; \
 	fi
 
+	if [ -f debian/$(curpass).triggers ] ; then \
+		install -m 644 -o root -g root debian/$(curpass).triggers \
+			debian/$(curpass)/DEBIAN/triggers ; \
+	fi
+
 	if [ -f debian/$(curpass).linda ] ; then \
 		install -d -m 755 -o root -g root debian/$(curpass)/usr/share/linda/overrides/ ; \
 		install -m 644 -o root -g root debian/$(curpass).linda \

Reply to: