Fixed bug in update

This commit is contained in:
Thomas Forgione 2019-01-09 11:02:32 +01:00
parent b775cde688
commit 7f54b3a921
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 39 additions and 38 deletions

View File

@ -59,60 +59,61 @@ update-rust() {
# Update rust if installed
command -v rustup > /dev/null 2>&1
if [ $? -eq 0 ]; then
if [ $? -ne 0 ]; then
return
fi
start_rust_update=`date +%s`
echo "\033[32;1m=== Updating rustup ===\033[0m"
rustup self update
start_rust_update=`date +%s`
echo "\033[32;1m=== Updating rustup ===\033[0m"
rustup self update
echo "\033[32;1m=== Updating rust ===\033[0m"
rustup update
echo "\033[32;1m=== Updating rust ===\033[0m"
rustup update
cargo install-update --help > /dev/null 2>&1
cargo install-update --help > /dev/null 2>&1
if [ $? -ne 0 ]; then
pkg-config --libs --cflags openssl > /dev/null 2>&1
# We need to install openssl
if [ $? -ne 0 ]; then
pkg-config --libs --cflags openssl > /dev/null 2>&1
# We need to install openssl
if [ $? -ne 0 ]; then
# Ask for sudo right now
sudoresult=$(sudo -nv 2>&1)
# Ask for sudo right now
sudoresult=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then
command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo apt install -y libssl-dev
fi
# For fedora
command -v dnf > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo dnf install openssl-devel
fi
elif echo $sudoresult | grep -q '^sudo:'; then
echo "\033[32;1m=== libssl-dev is needed to update rust packages, please enter your password ===\033[0m"
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
else
echo "\033[33;1m=== You are not a sudoer, cannot install cargo-update... ===\033[0m"
return 1
sudo apt install -y libssl-dev
fi
# For fedora
command -v dnf > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo dnf install openssl-devel
fi
elif echo $sudoresult | grep -q '^sudo:'; then
echo "\033[32;1m=== libssl-dev is needed to update rust packages, please enter your password ===\033[0m"
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
else
echo "\033[33;1m=== You are not a sudoer, cannot install cargo-update... ===\033[0m"
return 1
fi
echo "\033[32;1m=== Installing rust packages updater ===\033[0m"
cargo install cargo-update
fi
echo "\033[32;1m=== Updating rust packages ===\033[0m"
cargo install-update -ag
echo "\033[32;1m=== Installing rust packages updater ===\033[0m"
cargo install cargo-update
fi
echo "\033[32;1m=== Updating rust packages ===\033[0m"
cargo install-update -ag
seconds=$((`date +%s` - $start_rust_update ))
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo "\033[32;1m=== Rust updated in $formatted ===\033[0m"