Permalink
Browse files

simplify rpg-upgrade; allow upgrading all packages with no args

  • Loading branch information...
1 parent 868e6d9 commit 39c939bfd7381ed8b7c144691cf863ba0a5d4c2b @rtomayko committed Mar 19, 2010
Showing with 11 additions and 19 deletions.
  1. +11 −19 rpg-upgrade.sh
View
@@ -2,13 +2,14 @@
set -e
. rpg-sh-setup
-[ "$*" ] || set -- '--help'; ARGV="$@"
-USAGE '${PROGNAME} [-u] <package>...
-Upgrade packages to the latest available version.
+ARGV="$@"
+USAGE '${PROGNAME} [-u] [<package>...]
+Upgrade packages to the latest available version. With no <package>, upgrade
+all outdated packages.
Options
- -u Sync the remote package index to be sure the
- latest version is available.'
+ -u Sync the remote package index to be sure the latest version
+ is available.'
# Update the package index. Force the update right now with the `-u`
# arg; otherwise, maybe update it based on the configured stale time.
@@ -18,17 +19,8 @@ then rpg-sync
else rpg-sync -s
fi
-# Let `rpg-package-index` do the heavy lifting. We get back a list of
-# matching gems and their current versions.
-rpg-package-index -x "$@" |
-while read package vers
-do
- if test "$vers" = "X"
- then warn "$package not installed"
- else
- if rpg-install "$package" ">$vers" 2>&1
- then notice "$package upgraded to ..."
- else notice "$package is up to date at $vers"
- fi
- fi
-done
+# Have `rpg-list` generate a list of all installed package with parseable
+# output. Grab only outdated packages and pass them all to `rpg-install`.
+rpg-list -p "$@" |
+awk '/^o / { print $2, $4 }' |
+xargs rpg-install

0 comments on commit 39c939b

Please sign in to comment.