]> arthur.barton.de Git - homebrew-alex.git/blob - cmd/brew-run
755907bb1f4e6a3b2c40b9121be8d11aed77e831
[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 --verbose | grep -F -cv "pinned at" )
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 --ignore-pinned --cleanup || ax_abort "Upgrade failed!"
29         echo
30
31         ax_msg - "Cleaning up ..."
32         brew cleanup --prune=2 || ax_abort "\"brew cleanup\" failed!"
33         brew prune || ax_abort "\"brew prune\" failed!"
34         echo
35 else
36         ax_msg 0 "Nothing outdated."
37         echo
38 fi