Skip to content

Commit

Permalink
Update dotfiles to remove Brewfile dependency
Browse files Browse the repository at this point in the history
Homebrew is deprecating Brewfile.
[issue][issue],[pull request][pr]

[issue]: Homebrew/legacy-homebrew#30815
[pr]: Homebrew/legacy-homebrew#30749

Issue: #11
  • Loading branch information
Newton committed Jul 23, 2014
1 parent 0fd5dca commit 873c776
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Typically software you buy comes with some sort of installer, why not your dotfiles? After setting up my dotfiles and installation for years, I decided to take a page from [some](https://github.com/necolas) [other](https://github.com/mathiasbynens) [people's](https://github.com/cowboy) [books](http://dotfiles.github.io) and set up a script that will configure my machine to run [ViM as an IDE](http://blog.sanctum.geek.nz/series/unix-as-ide/). Along the way, I figured how to get all of the necessary [Homebrew](http://braumeister.org) & [Node](https://www.npmjs.org) packages installed as well as some useful [Ruby gems](http://rubygems.org). Feel free to [poke around](https://github.com/chrisopedia/dotfiles/commits/master) the repository, [fork it](https://github.com/chrisopedia/dotfiles/fork) to make it your own, [suggest things](https://github.com/chrisopedia/dotfiles/issues?labels=feature+request) for me to include, [log a bug](https://github.com/chrisopedia/dotfiles/issues/new), or maybe checkout the [features list](#features) to see what's included.

[![Version 1.2.0](http://img.shields.io/badge/version-1.2.0-brightgreen.svg)](https://github.com/chrisopedia/bash/releases/tag/1.2.0) [![Stories in Ready](https://badge.waffle.io/chrisopedia/dotfiles.png?label=Ready)](http://waffle.io/chrisopedia/dotfiles)
[![Version 1.2.2](http://img.shields.io/badge/version-1.2.2-brightgreen.svg)](https://github.com/chrisopedia/bash/releases/tag/1.2.2) [![Stories in Ready](https://badge.waffle.io/chrisopedia/dotfiles.png?label=Ready)](http://waffle.io/chrisopedia/dotfiles)

## Installation

Expand Down
54 changes: 20 additions & 34 deletions bin/dotfiles
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ else
DIR="/usr/local/opt/dotfiles"
fi

BREWFILE="${DIR}/var/Brewfile"
usage="$(basename "$0"): usage: $(basename "$0") [-h|--help] [-v|--version] [--prefix]"

# Test for known flags
Expand Down Expand Up @@ -93,47 +92,34 @@ if type -P 'brew' &> /dev/null; then
# Linking applications to ~/Applications
brew linkapps --local

# Install Homebrew formulae via Brewfile
# Install Homebrew formulae
# here check the hash as well
brews="${DIR}/opt/homebrew"
old_brew="$(cat '${DIR}/var/homebrew')"
new_brew="$(md5 "${brews}" | cut -d ' ' -f 4)"
if [[ $new_brew != $old_brew ]]; then

# remove any Brewfile if there
rm -rf ${BREWFILE}

# update and upgrade all packages
echo "update" >> ${BREWFILE}
echo "upgrade" >> ${BREWFILE}

# store IFS within a temp variable
OIFS=$IFS

# set the separator to a carriage return & a new line break
# read in passed-in file and store as an array
IFS=$'\r\n' formulae=($(cat "${brews}"))
# update and upgrade all packages
brew update
brew upgrade

for index in ${!formulae[*]}
do
# Test whether a Homebrew formula is already installed
if ! brew list '${formulae[$index]}' &> /dev/null; then
# add to brewfile to install
echo "install ${formulae[$index]}" >> ${BREWFILE}
fi
done
# store IFS within a temp variable
OIFS=$IFS

IFS=$OIFS
# set the separator to a carriage return & a new line break
# read in passed-in file and store as an array
IFS=$'\r\n' formulae=($(cat "${brews}"))

echo "cleanup" >> ${BREWFILE}
for index in ${!formulae[*]}
do
# Test whether a Homebrew formula is already installed
if ! brew list '${formulae[$index]}' &> /dev/null; then
brew install '${formulae[$index]}'
fi
done

brew bundle "${BREWFILE}"
IFS=$OIFS

# set up hash file for brew installation
echo $(md5 "${brews}" | cut -d ' ' -f 4) > "${DIR}/var/homebrew"
brew cleanup

[[ $? ]] && _success "Homebrew updated, all formulae upgraded, new formulae installed"
fi
[[ $? ]] && _success "Homebrew updated, all formulae upgraded, new formulae installed"
fi

# Check if node is installed, upgrade
Expand Down Expand Up @@ -190,7 +176,7 @@ fi
if type -P 'ruby' &> /dev/null; then
sudo gem update

# Install Homebrew formulae via Brewfile
# Install Ruby gem
# here check the hash as well
gemfile="${DIR}/opt/gems"
old_gem="$(cat '${DIR}/var/gems')"
Expand Down

0 comments on commit 873c776

Please sign in to comment.