| 1 | #!/bin/sh |
|---|
| 2 | # Copyright (C) 2002, 2005 Slackware Linux, Inc. |
|---|
| 3 | # Copyright 2005, 2006, 2011, 2012 Patrick J. Volkerding, Sebeka, Minnesota, USA |
|---|
| 4 | # |
|---|
| 5 | # This program is free software; you can redistribute it and/or |
|---|
| 6 | # modify it under the terms of the GNU General Public License |
|---|
| 7 | # as published by the Free Software Foundation; either version 2 |
|---|
| 8 | # of the License, or (at your option) any later version. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # Swap glibc on the fly. |
|---|
| 16 | # |
|---|
| 17 | # If we're on a running system we have to handle this _very_ carefully. :-) |
|---|
| 18 | # The tricks involved here get trickier every time... |
|---|
| 19 | |
|---|
| 20 | # OK, now we have to be sure of a few things. First, you do have a 2.6 |
|---|
| 21 | # kernel running, right? |
|---|
| 22 | |
|---|
| 23 | if [ -r /proc/ksyms ]; then |
|---|
| 24 | echo "FATAL: you need to be running a 2.6.x kernel in order to upgrade" |
|---|
| 25 | echo "to this version of glibc." |
|---|
| 26 | echo |
|---|
| 27 | sleep 999 |
|---|
| 28 | exit 1 |
|---|
| 29 | fi |
|---|
| 30 | |
|---|
| 31 | # Next, stop using the /lib/ntpl libraries. These are now obsolete and |
|---|
| 32 | # will break the installation if present: |
|---|
| 33 | if [ -d lib/tls ]; then |
|---|
| 34 | mkdir -p lib/obsolete |
|---|
| 35 | mv lib/tls lib/obsolete |
|---|
| 36 | fi |
|---|
| 37 | if [ -x sbin/ldconfig ]; then |
|---|
| 38 | sbin/ldconfig -r . |
|---|
| 39 | fi |
|---|
| 40 | |
|---|
| 41 | # Install NPTL glibc libraries: |
|---|
| 42 | if [ -x /sbin/ldconfig -a -d lib/incoming ]; then # swap on the fly |
|---|
| 43 | # First create copies of the incoming libraries: |
|---|
| 44 | ( cd lib/incoming |
|---|
| 45 | for file in * ; do |
|---|
| 46 | if [ ! -r ../${file}.incoming ]; then |
|---|
| 47 | cp -a $file ../${file}.incoming |
|---|
| 48 | fi |
|---|
| 49 | done |
|---|
| 50 | ) |
|---|
| 51 | # Then switch to them all at once: |
|---|
| 52 | /sbin/ldconfig -l lib/*.incoming 2> /dev/null |
|---|
| 53 | # Finally, rename them and clean up: |
|---|
| 54 | ( cd lib |
|---|
| 55 | for file in *.incoming ; do |
|---|
| 56 | rm -f `basename $file .incoming` |
|---|
| 57 | cp -a $file `basename $file .incoming` |
|---|
| 58 | /sbin/ldconfig -l `basename $file .incoming` |
|---|
| 59 | rm -f $file |
|---|
| 60 | done |
|---|
| 61 | ) |
|---|
| 62 | else # no ldconfig? Good, it's safe to just jam it on home (and make links below): |
|---|
| 63 | ( cd lib/incoming |
|---|
| 64 | for file in * ; do |
|---|
| 65 | cp -a $file .. |
|---|
| 66 | done |
|---|
| 67 | ) |
|---|
| 68 | fi |
|---|
| 69 | # Now, get rid of the temporary directory: |
|---|
| 70 | rm -rf lib/incoming |
|---|
| 71 | # Done installing NPTL glibc libraries. |
|---|
| 72 | |
|---|
| 73 | # Handle config files: |
|---|
| 74 | config() { |
|---|
| 75 | NEW="$1" |
|---|
| 76 | OLD="$(dirname $NEW)/$(basename $NEW .new)" |
|---|
| 77 | # If there's no config file by that name, mv it over: |
|---|
| 78 | if [ ! -r $OLD ]; then |
|---|
| 79 | mv $NEW $OLD |
|---|
| 80 | elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy |
|---|
| 81 | rm $NEW |
|---|
| 82 | fi |
|---|
| 83 | # Otherwise, we leave the .new copy for the admin to consider... |
|---|
| 84 | } |
|---|
| 85 | config etc/profile.d/glibc.csh.new |
|---|
| 86 | config etc/profile.d/glibc.sh.new |
|---|
| 87 | # Clearly you already decided this issue. :-) |
|---|
| 88 | rm -f etc/profile.d/glibc.csh.new |
|---|
| 89 | rm -f etc/profile.d/glibc.sh.new |
|---|
| 90 | |
|---|
| 91 | # In case there's no ldconfig, make the links manually: |
|---|
| 92 | if [ ! -x /sbin/ldconfig ]; then |
|---|
| 93 | ( cd lib ; rm -rf libnss_nis.so.2 ) |
|---|
| 94 | ( cd lib ; ln -sf libnss_nis-@@VERSION@@.so libnss_nis.so.2 ) |
|---|
| 95 | ( cd lib ; rm -rf libm.so.6 ) |
|---|
| 96 | ( cd lib ; ln -sf libm-@@VERSION@@.so libm.so.6 ) |
|---|
| 97 | ( cd lib ; rm -rf libnss_files.so.2 ) |
|---|
| 98 | ( cd lib ; ln -sf libnss_files-@@VERSION@@.so libnss_files.so.2 ) |
|---|
| 99 | ( cd lib ; rm -rf libresolv.so.2 ) |
|---|
| 100 | ( cd lib ; ln -sf libresolv-@@VERSION@@.so libresolv.so.2 ) |
|---|
| 101 | ( cd lib ; rm -rf libnsl.so.1 ) |
|---|
| 102 | ( cd lib ; ln -sf libnsl-@@VERSION@@.so libnsl.so.1 ) |
|---|
| 103 | ( cd lib ; rm -rf libutil.so.1 ) |
|---|
| 104 | ( cd lib ; ln -sf libutil-@@VERSION@@.so libutil.so.1 ) |
|---|
| 105 | ( cd lib ; rm -rf libnss_compat.so.2 ) |
|---|
| 106 | ( cd lib ; ln -sf libnss_compat-@@VERSION@@.so libnss_compat.so.2 ) |
|---|
| 107 | ( cd lib ; rm -rf libthread_db.so.1 ) |
|---|
| 108 | ( cd lib ; ln -sf libthread_db-1.0.so libthread_db.so.1 ) |
|---|
| 109 | ( cd lib ; rm -rf libnss_hesiod.so.2 ) |
|---|
| 110 | ( cd lib ; ln -sf libnss_hesiod-@@VERSION@@.so libnss_hesiod.so.2 ) |
|---|
| 111 | ( cd lib ; rm -rf libanl.so.1 ) |
|---|
| 112 | ( cd lib ; ln -sf libanl-@@VERSION@@.so libanl.so.1 ) |
|---|
| 113 | ( cd lib ; rm -rf libcrypt.so.1 ) |
|---|
| 114 | ( cd lib ; ln -sf libcrypt-@@VERSION@@.so libcrypt.so.1 ) |
|---|
| 115 | ( cd lib ; rm -rf libBrokenLocale.so.1 ) |
|---|
| 116 | ( cd lib ; ln -sf libBrokenLocale-@@VERSION@@.so libBrokenLocale.so.1 ) |
|---|
| 117 | ( cd lib ; rm -rf ld-linux.so.2 ) |
|---|
| 118 | ( cd lib ; ln -sf ld-@@VERSION@@.so ld-linux.so.2 ) |
|---|
| 119 | ( cd lib ; rm -rf libdl.so.2 ) |
|---|
| 120 | ( cd lib ; ln -sf libdl-@@VERSION@@.so libdl.so.2 ) |
|---|
| 121 | ( cd lib ; rm -rf libnss_dns.so.2 ) |
|---|
| 122 | ( cd lib ; ln -sf libnss_dns-@@VERSION@@.so libnss_dns.so.2 ) |
|---|
| 123 | ( cd lib ; rm -rf libpthread.so.0 ) |
|---|
| 124 | ( cd lib ; ln -sf libpthread-@@VERSION@@.so libpthread.so.0 ) |
|---|
| 125 | ( cd lib ; rm -rf libnss_nisplus.so.2 ) |
|---|
| 126 | ( cd lib ; ln -sf libnss_nisplus-@@VERSION@@.so libnss_nisplus.so.2 ) |
|---|
| 127 | ( cd lib ; rm -rf libc.so.6 ) |
|---|
| 128 | ( cd lib ; ln -sf libc-@@VERSION@@.so libc.so.6 ) |
|---|
| 129 | ( cd lib ; rm -rf librt.so.1 ) |
|---|
| 130 | ( cd lib ; ln -sf librt-@@VERSION@@.so librt.so.1 ) |
|---|
| 131 | fi |
|---|
| 132 | |
|---|
| 133 | # Reload to prevent init from holding a stale handle to glibc on shutdown: |
|---|
| 134 | if [ -x /sbin/telinit ]; then |
|---|
| 135 | /sbin/telinit u |
|---|
| 136 | fi |
|---|
| 137 | |
|---|