-
Notifications
You must be signed in to change notification settings - Fork 0
/
brew.sh
executable file
·48 lines (43 loc) · 1.62 KB
/
brew.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
. ./utils.sh || exit 1
# install xcode command line tools
printf "Checking for xcode command line tools\n"
xcode-select --install >/dev/null 2>&1
until xcode-select --print-path >/dev/null 2>&1; do # wait until xcode clts are installed
sleep 5
done
# install homebrew
homebrew_url="https://raw.githubusercontent.com/Homebrew/install/master/install"
if _test_executable "brew" 2>/dev/null; then
printf "Homebrew is already installed\n"
printf "Checking for updates\n"
brew update
printf "List installed packages\n"
brew list
printf "List outdated packages\n"
brew outdated
printf "Upgrading outdated packages\n"
brew upgrade
else
printf "Homebrew is not installed\n"
printf "Installing homebrew\n"
/usr/bin/ruby -e "$(curl -fsSL $homebrew_url)" || exit 1
fi
# install homebrew formulae
formulas="$(_get_fullname "$1")" || exit 1
printf "Installing homebrew formulas from file %s\n" "$formulas"
_parse_text_file "$formulas" |
while read -r formula options; do
_test_program_folder "$formula" "formula" "$(brew --prefix)/Cellar" || continue
brew_cmd="brew install $options --ignore-dependencies $formula"
if ! eval "$brew_cmd"; then
# some 'brew install' with python3 option will break if the '-ignore-dependencies' option is enabled
# moreover, tcpdump and lftp install for instance break with the '-ignore-dependencies' option, although without any other option
brew_cmd="brew install $options $formula"
printf "So trying to install formula %s again, this time without the '--ignore-dependencies' option\n" "$formula"
eval "$brew_cmd"
fi;
printf "\n"
done;
printf "Cleaning up homebrew\n"
brew cleanup --prune=all -s