-
-
Save deeagle/768bc0b50bf705e6edb027a04c14c076 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Needed for debian upgrade | |
# atm from buster to bullseye the linked libs are broken | |
# see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951880 | |
LIB="libcrypt.so.1" | |
# Checks if the executer has super user permissions. | |
# | |
# @exit 2 if the user has no super user permissions | |
function validateRootPermissions() { | |
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | |
echo "[ERR!] script must be run as root (sudo) and you're not root." | |
exit 2 | |
fi | |
} | |
# Validates the existing of: | |
# - the source library exists (normally a link to the lib file) | |
# - both destinations are symlinks | |
function validateLibsExists() { | |
if [[ ! -f "/lib/x86_64-linux-gnu/${LIB}" ]]; then | |
echo "ERROR: Library file </lib/x86_64-linux-gnu/${LIB}> does not exists." | |
exit 1 | |
fi | |
if [[ ! -L "/lib64/${LIB}" ]]; then | |
echo "ERROR: Library symlink </lib64/${LIB}> does not exists." | |
exit 2 | |
fi | |
if [[ ! -L "/lib/x86_64-linux-gnu/${LIB}" ]]; then | |
echo "ERROR: Library symlink </lib/x86_64-linux-gnu/${LIB}> does not exists." | |
exit 3 | |
fi | |
} | |
# Analyse the src and dest libs and if they link this src lib. | |
function analyseLibLinks() { | |
validateLibsExists | |
local correctPathSrcLib="$(readlink -f "/lib/x86_64-linux-gnu/${LIB}")" | |
if [[ $(readlink -f "/lib64/${LIB}") = "${correctPathSrcLib}" ]]; then | |
echo "[ ok ] $(ls -la "/lib64/${LIB}")" | |
else | |
echo "[ERR!] $(ls -la "/lib64/${LIB}")" | |
fi | |
if [[ $(readlink -f "/lib/x86_64-linux-gnu/${LIB}") = "${correctPathSrcLib}" ]]; then | |
echo "[ ok ] $(ls -la "/lib/x86_64-linux-gnu/${LIB}")" | |
else | |
echo "[ERR!] $(ls -la "/lib/x86_64-linux-gnu/${LIB}")" | |
fi | |
} | |
# Simple list of the symlinks to check. | |
function showLibLinks() { | |
ls -la "/lib64/${LIB}" | |
ls -la "/lib/x86_64-linux-gnu/${LIB}" | |
} | |
# Removes the old links and set the new symlinks. | |
function changeLibLinks() { | |
sudo rm "/lib64/${LIB}" | |
sudo rm "/lib/x86_64-linux-gnu/${LIB}" | |
sudo ln -s "/usr/lib/x86_64-linux-gnu/${LIB}" "/lib64/${LIB}" | |
sudo ln -s "/usr/lib/x86_64-linux-gnu/${LIB}" "/lib/x86_64-linux-gnu/${LIB}" | |
} | |
# Prints the help to stdout. | |
function printHelp() { | |
cat <<EOF | |
Project: rlxcrypt | |
Desc: Repair lib error XCRYPT2.x, XCRYPT4.4 not found. | |
Version: 0.0.2 | |
Infos: Martin Kock <[email protected]> | |
Possible options: | |
-a | --analyse Show the actual linked libraries | |
-r | --repair Change the library links to </usr/lib/x86_64-linux-gnu/${LIB} | |
-h | --help prints this help | |
EOF | |
} | |
# Catch arguments and go | |
if [[ $# -eq 0 ]]; then | |
# starts the main function | |
printHelp | |
else | |
case "${1}" in | |
-a | --analyse) | |
analyseLibLinks | |
;; | |
-r | --repair) | |
validateRootPermissions | |
changeLibLinks | |
;; | |
-h | --help | *) | |
printHelp | |
;; | |
esac | |
fi | |
exit 0 |
Sorry but the solution you wrote did not solve for me.
I keep getting the error after the update and go to KP.
I have to restore with rsync to have a bootable system again.
@famarm I'm sorry about that, but good thing you have a backup of the pre-situation.
My system runs clean with this workaround but I run the following cli loop til apt
says "nothing to do":
apt upgrade -yq
bash repair-libcrypt-v2.sh
Overall, though, this is a really terrible situation. Yes, it is testing, but I would have thought that the kind of bugs are found between unstable and testing.
Let's see how to support the community process in the future.
Good luck too you
After spending even more time on this issue, I found a simple way of fixing all the lib related issues that pop up during the upgrade, since there is a bunch.
Simply install usrmerge, modify the script to remove the files located in the /usr directories when it errors, run till it's finally happy and run the upgrade afterwards. Just works.
Here the repair steps as script.
edit: add
echo
toperl -v
-call