]> arthur.barton.de Git - homebrew-alex.git/blob - cmd/brew-run
e304efd90d4410ff69b57822c213dd8d2f24e5d9
[homebrew-alex.git] / cmd / brew-run
1 #!/bin/sh
2 # 2016-08-06, alex@barton.de
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 echo
21
22 outdated=$( brew outdated --quiet | wc -l | tr -d '\t ' )
23 if [ $outdated -gt 0 ]; then
24         ax_msg - "$outdated formula outdated:"
25         brew outdated || ax_abort "Failed to list outdated packages!"
26         echo
27         brew upgrade --all || ax_abort "Upgrade failed!"
28         brew linkapps --local || ax_abort "Linking of applications failed!"
29
30         echo
31         brew cleanup || ax_abort "\"brew cleanup\" failed!"
32         brew prune || ax_abort "\"brew prune\" failed!"
33 else
34         ax_msg - "Nothing outdated."
35 fi