diff --git a/scripts/update-glibc-to-2.26.sh b/scripts/update-glibc-to-2.26.sh new file mode 100755 index 000000000..421bb4370 --- /dev/null +++ b/scripts/update-glibc-to-2.26.sh @@ -0,0 +1,65 @@ +#! /bin/sh + +# Script to update glibc-2.25-1 to glibc-2.26-0 +# +# 2.25 ld-linux-x86-64.so.2 does not work with 2.26 libc.so.6 and visa versa +# plus there are a lot of other incompatibilities beween libraries provided +# by different glibc packages. +# +# This scripts attempts to switch the versions of conflicting shared libraries +# in a single atomic filesystem operation. + +set -e + +# same as "ln -sfT" but with a single rename() system call +# instead of unlink();symlink(); as "ln -sfT" would do. +# +function replace_with_symlink() { + local target="$1" + local linkname="$2" + + ln -sfT "$target" "$linkname.NEW" + mv -fT "$linkname.NEW" "$linkname" +} + +function die() { + echo "$@" >&2 + exit 1 +} + +cd /lib + +mkdir -p .glibc-switch/2.25 .glibc-switch/2.26 +(cd .glibc-switch/2.25 && tar xpf /src/mariux/beeroot/packages/glibc-2.25-1.x86_64.bee.tar.bz2) +(cd .glibc-switch/2.26 && tar xpf /src/mariux/beeroot/packages/glibc-2.26-0.x86_64.bee.tar.bz2) +ln -sfT 2.25 /lib/.glibc-switch/current + +# This link was accidentally omitted from glibc-2.25-1 +test -e .glibc-switch/2.25/lib/ld-linux-x86-64.so.2 || ln -s ld-2.25.so .glibc-switch/2.25/lib/ld-linux-x86-64.so.2 + +cd .glibc-switch/2.26 +for f in $(find lib usr/lib -name "*.so*"); do + if [[ -e /$f ]] # library exists in system + then + if [[ + $(stat -L --print "%s.%y" "/$f") != $(stat -L --print "%s.%y" "$f") # is not from the new glibc + && !(-L /$f && $(readlink "/$f") == /lib/.glibc-switch/*) # and is not already a version switcher symlink + ]]; then + # replace library by symlink to current (old) glibc version + test -e /lib/.glibc-switch/current/$f || die "$f: not found in old glibc" + echo replace_with_symlink "/lib/.glibc-switch/current/$f" "/$f" + replace_with_symlink "/lib/.glibc-switch/current/$f" "/$f" + fi + else + # provide new library in system + echo ln -fT "$f" "/$f" + ln -fT "$f" "/$f" + fi +done + +# now switch to new version +replace_with_symlink 2.26 /lib/.glibc-switch/current + +# fixup +bee update glibc-2.26-0.x86_64 +rm -r /lib/.glibc-switch