Bug#642076: Re: Bug#642076: lsb-core: no need to remove /lib/ld-lsb-x86-64.so.[23]

"Didier 'OdyX' Raboud" <[email protected]>
Newsgroups gmane.linux.debian.devel.lsb
Organization Debian, the Universal OS
Message-ID <4F50BA95.7090800__28613.0252680325$1330691097$gmane$org@debian.org>
tags 642076 +patch
thanks

Le 23.01.2012 21:44, Sven Joachim a écrit :
> On 2011-09-19 11:15 +0200, Colin Watson wrote:
>>
>> Nothing ever created /lib/ld-lsb-x86-64.so.[23] symlinks in the first
>> place, so as far as I can see there's no need to clean them up; the
>> problem was that the symlink *target* was wrong.  Isn't this dead code?
> 
> I don't think so, because /lib and /lib64 had been the same place in
> libc6 versions prior to 2.13-17, so there may be leftover symlinks there
> created by earlier lsb-core versions.
> 
>> (I initially thought that this was actively dangerous since /lib64 might
>> be a symlink to /lib so this would create the ld-lsb-* symlinks and then
>> delete them again, but since you depend on libc6 (>= 2.13-17) this
>> appears not to be the case.)
> 
> It would probably be better to only remove those symlinks on upgrades
> from versions < 3.2-28, and to do it before creating the new links.

Hi Colin and Sven, and thanks for your input on this bug;

I propose the attached patch to get this fixed by removing the symlinks
farm handling and replacing all symlinks by `solid` symlinks in the
packages. Please review and comment!

(I kept the removal of the supposedly-never-created symlinks in the
preinst assuming that no harm would be done anyway.)

Cheers,

OdyX
0001-Replace-lsb-core-s-symlink-farm-by-package-symlinks.patch (text/plain, 7.8 KB)
From 3520ec668ce06b9a09f9c259c27aea931cdc1edb Mon Sep 17 00:00:00 2001
From: Didier Raboud <[email protected]>
Date: Fri, 2 Mar 2012 11:47:34 +0100
Subject: [PATCH] Replace lsb-core's symlink farm by package symlinks

- Drop symlink farm handling in prerm/postinst.
- Create lsb-core.preinst to delete the symlink farm before unpacking those
  from the package.
- Use debhelper's lsb-core.links.$ARCH files to create the links
- Bugfix debian/rules' usage of DEB_HOST_ARCH.

Closes: #642076
Signed-off-by: Didier Raboud <[email protected]>
---
 debian/lsb-core.links.amd64       |    5 ++++
 debian/lsb-core.links.i386        |    3 ++
 debian/lsb-core.links.ia64        |    3 ++
 debian/lsb-core.links.otherarches |    3 ++
 debian/lsb-core.links.powerpc     |    3 ++
 debian/lsb-core.postinst          |   42 -------------------------------------
 debian/lsb-core.preinst           |   24 +++++++++++++++++++++
 debian/lsb-core.prerm             |   26 ----------------------
 debian/rules                      |    9 +++++++-
 9 files changed, 49 insertions(+), 69 deletions(-)
 create mode 100644 debian/lsb-core.links.amd64
 create mode 100644 debian/lsb-core.links.i386
 create mode 100644 debian/lsb-core.links.ia64
 create mode 100644 debian/lsb-core.links.otherarches
 create mode 100644 debian/lsb-core.links.powerpc
 create mode 100755 debian/lsb-core.preinst

