Skip to content

Commit

Permalink
Make mac script run idempotently
Browse files Browse the repository at this point in the history
Use preferred POSIX `command -v` test for command existence instead of
previous `which` technique. `which` exits with status `1` if nothing is
found. That would cause the script to abort because we use `set -e`.

http://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script

Remove GCC dependency in mac script

GCC is no longer necessary to compile Ruby. It was fixed in Ruby about
two years ago. LLVM has been supported since 1.9.3-p125.

https://bugs.ruby-lang.org/issues/5076
http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues
  • Loading branch information
Dan Croak committed Apr 14, 2014
1 parent e8ad3a3 commit f0acd78
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
18 changes: 8 additions & 10 deletions mac
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if [[ -f /etc/zshenv ]]; then
fi
### end mac-components/zsh-fix

if ! which brew &>/dev/null; then
if ! command -v brew &>/dev/null; then
fancy_echo "Installing Homebrew, a good OS X package manager ..."
ruby <(curl -fsS https://raw.github.com/Homebrew/homebrew/go/install)

Expand Down Expand Up @@ -115,16 +115,10 @@ fancy_echo "Installing ruby-build, to install Rubies ..."
brew install ruby-build
### end mac-components/rbenv

fancy_echo "Installing GNU Compiler Collection, a necessary prerequisite to installing Ruby ..."
brew tap homebrew/dupes
brew install apple-gcc42

fancy_echo "Upgrading and linking OpenSSL ..."
brew install openssl
brew link openssl --force
brew install curl-ca-bundle

export CC=gcc-4.2
### end mac-components/compiler-and-libraries

ruby_version="$(curl -sSL http://ruby.thoughtbot.com/latest)"
Expand Down Expand Up @@ -163,9 +157,13 @@ fancy_echo "Installing GitHub CLI client ..."
brew install hub
### end mac-components/github

fancy_echo "Installing rcm, to manage your dotfiles ..."
brew tap thoughtbot/formulae
brew install rcm
if ! command -v rcup &>/dev/null; then
fancy_echo "Installing rcm, to manage your dotfiles ..."
brew tap thoughtbot/formulae
brew install rcm
else
fancy_echo "rcm already installed. Skipping ..."
fi
### end mac-components/rcm

fancy_echo "Installing your personal additions from ~/.laptop.local ..."
Expand Down
6 changes: 0 additions & 6 deletions mac-components/compiler-and-libraries
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
fancy_echo "Installing GNU Compiler Collection, a necessary prerequisite to installing Ruby ..."
brew tap homebrew/dupes
brew install apple-gcc42

fancy_echo "Upgrading and linking OpenSSL ..."
brew install openssl
brew link openssl --force
brew install curl-ca-bundle

export CC=gcc-4.2
2 changes: 1 addition & 1 deletion mac-components/homebrew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ! which brew &>/dev/null; then
if ! command -v brew &>/dev/null; then
fancy_echo "Installing Homebrew, a good OS X package manager ..."
ruby <(curl -fsS https://raw.github.com/Homebrew/homebrew/go/install)

Expand Down
10 changes: 7 additions & 3 deletions mac-components/rcm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
fancy_echo "Installing rcm, to manage your dotfiles ..."
brew tap thoughtbot/formulae
brew install rcm
if ! command -v rcup &>/dev/null; then
fancy_echo "Installing rcm, to manage your dotfiles ..."
brew tap thoughtbot/formulae
brew install rcm
else
fancy_echo "rcm already installed. Skipping ..."
fi

0 comments on commit f0acd78

Please sign in to comment.