diff --git a/bin/update b/bin/update index 6628a97..6f1a987 100755 --- a/bin/update +++ b/bin/update @@ -244,21 +244,31 @@ update-rust() { echo -e "\033[32;1m=== Updating rust ===\033[0m" rustup update - cargo install-update --help > /dev/null 2>&1 - - # Program to update cargo programs is not installed - if [ $? -ne 0 ]; then - - echo -e "\033[33;1m=== To allow updating rust packages, run \`cargo install cargo-update\`===\033[0m" - - fi - - # If the user has no root, and if he doesn't have openssl, we won't install cargo update. - # Before running cargo update, we check again that it is installed. - cargo install-update --help > /dev/null 2>&1 if [ $? -eq 0 ]; then echo -e "\033[32;1m=== Updating rust packages ===\033[0m" - cargo install-update -ag + + IFS=$'\n' + for line in $(cargo install --list); do + if [[ $line == " "* ]] || [[ $line == "\t"* ]]; then + continue + fi + + if [[ $line == *"("* ]]; then + crate=$(echo $line | cut -d ' ' -f 1) + full_repo=$(echo $line | cut -d '(' -f 2 | cut -d ')' -f 1) + repo=$(echo $full_repo | cut -d '#' -f 1) + current_commit=$(echo $full_repo | cut -d '#' -f 2) + latest_commit=$(git ls-remote $repo | head -n 1 | cut -d $'\t' -f 1) + + if [[ $latest_commit == ${current_commit}* ]]; then + echo -e " \x1b[32;1mIgnored\x1b[0m package \`$crate\` is already installed" + else + cargo install --git $repo + fi + else + cargo install $(echo $line | cut -d ' ' -f 1) + fi + done fi local seconds=$((`date +%s` - $start))