diff --git a/debian/lsb-core.links.amd64 b/debian/lsb-core.links.amd64
new file mode 100644
index 0000000..009b344
--- /dev/null
+++ b/debian/lsb-core.links.amd64
@@ -0,0 +1,5 @@
+/lib/ld-linux.so.2 /lib/ld-lsb.so.1
+/lib/ld-linux.so.2 /lib/ld-lsb.so.2
+/lib/ld-linux.so.2 /lib/ld-lsb.so.3
+/lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.2
+/lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
diff --git a/debian/lsb-core.links.i386 b/debian/lsb-core.links.i386
new file mode 100644
index 0000000..61392d9
--- /dev/null
+++ b/debian/lsb-core.links.i386
@@ -0,0 +1,3 @@
+/lib/ld-linux.so.2 /lib/ld-lsb.so.1
+/lib/ld-linux.so.2 /lib/ld-lsb.so.2
+/lib/ld-linux.so.2 /lib/ld-lsb.so.3
diff --git a/debian/lsb-core.links.ia64 b/debian/lsb-core.links.ia64
new file mode 100644
index 0000000..6a4ffd2
--- /dev/null
+++ b/debian/lsb-core.links.ia64
@@ -0,0 +1,3 @@
+/lib/ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.1
+/lib/ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.2
+/lib/ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.3
diff --git a/debian/lsb-core.links.otherarches b/debian/lsb-core.links.otherarches
new file mode 100644
index 0000000..e910559
--- /dev/null
+++ b/debian/lsb-core.links.otherarches
@@ -0,0 +1,3 @@
+/lib/ld.so.1 /lib/ld-lsb-##ARCH##.so.1
+/lib/ld.so.1 /lib/ld-lsb-##ARCH##.so.2
+/lib/ld.so.1 /lib/ld-lsb-##ARCH##.so.3
diff --git a/debian/lsb-core.links.powerpc b/debian/lsb-core.links.powerpc
new file mode 100644
index 0000000..e0b6868
--- /dev/null
+++ b/debian/lsb-core.links.powerpc
@@ -0,0 +1,3 @@
+/lib/ld.so.1 /lib/ld-lsb-ppc32.so.1
+/lib/ld.so.1 /lib/ld-lsb-ppc32.so.2
+/lib/ld.so.1 /lib/ld-lsb-ppc32.so.3
diff --git a/debian/lsb-core.postinst b/debian/lsb-core.postinst
index 0321747..2ad788c 100755
--- a/debian/lsb-core.postinst
+++ b/debian/lsb-core.postinst
@@ -2,47 +2,6 @@
 
 set -e
 
-setup_ldso_symlink () {
-    ARCH=$DPKG_MAINTSCRIPT_ARCH
-    if [ -z "$ARCH" ]; then
-        ARCH=$(dpkg --print-architecture)
-    fi
-    case "$ARCH" in
-        s390|ppc64|sparc|sparc64|alpha|hppa|m68k|mipsel)
-            ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.1
-            ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.2
-            ln -sf ld.so.1 /lib/ld-lsb-$ARCH.so.3
-            ;;
-        powerpc)
-            ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.1
-            ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.2
-            ln -sf ld.so.1 /lib/ld-lsb-ppc32.so.3
-            ;;
-        i386)
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.1
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.2
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.3
-            ;;
-        amd64)
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.1
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.2
-            ln -sf ld-linux.so.2 /lib/ld-lsb.so.3
-            ln -sf ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.2
-            ln -sf ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
-            [ -L /lib/ld-lsb-x86-64.so.2 ] && rm /lib/ld-lsb-x86-64.so.2 || true
-            [ -L /lib/ld-lsb-x86-64.so.3 ] && rm /lib/ld-lsb-x86-64.so.3 || true
-            ;;
-        ia64)
-            ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.1
-            ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.2
-            ln -sf ld-linux-ia64.so.2 /lib/ld-lsb-ia64.so.3
-            ;;
-        *)
-            echo "ld-lsb-*.so.1 symlink for $ARCH is unknown!"
-            ;;
-    esac
-}
-
 PATH=/sbin:/usr/sbin:$PATH
 export PATH
 
@@ -56,7 +15,6 @@ case "$1" in
                 shadowconfig on >&2 || true
             fi
         fi
-        setup_ldso_symlink
         ;;
     abort-upgrade|abort-remove|abort-deconfigure)
         ;;
diff --git a/debian/lsb-core.preinst b/debian/lsb-core.preinst
new file mode 100755
index 0000000..26baa6a
--- /dev/null
+++ b/debian/lsb-core.preinst
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+  install|upgrade)
+    if dpkg --compare-versions "$2" lt "3.2+Debian30" ; then
+      # 32 bits arches
+      rm -f /lib/ld-lsb-*.so.[123]
+      # 64 bits
+      rm -f /lib64/ld-lsb-*.so.[23]
+      # legacy x86
+      rm -f /lib/ld-lsb.so.[123]
+    fi
+  ;;
+  abort-upgrade)
+  ;;
+  *)
+    echo "preinst called with unknown argument \`$1'" >&2
+    exit 1
+  ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/lsb-core.prerm b/debian/lsb-core.prerm
index e6b26b6..94bf203 100644
--- a/debian/lsb-core.prerm
+++ b/debian/lsb-core.prerm
@@ -2,36 +2,11 @@
 
 set -e
 
