From d04e87da0ad3593ffdbd6029e05f5fc656a86b62 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Fri, 29 Sep 2023 12:16:58 -0400 Subject: [PATCH] Fix upgrade_system for asdf plugins --- .../dot_zshrc.d/executable_upgrade_system.sh | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/chezmoi/dot_zshrc.d/executable_upgrade_system.sh b/chezmoi/dot_zshrc.d/executable_upgrade_system.sh index 2d81553..1ce0e5e 100644 --- a/chezmoi/dot_zshrc.d/executable_upgrade_system.sh +++ b/chezmoi/dot_zshrc.d/executable_upgrade_system.sh @@ -38,31 +38,38 @@ upgrade_system() { esac if command -v asdf &> /dev/null; then - ( - cd "$HOME" - asdf update || true - asdf plugin update --all - asdf latest --all | grep -Ev '^(python|nodejs)' - LATEST_PYTHON_VERSION="$(asdf latest python)" - CURRENT_PYTHON_VERSION="$(asdf current python | awk '{print $2}')" - echo -en "python\t${LATEST_PYTHON_VERSION}\t" - if [[ "$LATEST_PYTHON_VERSION" == "$CURRENT_PYTHON_VERSION" ]]; then - echo "installed" - else - echo "missing" - fi + asdf update || true + asdf plugin update --all + echo -e 'package\tversion\tlatest\tstatus' + awk '{ + package = $1 + if(package == "nodejs") { + next + } + + installed_version = $2 + "asdf latest " package | getline + latest_version = $0 + printf package"\t"installed_version"\t"latest_version"\t" + if(installed_version == latest_version) { + print "up-to-date" + } else { + print "out-of-date" + } + }' "${HOME}/.tool-versions" + if grep -q '^nodejs' "${HOME}/.tool-versions"; then asdf list all nodejs | awk -v lts="$(asdf nodejs resolve lts)" \ - -v current="$(asdf current nodejs | awk '{print $2}')" \ - 'index($0, lts) == 1 {latest=$0} END { - printf "nodejs\t"latest"\t" - if(latest == current) { - print "installed" - } else { - print "missing" - } - }' - ) + -v current="$(asdf current nodejs | awk '{print $2}')" \ + 'index($0, lts) == 1 {latest=$0} END { + printf "nodejs\t"current"\t"latest"\t" + if(latest == current) { + print "up-to-date" + } else { + print "out-of-date" + } + }' + fi fi if command -v fwupdmgr &> /dev/null; then