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