Permalink
Browse files

Parcel out homebrew install in /usr/local, add Vagrantfile for testing.

  • Loading branch information...
mitchty committed Dec 16, 2014
1 parent 3a37c2c commit 663ad456e0ad7c77614fb7f48550d9b75e091808
Showing with 576 additions and 26 deletions.
  1. +3 −2 Vagrantfile
  2. +22 −24 bootstrap.sh
  3. +71 −0 cabal.yml
  4. +254 −0 osx-homebrew.yml
  5. +12 −0 osx-root.yml
  6. +214 −0 osx-user.yml
View
@@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# For now, test on yosemite+mavericks, sort out linux/bsd later
config.vm.define "yosemite" do |yosemite|
config.vm.define "yosemite", primary: true do |yosemite|
yosemite.vm.box = "yosemite"
yosemite.vm.provider "vmware_fusion" do |v|
v.gui = true
@@ -27,5 +27,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# provision via ansible from there on out
config.vm.provision "shell",
privileged: false,
inline: "cd /vagrant && cat bootstrap.sh | sh -x"
keep_color: true,
inline: "/vagrant/bootstrap.sh"
end
View
@@ -4,7 +4,8 @@
# Cause... setting shit up should be easy. And I'm lazy.
#
local_files=${local_files:=yes}
brew_home=/usr/local
osx_release=$(sw_vers -productVersion | sed -e 's/\.[0-9]\{1\}//2')
brew_home=/usr/local/brew/${osx_release}
iam_user=$(id -u -nr)
iam_group=$(id -g -nr)
brew_bin=${brew_home}/bin
@@ -14,6 +15,18 @@ ansible_verbose=${ansible_verbose:=""}
[ -d "/vagrant" ] && sut=true
sut_guard()
{
# Let local testing in /vagrant work.
if [ ${sut} = "true" ]; then
cd /vagrant
else
cd "${base_home}"
fi
}
export PATH=${brew_bin}:${PATH}
homebrew_setup()
{
# Find out when crap breaks faster...ish
@@ -40,25 +53,15 @@ homebrew_setup()
if [ ! -e "${instfile}" ]; then
echo "Install homebrew for the first time"
trap 'rm -fr "${instfile}"; exit' INT TERM EXIT
curl -fsSL -o "${instfile}" ${brew_url}
chmod 755 "${instfile}"
"${instfile}" --fast
rm -f "${instfile}"
git clone "https://github.com/Homebrew/homebrew" ${brew_home}
trap - INT TERM EXIT
else
echo "lock file found ${instfile}"
else
echo "lock file found ${instfile}"
exit 2
fi
rm -f "${instfile}"
fi
# Use bottles when possible?
if [ ! -z "${FASTER}" ]; then
echo Building from source
sleep 3
export HOMEBREW_BUILD_FROM_SOURCE=yesplease
fi
export PATH=${brew_bin}:${PATH}
for prep in git ansible; do
@@ -73,13 +76,6 @@ homebrew_setup()
# still a work in progress to be honest.
ansible()
{
# Let local testing in /vagrant work.
if [ ${sut} = "true" ]; then
cd /vagrant
else
cd "${base_home}"
fi
# Allow this sudo to fail if we get prompted or aren't setup
set +e
cmd="ansible-playbook ${ansible_verbose} --inventory-file inventory --sudo bootstrap.yml"
@@ -94,9 +90,9 @@ ansible()
${cmd}
fi
# for playbook in osx-user osx-homebrew; do
# ansible_play ${playbook}
# done
for playbook in osx-user osx-homebrew cabal; do
ansible_play ${playbook}
done
}
ansible_play()
@@ -107,6 +103,8 @@ ansible_play()
${cmd}
}
sut_guard
case $1 in
ansible)
if [ "$2" != "" ]; then
View
@@ -0,0 +1,71 @@
---
#
# Setup cabal
#
- hosts: localhost
tasks:
- name: Download haskell platform
get_url: url='https://www.haskell.org/platform/download/2014.2.0.0/Haskell%20Platform%202014.2.0.0%2064bit.signed.pkg'
dest=/tmp/haskell_platform.pkg
timeout=300
- name: Install haskell platform
command: sudo installer -target / -pkg /tmp/haskell_platform.pkg
ignore_errors: True
# NOTE: ^^^^ have to ignore because of
# https://github.com/haskell/haskell-platform/issues/151
- name: Remove tmp file
command: rm /tmp/haskell_platform.pkg
ignore_errors: True
- name: ~/.cabal/bin
file: state=directory path=~/.cabal/bin
- name: ~/Library/Haskell
file: state=directory path=~/Library/Haskell
when: "ansible_os_family == 'Darwin'"
- name: ~/Library/Haskell/bin -> ~/.cabal/bin
file: state=link force=yes src=~/.cabal/bin path=~/Library/Haskell/bin
when: "ansible_os_family == 'Darwin'"
- name: cabal update
command: cabal update
- name: cabal install cabal cabal-install
command: cabal install -v cabal cabal-install
- name: install binaries with cabal sandboxes
environment:
PATH: ~/.cabal/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
TMPDIR: /tmp
shell: >-
temp=$(mktemp -d -t "cabalsandbox-{{item}}");
cd ${temp} &&
cabal sandbox init &&
cabal install -v "{{item}}" &&
cp .cabal-sandbox/bin/* ~/.cabal/bin &&
cd / &&
rm -fr ${temp}
with_items:
- pandoc
- shellcheck
- shake
- bake
- happy
- alex
- c2hs
- hi
- hlint
- hspec
- cgrep
- stylish-haskell
- hasktags
- hoogle
- cabal-meta
- ghc-mod
- hindent
- name: Hoogle update
command: ~/.cabal/bin/hoogle data
Oops, something went wrong.

0 comments on commit 663ad45

Please sign in to comment.