Created
March 22, 2014 23:39
-
-
Save nickjacob/9716113 to your computer and use it in GitHub Desktop.
script to safely upgrade starcluster & dependencies
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 | |
# upgrade starcluster | |
#### | |
mute_run () | |
{ | |
$* >/dev/null 2>&1 | |
} | |
cecho () | |
{ | |
local _c=$1; shift | |
echo -e "$(tput setaf $_c )$@$(tput sgr0)" | |
} | |
err () | |
{ | |
cecho 1 "$@" | |
} | |
tabecho () | |
{ | |
perl -sne '$|=1; print "[$pp]\t$_"' -- -pp="$1" | |
} | |
is_installed_pip () | |
{ | |
pip list 2>&1 | grep -q "$1" | |
} | |
#### | |
# actual code | |
#### | |
STARCLUSTER_DEPS=(ecdsa iso8601) | |
CRYPTO_DEPS=(scp boto) | |
OTHER_PKGS=(pycrypto markupsafe) | |
# test whether or not we need to sudo | |
USE_SUDO="" | |
which pip | grep -Eq -e 'Users|home' || | |
{ USE_SUDO="sudo"; cecho 3 "\t- using sudo"; } && cecho 3 "\t- using venv"; | |
# test for PIP being at the correct version/upgrade pip | |
cecho 2 "upgrading PIP and testing for features" | |
$USE_SUDO easy_install --upgrade pip | tabecho "easy_install" | |
if [ $? -ne 0 ]; then | |
err "PIP upgrade failed. Sorry" | |
exit 2; | |
fi | |
mute_run "pip uninstall --help" | |
if [ $? -ne 0 ]; then | |
err "PIP does not have correct features. Exiting" | |
exit 2; | |
fi | |
if pip --version; then | |
echo "pip" | |
else | |
err "what" | |
exit 22; | |
fi | |
if pip list | grep -E starcluster; then | |
yes | pip uninstall starcluster | |
$USE_SUDO rm -f $pip_loc | |
fi | |
# uninstall all of the dependencies | |
cecho 2 "uninstalling all dependencies" | |
for pkg in ${STARCLUSTER_DEPS[@]}; do | |
is_installed_pip $pkg && yes | pip uninstall $pkg | tabecho "uninstall" | |
done | |
for pkg in ${CRYPTO_DEPS[@]}; do | |
is_installed_pip $pkg && yes | pip uninstall $pkg | tabecho "uninstall" | |
done | |
for pkg in ${OTHER_PKGS[@]}; do | |
is_installed_pip $pkg && yes | pip uninstall $pkg | tabecho "uninstall" | |
done | |
cecho 2 "starcluster uninstalled. Successfully" | |
cecho 2 "installing starcluster dependencies" | |
for dep in ${STARCLUSTER_DEPS[@]}; do | |
$USE_SUDO pip install $dep | tabecho "pip-$dep" | |
if [ $? -ne 0 ]; then | |
err "unable to install $dep." | |
exit 2; | |
fi | |
done | |
if pip --version; then | |
echo "pip" | |
else | |
err "what" | |
exit 22; | |
fi | |
cecho 2 "installing pycrypto with compiler flags" | |
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future \ | |
$USE_SUDO pip install pycrypto | tabecho "pip-pycrypto" | |
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future \ | |
$USE_SUDO pip install MarkupSafe | tabecho "pip-markupsafe" | |
if [ $? -ne 0 ]; then | |
err "error installing pycrypto!" | |
exit 2; | |
fi | |
for dep in ${CRYPTO_DEPS[@]}; do | |
$USE_SUDO pip install $dep | tabecho "pip-$dep" | |
if [ $? -ne 0 ]; then | |
err "error installing $dep" | |
exit 2; | |
fi | |
done | |
# now we can install starcluster | |
cecho 2 "installing starcluster" | |
$USE_SUDO pip install -U starcluster | tabecho "pip-starcluster" | |
if [ $? -ne 0 ]; then | |
err "error installing starcluster" | |
exit 2; | |
fi | |
cecho 2 "validating version and command..." | |
if starcluster --version 2>&1 | grep -q '0.95'; then | |
cecho 2 "- starcluster is at correct version" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice script. Thanks!
There is still a point of potential failure which you may want to cater for (I am a victim myself):
If you have the python-crypto-2.0.1 RPM installed system-wide, and you didn't have gmp-devel installed when you built & installed a later version of PyCrypto, so you'reusing a newer version of PyCrypto with an older version of _fastmath.
To solve it you need to install gmp-devel, uninstall PyCrypto and re-install PyCrypto.