Skip to content

Commit

Permalink
setup-mac-brew: close #267
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Jan 29, 2025
1 parent cf68611 commit 9ea2a9f
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions commands/setup-mac-brew
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@ function setup_mac_brew() (

# update brew
function update_brew {
brew upgrade --quiet
local brew_upgrade_status=0
brew upgrade --quiet || brew_upgrade_status=$?
if [[ $brew_upgrade_status -ne 0 ]]; then
if ! confirm --positive --ppid=$$ --linger -- 'Would you like to proceed?' "The homebrew upgrade reported a failure exit status of $brew_upgrade_status, however unless there is actually an error above that requires attention then you can proceed safely, as homebrew reports failure exit statuses when there are merely recommendations, and such recommendations are typically already handled by Dorothy."; then
return "$brew_upgrade_status"
fi
fi
return 0
}

# install encoding tools
Expand All @@ -261,8 +268,8 @@ function setup_mac_brew() (

# if yes, then install the linting tools
if [[ $HOMEBREW_ENCODING_INSTALL == 'yes' ]]; then
echo-style --h1="Homebrew encoding tools"
echo-style --notice="This can take a while... ⏲"
echo-style --h1='Homebrew encoding tools'
echo-style --notice='This can take a while... ⏲'

# install dependencies:
# https://github.com/varenc/homebrew-ffmpeg/issues/28
Expand All @@ -282,7 +289,7 @@ function setup_mac_brew() (
uninstall_encoding

# log
echo-style --h2="Install ffmpeg with options"
echo-style --h2='Install ffmpeg with options'

# fetch all the build options for ffmpeg
local ffmpeg_opts bad_option
Expand Down Expand Up @@ -362,7 +369,7 @@ function setup_mac_brew() (
# otherwise we are on a custom directory, can't use bottles, so have to compile ourselves, which takes forever
if confirm --linger --bool --ppid=$$ -- "Do you want to install [$*]?" 'These can take hours, so best left overnight...'; then
echo-style --h2="Install $# slow formulas"
echo-style --notice="This can take a while... ⏲"
echo-style --notice='This can take a while... ⏲'
brew_install --formula -- "$@"
echo-style --g2="Install $# slow formulas"
fi
Expand All @@ -386,7 +393,7 @@ function setup_mac_brew() (
elif [[ $# -gt 1 ]]; then
fodder="$(
choose --multi \
--question="Which casks would you like to brew install?" \
--question='Which casks would you like to brew install?' \
-- "$@"
)"
mapfile -t cask_selection <<<"$fodder" # <( destroys stdin
Expand Down Expand Up @@ -510,9 +517,9 @@ function setup_mac_brew() (
brew_repo "${repos[@]}"

# update
echo-style --h2="Update Homebrew"
echo-style --h2='Update Homebrew'
brew update --quiet
echo-style --g2="Update Homebrew"
echo-style --g2='Update Homebrew'

# uninstall packages
brew_uninstall "${HOMEBREW_UNINSTALL[@]}"
Expand All @@ -528,16 +535,15 @@ function setup_mac_brew() (
uninstall_encoding

# update packages
echo-style --h2="Upgrade Homebrew"
echo-style --dim='Brew upgrades can fail sporadically due to changes in the environment (such as when the environment depended on a now upgraded package, in which the environment must be reloaded to make use of the upgraded package). If it fails, open a new terminal and try again which will continue this incremental upgrade process.'
echo-style --h2='Upgrade Homebrew'
update_brew
echo-style --g2="Upgrade Homebrew"
echo-style --g2='Upgrade Homebrew'

# dependencies
echo-style --h2="Install build dependencies"
echo-style --h2='Install build dependencies'
eval_helper --quiet \
-- setup-util-devel
echo-style --g2="Install build dependencies"
echo-style --g2='Install build dependencies'

# install encoding tools
install_encoding
Expand Down

0 comments on commit 9ea2a9f

Please sign in to comment.