]> arthur.barton.de Git - homebrew-alex.git/blob - cmd/brew-run
brew-run: Update commands for latest Homebrew
[homebrew-alex.git] / cmd / brew-run
1 #!/bin/sh
2 # brew-run -- Update, upgrade, and clean up Hoembrew installation.
3
4 # Include "ax-common.sh":
5 ax_common_sourced=
6 for dir in "$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr; do
7         [ -z "$ax_common_sourced" ] || break
8         ax_common="${dir}/lib/ax/ax-common.sh"
9         # shellcheck source=/usr/local/lib/ax/ax-common.sh
10         [ -r "$ax_common" ] && . "$ax_common"
11 done
12 if [ -z "$ax_common_sourced" ]; then
13         ax_msg() { shift; echo "$@"; }
14         ax_abort() { ax_msg - "$@"; exit 1; }
15 fi
16 unset dir ax_common ax_common_sourced
17
18 ax_msg - "Updating Homebrew installation ..."
19 brew update || ax_abort "Update failed!"
20
21 outdated=$( brew outdated --quiet | wc -l | tr -d '\t ' )
22 if [ $outdated -gt 0 ]; then
23         echo
24         ax_msg - "$outdated formula outdated:"
25         brew outdated --verbose || ax_abort "Failed to list outdated packages!"
26         echo
27
28         brew upgrade --cleanup || ax_abort "Upgrade failed!"
29         echo
30
31         ax_msg - "Linking applications ..."
32         brew linkapps --local || ax_abort "Linking of applications failed!"
33 else
34         ax_msg 0 "Nothing outdated."
35 fi