Improve rakefile provisioner

This commit is contained in:
Henrik Lissner 2014-04-13 11:46:20 -04:00
parent 2883f5bd29
commit 1d6f9707d3
10 changed files with 151 additions and 30 deletions

View file

@ -14,20 +14,20 @@ namespace :homebrew do
end
Homebrew.tap('homebrew/dupes')
# Homebrew.tap('homebrew/python')
Homebrew.tap('phinze/cask')
%w{
apple_gcc42
coreutils
wget
curl
tree
git
cask
brew-cask
the_silver_searcher
tmux
gist
lua
luajit
}.each { |pkg| Homebrew.install pkg }
%w{

View file

@ -3,13 +3,16 @@ require_relative 'lib/output'
desc "Provision the node"
task :init,:node do |t,args|
args.with_defaults(:node => `hostname`.strip)
# TODO: chop of the *.local in osx hostnames
# TODO: chop off the *.local in osx hostnames
path = "#{File.dirname(__FILE__)}/node/#{args.node}.rb"
if File.exists?(path)
echo "Setting up node: #{args.node}"
require_relative "node/#{args.node}"
echo "Done!"
else
echo "#{args.node} node does not exist!"
end
end
task :update => :init

0
rake/lib/pyenv.rb Normal file
View file

46
rake/lib/rbenv.rb Normal file
View file

@ -0,0 +1,46 @@
include Rake::DSL
require_relative 'homebrew'
module Rbenv
BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash}
def self.bootstrap
unless self.is_installed?
BREWS.each { |pkg| Homebrew.install pkg }
sh 'exec $SHELL -l'
end
end
def self.destroy
if self.is_installed?
BREWS.each { |pkg| Homebrew.remove pkg }
# sh "rm -rf #{Homebrew.prefix 'rbenv'}"
end
end
def self.install(version, gems=[])
unless self.is_version_installed?(version)
sh "rbenv install #{version}"
end
sh "RBENV_VERSION=#{version} gem install #{gems.join(' ')}"
end
def self.update(version)
sh "RBENV_VERSION=#{version} gem update"
sh "RBENV_VERSION=#{version} gem clean"
end
def self.is_installed?
Homebrew.is_keg_installed? "rbenv"
end
def self.is_version_installed?(version)
system("rbenv versions | grep -w #{version}")
end
def self.installed_versions
`ls -1 #{Homebrew.prefix 'rbenv'}/versions`.split("\n")
end
end

View file

@ -1,17 +1,19 @@
require_relative 'lib/homebrew'
require_relative '../lib/homebrew'
%w{
osx
homebrew
zsh
vim
gamedev:sfml
gamedev:love2D
gamedev:unity
rbenv
rbenv:v1_9
rbenv:v2_0
rbenv:update
pyenv
}.each { |task| Rake::Task[task].invoke }
Homebrew.tap 'homebrew/python'
Homebrew.install 'pygame'
%w{
evernote
transmit
@ -26,4 +28,6 @@ require_relative 'lib/homebrew'
scrivener
omnigraffle
mindnode-pro
love
unity3d
}.each { |app| Homebrew.install_cask app }

View file

@ -11,10 +11,9 @@ task :osx do
sh 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3'
sh 'defaults write NSGlobalDomain AppleFontSmoothing -int 2'
sh 'defaults write com.apple.dock autohide -bool true'
sh 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true'
sh 'defaults write com.apple.finder ShowStatusBar -bool true'
sh 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
sh 'defaults write com.apple.dock autohide -bool true'
# Disable app quarantine
sh 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
@ -22,7 +21,6 @@ task :osx do
# Disable auto-correct
sh 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
sh 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
# Avoid creating .DS_Store files on network volumes
sh 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
# Disable the warning when changing a file extension
@ -42,6 +40,9 @@ task :osx do
# Use column view
sh 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"'
sh 'defaults write com.apple.finder ShowStatusBar -bool true'
sh 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
sh 'killall Finder'
sh 'killall Dock'
end

View file

@ -0,0 +1,42 @@
require_relative 'lib/output'
require_relative 'lib/homebrew'
require_relative 'lib/pyenv'
task :pyenv => 'pyenv:update'
namespace :pyenv do
# task :install do
# unless Pyenv.is_installed?
# echo "Installing pyenv"
# Pyenv.bootstrap
# end
# end
#
# task :v2 => :install do
# # v = "2.0.0-p451"
# # unless Pyenv.is_version_installed?(v)
# # echo "Building ruby #{v}"
# # Pyenv.install v, GLOBAL_GEMS
# # end
# end
#
# task :v3 => :install do
# # v = "1.9.3-p545"
# # unless Pyenv.is_version_installed?(v)
# # echo "Building ruby #{v}"
# # Pyenv.install v, GLOBAL_GEMS
# # end
# end
#
# task :remove do
# # Pyenv.destroy
# end
task :update => :install do
echoerr "Pyenv rakefile not yet implemented!"
# Pyenv.installed_versions.each { |v| Pyenv.update v }
end
end

View file

@ -1,26 +1,47 @@
require_relative 'lib/homebrew'
require_relative 'lib/rbenv'
task :rbenv do
end
task :rbenv => 'rbenv:update'
namespace :rbenv do
BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash}
GLOBAL_GEMS = %w{bundler pry rspec rake}
task :install do
BREWS.each { |pkg| Homebrew.install pkg }
unless Rbenv.is_installed?
echo "Installing rbenv"
Rbenv.bootstrap
end
end
if Dir.exists?(File.expand_path("~/.rbenv"))
task :v2_0 => :install do
v = "2.0.0-p451"
unless Rbenv.is_version_installed?(v)
echo "Building ruby #{v}"
Rbenv.install v, GLOBAL_GEMS
end
end
task :v1_9 => :install do
v = "1.9.3-p545"
unless Rbenv.is_version_installed?(v)
echo "Building ruby #{v}"
Rbenv.install v, GLOBAL_GEMS
end
end
if Rbenv.is_installed?
task :remove do
BREWS.each { |pkg| Homebrew.remove pkg }
sh "rm -rf ~/.rbenv"
echo "Deleting rbenv"
Rbenv.destroy
end
end
task :update => :install do
Rbenv.installed_versions.each do |v|
echo "Updating ruby #{v}"
Rbenv.update v
end
end

View file

@ -7,22 +7,22 @@ task :vim => 'vim:update'
namespace :vim do
task :install => 'homebrew' do
task :install do
%w{lua luajit}.each { |pkg| Homebrew.install pkg }
%w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') }
github 'hlissner/vim', '~/.vim'
github('hlissner/vim', '~/.vim') unless Dir.exists?(File.expand_path("~/.vim"))
end
task :update => :install do
echo "Updating homebrew..."
Homebrew.update
task :update => 'vim:install' do
echo "Updating vim..."
Homebrew.update *["lua", "luajit", "vim", "macvim"]
end
desc "Remove homebrew cleanly"
desc "Remove vim"
task :remove do
echo "Uninstalling Homebrew"
Homebrew.destroy
%w{vim macvim}.each { |pkg| Homebrew.remove pkg }
end
end

View file

@ -25,4 +25,8 @@ namespace :zsh do
sh 'cd ~/.oh-my-zsh && git pull'
end
task :remove do
sh 'rm -rf ~/.oh-my-zsh' if Dir.exists?(File.expand_path("~/.oh-my-zsh"))
end
end