Last active
July 21, 2017 03:36
-
-
Save LoganDark/6d473f42fcb59c3eee25783ce342c7ed to your computer and use it in GitHub Desktop.
A small script I created to install missing libraries for commands installed via slackpkg.
This file contains hidden or 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
bin= | |
if [ -z "$1" ]; then | |
read -p 'Please enter the name of a command with missing libraries: ' bin | |
else | |
bin="$1" | |
fi | |
printf ' | |
' | |
bin=`which "$bin"` | |
if [ '0' -ne "$?" ]; then | |
echo 'That command could not be located successfully.' | |
exit 1 | |
fi | |
ldd=`ldd "$bin"` | |
not_founds=`echo "$ldd" | egrep -o '\S+ => not found' | egrep -o '^\S+'` | |
if [ -z "$not_founds" ]; then | |
echo 'That command seems to already have all the libraries it needs.' | |
exit 1 | |
fi | |
printf 'Libraries to locate: | |
%s | |
' "$not_founds" | |
searched=`slackpkg file-search "$not_founds"` | |
to_install=`echo "$searched" | egrep -o '\[uninstalled\] - \S+' | egrep -o '\S+$'` | |
to_upgrade=`echo "$searched" | egrep -o '\[ upgrade \] - \S+ --> \S+' | egrep -o '\S+$'` | |
if [ -z "$to_install" -a -z "$to_upgrade" ]; then | |
echo 'Couldn\'t find any packages to install.' | |
exit 1 | |
fi | |
printf 'Packages that will be installed: | |
%s | |
' "$to_install" | |
printf 'Packages that will be upgraded: | |
%s | |
' "$to_upgrade" | |
if read -p 'Press any key to continue, or ^C to cancel' -n 1 -s; then | |
slackpkg install "$to_install" | |
slackpkg upgrade "$to_upgrade" | |
else | |
printf ' | |
Canceled.' | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment