r4762 - in glibc-package/trunk/debian: . debhelper.in
Author: aurel32
Date: 2011-06-28 20:38:54 +0000 (Tue, 28 Jun 2011)
New Revision: 4762
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/debhelper.in/libc.preinst
Log:
* libc.preinst: improve and simplify search for old libraries, detect
broken LD_LIBRARY_PATH. Closes: #630608.
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2011-06-28 19:40:19 UTC (rev 4761)
+++ glibc-package/trunk/debian/changelog 2011-06-28 20:38:54 UTC (rev 4762)
@@ -25,7 +25,8 @@
* Fix patches/hppa/submitted-nptl-carlos.diff to correctly pass
--as-needed and --no-as-needed to the linker.
* Update breaks on pre-multiarch packages. Closes: #631907.
- * libc.preinst: detect broken LD_LIBRARY_PATH. Closes: #630608.
+ * libc.preinst: improve and simplify search for old libraries, detect
+ broken LD_LIBRARY_PATH. Closes: #630608.
* kfreebsd/local-sysdeps.diff, update to revision 3501 (from glibc-bsd),
to fix <bits/siginfo.h>. Closes: #631867.
Modified: glibc-package/trunk/debian/debhelper.in/libc.preinst
===================================================================
--- glibc-package/trunk/debian/debhelper.in/libc.preinst 2011-06-28 19:40:19 UTC (rev 4761)
+++ glibc-package/trunk/debian/debhelper.in/libc.preinst 2011-06-28 20:38:54 UTC (rev 4762)
@@ -156,43 +156,61 @@
# with different sonames, and libraries incompatible with the
# to-be-installed ld.so.
-check_dirs () {
- for dir in $*; do
- # Follow symlinks
- dirlink=$(readlink -e $dir)
- [ -n "$dirlink" ] && dir=$dirlink
-
- # Handle /lib in LD_LIBRARY_PATH.
- if expr $dir : "/lib.*" > /dev/null; then
+check_dir () {
+ msg=$1
+ dir=$2
+
+ # Follow symlinks
+ dir=$(readlink -e $dir || true)
+
+ # Ignore inexistent directories
+ if ! test -d "$dir" ; then
+ return
+ fi
+
+ # Detect possible candidates
+ files=$(ls $dir | egrep '^(ld|lib(d|c|m|pthread|rt|dl))-2.*.so' 2>/dev/null || true)
+ if test -z "$files" ; then
+ return
+ fi
+
+ for file in $files ; do
+ lib=$dir/$file
+
+ # Skip if it is a symlink (as installed by lsb-core)
+ if test -L "$lib" ; then
continue
fi
- # Skip ia32-libs package on ia64, and similar libraries
- # (not sure why these get added to /etc/ld.so.conf)
- if expr $dir : "/emul/.*" > /dev/null; then
+
+ # Skip if it is the currently dynamic loader
+ if test "$lib" = "$ldfile" ; then
continue
fi
- if test -d $dir; then
- output=$(ls $dir | egrep '^(C_SO|M_SO|PTHREAD_SO|RT_SO|DL_SO)$' 2>/dev/null)
- if test -n "$output"; then
- # See if the found libraries are compatible with the system ld.so;
- # if they aren't, they'll be ignored. Check e_ident, e_type (which
- # will just be ET_DYN), and e_machine. If a match is found, there
- # is a risk of breakage.
- for lib in $output
- do
- if test -f "$dir/$lib"; then
- libbytes=`head -c 20 $dir/$lib | od -c`
- if test "$ldbytes" = "$libbytes"; then
- echo "Matching libraries: $dir/$lib"
- return 0
- fi
- fi
- done
- fi
+ # See if the found libraries are compatible with the system ld.so;
+ # if they aren't, they'll be ignored. Check e_ident, e_type (which
+ # will just be ET_DYN), and e_machine. If a match is found, there
+ # is a risk of breakage.
+ libbytes=`head -c 20 $lib | od -c`
+ if test "$ldbytes" != "$libbytes" ; then
+ continue
fi
+
+ # Binaries owned packages are considered to do the right thing
+ if echo $libcfiles | grep -q "[ ^]$lib[ $]" ; then
+ continue
+ fi
+
+ # Output an error message and exit
+ echo
+ echo "A copy of the C library was found $msg:"
+ echo " '$lib'"
+ echo "It is not safe to upgrade the C library in this situation;"
+ echo "please remove that copy of the C library or get it out of"
+ echo "'$dir' and try again."
+ echo
+ exit 1
done
- return 1
}
if [ "$type" != abort-upgrade ]
@@ -211,7 +229,6 @@
;;
esac
done
-
if test -n "$seen_traditional" && test -z "$seen_multiarch" ; then
echo
echo "LD_LIBRARY_PATH contains the traditional /lib directory,"
@@ -219,74 +236,37 @@
echo "It is not safe to upgrade the C library in this situation;"
echo "please remove the /lib/directory from LD_LIBRARY_PATH and"
echo "try again."
- exit 1
- fi
-
- ldbytes=`head -c 20 RTLD_SO | od -c`
- dirs="/lib32 /lib64 /usr/local/lib /usr/local/lib32 /usr/local/lib64"
- if ! test -L /usr; then
- dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
- fi
- if check_dirs $dirs; then
echo
- echo "A copy of glibc was found in an unexpected directory."
- echo "It is not safe to upgrade the C library in this situation;"
- echo "please remove that copy of the C library and try again."
exit 1
fi
+ # Try to detect copies of the libc library in the various places
+ # the dynamic linker uses.
+ ldfile=$(readlink -e RTLD_SO)
+ ldbytes=$(head -c 20 RTLD_SO | od -c)
+ libcfiles=$(dpkg-query -L LIBC 2>/dev/null)
+
+ dirs="SLIBDIR /lib /lib/tls /lib32 /lib64 /usr/local/lib /usr/local/lib32 /usr/local/lib64"
+ for dir in $dirs ; do
+ check_dir "in an unexpected directory" $dir
+ done
+
if test -n "$LD_LIBRARY_PATH"; then
dirs=$(echo $LD_LIBRARY_PATH | sed 's/:/ /g')
- if check_dirs $dirs; then
- echo
- echo "Another copy of the C library was found via LD_LIBRARY_PATH."
- echo "It is not safe to upgrade the C library in this situation;"
- echo "please remove the directory from LD_LIBRARY_PATH and try again."
- exit 1
- fi
+ for dir in $dirs ; do
+ check_dir "via LD_LIBRARY_PATH" $dir
+ done
fi
+
if test -e /etc/ld.so.conf; then
dirs=$(echo $(cat /etc/ld.so.conf))
- if check_dirs $dirs; then
- echo
- echo "Another copy of the C library was found via /etc/ld.so.conf."
- echo "It is not safe to upgrade the C library in this situation;"
- echo "please remove the directory from /etc/ld.so.conf and try again."
- exit 1
+ if test -n "$dirs" ; then
+ for dir in $dirs ; do
+ check_dir "via /etc/ld.so.conf" $dir
+ done
fi
fi
- for dir in /lib /lib/tls ; do
- for i in $dir/ld*.so* ; do
- # Skip if no match
- if [ "$i" = "$dir/ld*.so*" ] ; then
- continue
- fi
- # Skip if it is a symlink (as installed by lsb-core)
- if test -L "$i" ; then
- continue
- fi
- # Binaries owned packages are considered to do the right thing
- if dpkg-query -L LIBC 2>/dev/null | grep -q "$i"; then
- continue
- fi
- # Remove leftovers from libc5 to libc6 transition
- case "$i" in
- /lib/ld.so | /lib/ld.so.1.*.*)
- echo "Warning: removing leftover from libc5 to libc6 transition: '$i'"
- rm -f "$i"
- continue
- ;;
- esac
- # Stop the upgrade if there is a risk of crash after the upgrade
- echo
- echo "A non-dpkg owned copy of the C library was found:"
- echo " '$i'"
- echo "It is not safe to upgrade the C library in this situation;"
- echo "please remove that copy of the C library or get it out of"
- echo "'$dir' and try again."
- exit 1
- done
- done
+
if [ -e /lib/tls/i686/cmov/libc.so.6 ] || [ -e /lib/i686/cmov/libc.so.6 ] ; then
status_i686=$(dpkg -s libc6-i686 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
status_xen=$(dpkg -s libc6-xen 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
@@ -296,9 +276,11 @@
echo "A non-dpkg owned copy of the libc6-i686 package was found."
echo "It is not safe to upgrade the C library in this situation;"
echo "please remove that copy of the C library and try again."
+ echo
exit 1
fi
fi
+
if [ -n "$LD_ASSUME_KERNEL" ] ; then
if dpkg --compare-versions "$LD_ASSUME_KERNEL" le "2.6.1"; then
echo
@@ -306,6 +288,7 @@
echo "or later. It appears that LD_ASSUME_KERNEL is set to $LD_ASSUME_KERNEL."
echo "It is not safe to upgrade the C library in this situation;"
echo "Please unset this environment variable and try again."
+ echo
exit 1
fi
fi
Reply to: