Skip to content

Commit

Permalink
glibc: Provide script to update glibv-2.25-1 to 2.26-0.
Browse files Browse the repository at this point in the history
This is required, because a plain "bee update" is not
an atomic operation and would create incompatible
versions of ld-linux-x86-64.so.2 and libc.so.6
in the system and prevent the "bee update" to run
to cpmpletion.
  • Loading branch information
donald committed Oct 5, 2017
1 parent e4eea0c commit 22993eb
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions scripts/update-glibc-to-2.26.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 22993eb

Please sign in to comment.