Last active
August 3, 2021 14:36
-
-
Save cloudnull/cb87440c8221104ed2b857e67289905f to your computer and use it in GitHub Desktop.
upgrade venvs on compute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# When upgrading from 16.04 to 18.04 a lot of new packages get installed and a lot of old packages get removed. | |
# The upgrade process can break things we rely on within the virtual environments we run openstack services within. | |
# This script will correct issues in the venvs by fixing broken symlinks to system libraries we require. | |
for venv in $(find /openstack/venvs/* -maxdepth 0 -type d); do | |
# Update the venvs in place with the new system python | |
virtualenv --no-wheel --no-pip --no-setuptools --always-copy --python=/usr/bin/python "${venv}" | |
# Correct SSL links | |
ln -sf /usr/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so "${venv}/local/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so" | |
ln -sf /usr/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so "${venv}/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so" | |
# Find broken links | |
for broken_link in $(find "${venv}" -type l ! -exec test -e {} \; -print); do | |
LOCAL_LIB=$(find /usr -name "$(basename -s .so ${broken_link}).x86_64-linux-gnu.so" -print -quit) | |
if [[ -z "${LOCAL_LIB}" ]]; then | |
echo "a broken link has been found within a venv and can not be automatically fixed" | |
echo "BROKEN LINK: ${broken_link}" | |
else | |
ln -sf "${LOCAL_LIB}" "${broken_link}" | |
fi | |
done | |
done |
When you change the line 22 this script works very well else it would overwrite the files in
/usr
with a symbolic link to a broken symbolic link in the venv.ln -sf "${LOCAL_LIB}" "${broken_link}"
👍 fixed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you change the line 22 this script works very well else it would overwrite the files in
/usr
with a symbolic link to a broken symbolic link in the venv.