Fixed bug in update
This commit is contained in:
parent
b775cde688
commit
7f54b3a921
|
@ -59,60 +59,61 @@ update-rust() {
|
||||||
|
|
||||||
# Update rust if installed
|
# Update rust if installed
|
||||||
command -v rustup > /dev/null 2>&1
|
command -v rustup > /dev/null 2>&1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
start_rust_update=`date +%s`
|
start_rust_update=`date +%s`
|
||||||
echo "\033[32;1m=== Updating rustup ===\033[0m"
|
echo "\033[32;1m=== Updating rustup ===\033[0m"
|
||||||
rustup self update
|
rustup self update
|
||||||
|
|
||||||
echo "\033[32;1m=== Updating rust ===\033[0m"
|
echo "\033[32;1m=== Updating rust ===\033[0m"
|
||||||
rustup update
|
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
|
if [ $? -ne 0 ]; then
|
||||||
|
|
||||||
pkg-config --libs --cflags openssl > /dev/null 2>&1
|
# Ask for sudo right now
|
||||||
|
sudoresult=$(sudo -nv 2>&1)
|
||||||
# We need to install openssl
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
|
|
||||||
# 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
|
if [ $? -eq 0 ]; then
|
||||||
command -v apt > /dev/null 2>&1
|
sudo apt install -y libssl-dev
|
||||||
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
|
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
echo "\033[32;1m=== Installing rust packages updater ===\033[0m"
|
|
||||||
cargo install cargo-update
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "\033[32;1m=== Updating rust packages ===\033[0m"
|
echo "\033[32;1m=== Installing rust packages updater ===\033[0m"
|
||||||
cargo install-update -ag
|
cargo install cargo-update
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "\033[32;1m=== Updating rust packages ===\033[0m"
|
||||||
|
cargo install-update -ag
|
||||||
|
|
||||||
seconds=$((`date +%s` - $start_rust_update ))
|
seconds=$((`date +%s` - $start_rust_update ))
|
||||||
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
|
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
|
||||||
echo "\033[32;1m=== Rust updated in $formatted ===\033[0m"
|
echo "\033[32;1m=== Rust updated in $formatted ===\033[0m"
|
||||||
|
|
Loading…
Reference in New Issue