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 end
Homebrew.tap('homebrew/dupes') Homebrew.tap('homebrew/dupes')
# Homebrew.tap('homebrew/python')
Homebrew.tap('phinze/cask') Homebrew.tap('phinze/cask')
%w{ %w{
apple_gcc42
coreutils coreutils
wget wget
curl curl
tree tree
git git
cask brew-cask
the_silver_searcher the_silver_searcher
tmux tmux
gist gist
lua
luajit
}.each { |pkg| Homebrew.install pkg } }.each { |pkg| Homebrew.install pkg }
%w{ %w{

View file

@ -3,13 +3,16 @@ require_relative 'lib/output'
desc "Provision the node" desc "Provision the node"
task :init,:node do |t,args| task :init,:node do |t,args|
args.with_defaults(:node => `hostname`.strip) 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" path = "#{File.dirname(__FILE__)}/node/#{args.node}.rb"
if File.exists?(path) if File.exists?(path)
echo "Setting up node: #{args.node}" echo "Setting up node: #{args.node}"
require_relative "node/#{args.node}" require_relative "node/#{args.node}"
echo "Done!"
else else
echo "#{args.node} node does not exist!" echo "#{args.node} node does not exist!"
end end
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{ %w{
osx osx
homebrew homebrew
zsh zsh
vim vim
gamedev:sfml rbenv:v1_9
gamedev:love2D rbenv:v2_0
gamedev:unity rbenv:update
rbenv
pyenv pyenv
}.each { |task| Rake::Task[task].invoke } }.each { |task| Rake::Task[task].invoke }
Homebrew.tap 'homebrew/python'
Homebrew.install 'pygame'
%w{ %w{
evernote evernote
transmit transmit
@ -26,4 +28,6 @@ require_relative 'lib/homebrew'
scrivener scrivener
omnigraffle omnigraffle
mindnode-pro mindnode-pro
love
unity3d
}.each { |app| Homebrew.install_cask app } }.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 AppleKeyboardUIMode -int 3'
sh 'defaults write NSGlobalDomain AppleFontSmoothing -int 2' 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 NSGlobalDomain AppleShowAllExtensions -bool true'
sh 'defaults write com.apple.finder ShowStatusBar -bool true'
sh 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true' sh 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
sh 'defaults write com.apple.dock autohide -bool true'
# Disable app quarantine # Disable app quarantine
sh 'defaults write com.apple.LaunchServices LSQuarantine -bool false' sh 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
@ -22,7 +21,6 @@ task :osx do
# Disable auto-correct # Disable auto-correct
sh 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false' sh 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
sh 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
# Avoid creating .DS_Store files on network volumes # Avoid creating .DS_Store files on network volumes
sh 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true' sh 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
# Disable the warning when changing a file extension # Disable the warning when changing a file extension
@ -42,6 +40,9 @@ task :osx do
# Use column view # Use column view
sh 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"' 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 Finder'
sh 'killall Dock' sh 'killall Dock'
end 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/homebrew'
require_relative 'lib/rbenv'
task :rbenv do task :rbenv => 'rbenv:update'
end
namespace :rbenv do 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 task :install do
BREWS.each { |pkg| Homebrew.install pkg } unless Rbenv.is_installed?
echo "Installing rbenv"
Rbenv.bootstrap
end
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 task :remove do
BREWS.each { |pkg| Homebrew.remove pkg } echo "Deleting rbenv"
sh "rm -rf ~/.rbenv" Rbenv.destroy
end
end end
task :update => :install do task :update => :install do
Rbenv.installed_versions.each do |v|
echo "Updating ruby #{v}"
Rbenv.update v
end end
end end

View file

@ -7,22 +7,22 @@ task :vim => 'vim:update'
namespace :vim do namespace :vim do
task :install => 'homebrew' do task :install do
%w{lua luajit}.each { |pkg| Homebrew.install pkg } %w{lua luajit}.each { |pkg| Homebrew.install pkg }
%w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') } %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 end
task :update => :install do task :update => 'vim:install' do
echo "Updating homebrew..." echo "Updating vim..."
Homebrew.update Homebrew.update *["lua", "luajit", "vim", "macvim"]
end end
desc "Remove homebrew cleanly" desc "Remove vim"
task :remove do task :remove do
echo "Uninstalling Homebrew" echo "Uninstalling Homebrew"
Homebrew.destroy %w{vim macvim}.each { |pkg| Homebrew.remove pkg }
end end
end end

View file

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