-remove_ldso_symlink () {
-    ARCH=$DPKG_MAINTSCRIPT_ARCH
-    if [ -z "$ARCH" ]; then
-        ARCH=$(dpkg --print-architecture)
-    fi
-    case "$ARCH" in
-        s390|ia64|ppc64|sparc|sparc64|alpha|hppa|m68k|mipsel)
-            rm -f /lib/ld-lsb-$ARCH.so.[123]
-            ;;
-        powerpc)
-            rm -f /lib/ld-lsb-ppc32.so.[123]
-            ;;
-        i386)
-            rm -f /lib/ld-lsb.so.[123]
-            ;;
-        amd64)
-            rm -f /lib/ld-lsb.so.[123] /lib64/ld-lsb-x86-64.so.[23] /lib/ld-lsb-x86-64.so.[23]
-            ;;
-        *)
-            echo "ld-lsb-*.so.1 symlink for $ARCH is unknown; not removed."
-            ;;
-    esac
-}
-
 PATH=/sbin:/usr/sbin:$PATH
 export PATH
 
 case "$1" in
     remove)
-        remove_ldso_symlink
         rm -f /var/lib/lsb/facilities
         rm -f /var/lib/lsb/depends
         ;;
@@ -43,5 +18,4 @@ case "$1" in
     ;;
 esac
 
-
 #DEBHELPER#
diff --git a/debian/rules b/debian/rules
index d923da5..707fa16 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,7 +9,7 @@ derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes")
 # from having to guess our platform (since we know it already)
 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
 
 # Map Debian architectures to LSB architectures
 lsbarch=${DEB_HOST_ARCH}
@@ -54,6 +54,13 @@ ifeq ($(derives_from_ubuntu),yes)
 	cp -p lsb-base-logging-ubuntu.sh debian/lsb-base/etc/lsb-base-logging.sh
 endif
 
+override_dh_link:
+	# For many architectures, take the standard arch'ified links
+ifneq ($(filter $(DEB_HOST_ARCH), s390 ppc64 sparc sparc64 alpha hppa m68k mipsel),)
+	sed -e 's/##ARCH##/${DEB_HOST_ARCH}/' debian/lsb-core.links.otherarches > debian/lsb-core.links.${DEB_HOST_ARCH}
+endif
+	dh_link
+
 override_dh_gencontrol:
 	@echo >> debian/lsb-core.substvars "glibc=${LIBC}"
 #	@[ ${DEB_HOST_GNU_TYPE} != 'arm-linux-gnueabi' ] && echo >> debian/lsb-cxx.substvars "depends=libstdc++5" || true
-- 
1.7.2.5
signature.asc (application/pgp-signature, 663 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQGcBAEBAgAGBQJPULqVAAoJEIvPpx7KFjRVTIUL/i0RI0YMCvhtXW8A0J/JiZBJ
AtP3qhACGB/iqkuRFSyvjLpfOCzrtX2i0ZQNvYNvHufWzjip2KEVXn1YE2nWDbZU
gzmC4dX1aFu+11IjC14T/ZSTZCGfDV5EO/R9/Qsjv3GXb+na21u6SvSHxbjZzAN/
qYQFPXgRXU7hBGzxGgLG2U7+zXwX3p77UhYU2cXErhJo5TxYeF9ddmCN/ESvdW+S
o446o/AjRxQsv61wZHetFN3Fsdpi4meFsOgAdq3Y44f1E46igaor7PsNOIP9RBP0
JN0kRZKCxKq3Kb2Bg0WOZ+cKduCsqdc3rYYuJ+6PjTrloUXp4L9Q/t1O6hn8ZK0e
tfwHdqWWG6twTbtcUVVjcWMmOWkjFAEwly8Dv6+dsQXfeaoSrzrWXJTWjl9QxINH
SpWJheRzhCF/GMiYAw6pPzzLfyubTuK+mf3V+dM4r0DtTH1sYrI5PY6liyhljfr2
82pmOpHOvGmGf+r/ZHxlbiSUiZxK7K03j5EWc/7VJw==
=mp4e
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.