From d304364e81a853a595eacb14c46af991ea3bdbcf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 17 Jul 2014 08:11:18 -0400 Subject: [PATCH] Rewrote/restructured provisioner rakefiles --- rake/init.rake | 19 ---------------- rake/lib/deploy.rb | 24 +++++++++++++++++++++ rake/lib/fileutils.rb | 2 -- rake/lib/homebrew.rb | 4 ++++ rake/lib/rake.rb | 4 ++++ rake/node/callisto.rake | 13 +++++++++++ rake/node/callisto.rb | 8 ------- rake/node/ganymede.rake | 3 +++ rake/node/ganymede.rb | 1 - rake/node/io.rake | 30 ++++++++++++++++++++++++++ rake/node/io.rb | 26 ---------------------- rake/node/test.rb | 1 - rake/node/titan.rake | 3 +++ rake/node/titan.rb | 0 rake/pkg.rake | 5 +++++ rake/pkg/emacs.rake | 26 ++++++++++++++++++++++ rake/{ => pkg}/homebrew.rake | 13 +++++------ rake/{ => pkg}/osx.rake | 3 +-- rake/{ => pkg}/rbenv.rake | 17 ++++++++++++--- rake/pkg/vim.rake | 39 +++++++++++++++++++++++++++++++++ rake/{ => pkg}/zsh.rake | 4 ++-- rake/pyenv.rake | 42 ------------------------------------ rake/setup.rake | 16 ++++++++++++++ rake/vim.rake | 40 ---------------------------------- 24 files changed, 189 insertions(+), 154 deletions(-) delete mode 100644 rake/init.rake create mode 100644 rake/lib/deploy.rb delete mode 100644 rake/lib/fileutils.rb create mode 100644 rake/lib/rake.rb create mode 100644 rake/node/callisto.rake delete mode 100644 rake/node/callisto.rb create mode 100644 rake/node/ganymede.rake delete mode 100644 rake/node/ganymede.rb create mode 100644 rake/node/io.rake delete mode 100644 rake/node/io.rb delete mode 100644 rake/node/test.rb create mode 100644 rake/node/titan.rake delete mode 100644 rake/node/titan.rb create mode 100644 rake/pkg.rake create mode 100644 rake/pkg/emacs.rake rename rake/{ => pkg}/homebrew.rake (86%) rename rake/{ => pkg}/osx.rake (98%) rename rake/{ => pkg}/rbenv.rake (81%) create mode 100644 rake/pkg/vim.rake rename rake/{ => pkg}/zsh.rake (92%) delete mode 100644 rake/pyenv.rake create mode 100644 rake/setup.rake delete mode 100644 rake/vim.rake diff --git a/rake/init.rake b/rake/init.rake deleted file mode 100644 index cd5432b0..00000000 --- a/rake/init.rake +++ /dev/null @@ -1,19 +0,0 @@ -require_relative 'lib/output' - -desc "Provision the node" -task :init,:node do |t,args| - args.with_defaults(:node => `hostname`.gsub('.local', '').strip) - # 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 - -desc "Update the node" -task :default => :init diff --git a/rake/lib/deploy.rb b/rake/lib/deploy.rb new file mode 100644 index 00000000..796ab1ee --- /dev/null +++ b/rake/lib/deploy.rb @@ -0,0 +1,24 @@ + +module Project + + def create(dirs=[]) + + end + + def template(template, vars={}, dest="") + + end + + def update(name) + + end + + def remove(name) + + end + + class Template + + end + +end diff --git a/rake/lib/fileutils.rb b/rake/lib/fileutils.rb deleted file mode 100644 index 139597f9..00000000 --- a/rake/lib/fileutils.rb +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/rake/lib/homebrew.rb b/rake/lib/homebrew.rb index 9ee15c0d..2068c8bf 100644 --- a/rake/lib/homebrew.rb +++ b/rake/lib/homebrew.rb @@ -40,6 +40,10 @@ module Homebrew sh_safe "#{BIN} remove #{keg}" end + def self.remove_cask(keg) + sh_safe "#{BIN} cask uninstall #{keg}" + end + def self.has_keg?(keg) system("#{BIN} search #{keg}") end diff --git a/rake/lib/rake.rb b/rake/lib/rake.rb new file mode 100644 index 00000000..1ff7519a --- /dev/null +++ b/rake/lib/rake.rb @@ -0,0 +1,4 @@ + +def load_all(glob) + Dir.glob("#{File.dirname(__FILE__)}/../#{glob}") { |file| load file } +end diff --git a/rake/node/callisto.rake b/rake/node/callisto.rake new file mode 100644 index 00000000..6360bdf8 --- /dev/null +++ b/rake/node/callisto.rake @@ -0,0 +1,13 @@ + +desc "Provision home server" +task :callisto do + %w{ + osx + homebrew + zsh + vim + nginx + mongodb + gitlab + }.each { |task| Rake::Task[task].invoke } +end diff --git a/rake/node/callisto.rb b/rake/node/callisto.rb deleted file mode 100644 index f3ebdab8..00000000 --- a/rake/node/callisto.rb +++ /dev/null @@ -1,8 +0,0 @@ -%w{ - osx - homebrew - zsh - vim - rbenv - mongodb -}.each { |task| Rake::Task[task].invoke } diff --git a/rake/node/ganymede.rake b/rake/node/ganymede.rake new file mode 100644 index 00000000..531279c9 --- /dev/null +++ b/rake/node/ganymede.rake @@ -0,0 +1,3 @@ + +desc "Provision main laptop" +task :ganymede => :io diff --git a/rake/node/ganymede.rb b/rake/node/ganymede.rb deleted file mode 100644 index cab1e953..00000000 --- a/rake/node/ganymede.rb +++ /dev/null @@ -1 +0,0 @@ -require_relative "io" diff --git a/rake/node/io.rake b/rake/node/io.rake new file mode 100644 index 00000000..ad2130f7 --- /dev/null +++ b/rake/node/io.rake @@ -0,0 +1,30 @@ +require_relative '../lib/homebrew' + +desc "Provision main desktop" +task :io do + %w{ + pkg:osx + pkg:homebrew + pkg:zsh + pkg:vim + pkg:emacs + pkg:rbenv:v1_9 + pkg:rbenv:v2_0 + pkg:rbenv:update + }.each { |task| Rake::Task[task].invoke } + + %w{ + transmit + transmission + vlc + flux + skype + adium + codekit + mongohub + sequel-pro + scrivener + omnigraffle + love + }.each { |app| Homebrew.install_cask app } +end diff --git a/rake/node/io.rb b/rake/node/io.rb deleted file mode 100644 index 52af0a7c..00000000 --- a/rake/node/io.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../lib/homebrew' - -%w{ - osx - homebrew - zsh - vim - rbenv:v1_9 - rbenv:v2_0 - rbenv:update -}.each { |task| Rake::Task[task].invoke } - -%w{ - transmit - transmission - vlc - flux - skype - adium - codekit - mongohub - sequel-pro - scrivener - omnigraffle - love -}.each { |app| Homebrew.install_cask app } diff --git a/rake/node/test.rb b/rake/node/test.rb deleted file mode 100644 index cab1e953..00000000 --- a/rake/node/test.rb +++ /dev/null @@ -1 +0,0 @@ -require_relative "io" diff --git a/rake/node/titan.rake b/rake/node/titan.rake new file mode 100644 index 00000000..69cda0eb --- /dev/null +++ b/rake/node/titan.rake @@ -0,0 +1,3 @@ + +desc "Provision 2nd desktop" +task :titan => :io diff --git a/rake/node/titan.rb b/rake/node/titan.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/rake/pkg.rake b/rake/pkg.rake new file mode 100644 index 00000000..ff429129 --- /dev/null +++ b/rake/pkg.rake @@ -0,0 +1,5 @@ +require_relative "lib/rake" + +verbose(false) + +namespace :pkg do load_all("pkg/*.rake") end diff --git a/rake/pkg/emacs.rake b/rake/pkg/emacs.rake new file mode 100644 index 00000000..b4f03458 --- /dev/null +++ b/rake/pkg/emacs.rake @@ -0,0 +1,26 @@ +desc "Ensure emacs is installed and up to date" +task :emacs => "emacs:update" + +namespace :emacs do + + task :install do + Homebrew.install("emacs", "--with-gnutls --cocoa --keep-ctags --srgb") + Homebrew.install "aspell" + github('hlissner/emacs.d', '~/.emacs.d') + end + + task :update do + echo "Updating emacs.d" + sh_safe "cd ~/.emacs.d && git pull" + + echo "You'll have to update emacs manually!" + end + + task :remove do + echo "Uninstalling emacs" + Homebrew.remove "emacs" + Homebrew.remove "aspell" + rm_rf "~/.emacs.d" if Dir.exists? "~/.emacs.d" + end + +end diff --git a/rake/homebrew.rake b/rake/pkg/homebrew.rake similarity index 86% rename from rake/homebrew.rake rename to rake/pkg/homebrew.rake index c216184a..62110e37 100644 --- a/rake/homebrew.rake +++ b/rake/pkg/homebrew.rake @@ -1,13 +1,10 @@ +require_relative "../lib/output" +require_relative "../lib/homebrew" +require_relative "../lib/sh" -require_relative "lib/output" -require_relative "lib/homebrew" -require_relative "lib/sh" - -desc "Ensure homebrew is installed and up to date" +desc 'Install/update homebrew' task :homebrew => 'homebrew:update' -verbose(false) - namespace :homebrew do task :install do @@ -49,6 +46,7 @@ namespace :homebrew do echo "Homebrew is installed. Moving on." end + desc "Update homebrew and upgrade brews" task :update => "homebrew:install" do echo "Updating homebrew..." Homebrew.update @@ -60,4 +58,3 @@ namespace :homebrew do end end - diff --git a/rake/osx.rake b/rake/pkg/osx.rake similarity index 98% rename from rake/osx.rake rename to rake/pkg/osx.rake index 485f506c..52e11eca 100644 --- a/rake/osx.rake +++ b/rake/pkg/osx.rake @@ -1,5 +1,4 @@ - -require_relative 'lib/output' +require_relative '../lib/output' task :osx do if system('defaults read com.apple.finder _FXShowPosixPathInTitle >&/dev/null') diff --git a/rake/rbenv.rake b/rake/pkg/rbenv.rake similarity index 81% rename from rake/rbenv.rake rename to rake/pkg/rbenv.rake index 18505eae..5f363df8 100644 --- a/rake/rbenv.rake +++ b/rake/pkg/rbenv.rake @@ -1,6 +1,5 @@ - -require_relative 'lib/homebrew' -require_relative 'lib/rbenv' +require_relative '../lib/homebrew' +require_relative '../lib/rbenv' task :rbenv => 'rbenv:update' @@ -47,4 +46,16 @@ namespace :rbenv do end end + namespace :gem do + + task :install, [:gem, :all_rubies] do |t, args| + + end + + task :remove, [:gem, :all_rubies] do |t, args| + + end + + end + end diff --git a/rake/pkg/vim.rake b/rake/pkg/vim.rake new file mode 100644 index 00000000..05a64f11 --- /dev/null +++ b/rake/pkg/vim.rake @@ -0,0 +1,39 @@ +require_relative "../lib/output" +require_relative "../lib/homebrew" +require_relative "../lib/sh" + +desc "Ensure vim/macvim is installed and up to date" +task :vim => "vim:update" + +namespace :vim do + + task :install do + %w{lua luajit}.each { |pkg| Homebrew.install pkg } + %w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') } + + unless Dir.exists? (File.expand_path("~/.vim")) + github('hlissner/vim', '~/.vim') + github('Shougo/neobundle.vim', '~/.vim/bundle/neobundle.vim') + end + end + + task :update => 'vim:install' do + path = File.expand_path("~/.vim") + + echo "Updating vim" + sh "cd #{path} && git pull" + + echo "Updating vim plugins" + Dir.glob("#{path}/bundle/*") do |f| + echo ":: Updating #{File.basename(f)}:" + sh_safe "cd #{f} && git pull" + end + end + + desc "Remove vim" + task :remove do + echo "Uninstalling vim" + %w{vim macvim}.each { |pkg| Homebrew.remove pkg } + end + +end diff --git a/rake/zsh.rake b/rake/pkg/zsh.rake similarity index 92% rename from rake/zsh.rake rename to rake/pkg/zsh.rake index d6508d32..05b5d6f9 100644 --- a/rake/zsh.rake +++ b/rake/pkg/zsh.rake @@ -1,5 +1,5 @@ -require_relative 'lib/sh' -require_relative 'lib/git' +require_relative '../lib/sh' +require_relative '../lib/git' desc "Ensure zsh and oh-my-zsh is installed and set" task :zsh => 'zsh:update' diff --git a/rake/pyenv.rake b/rake/pyenv.rake deleted file mode 100644 index eb92ca3a..00000000 --- a/rake/pyenv.rake +++ /dev/null @@ -1,42 +0,0 @@ -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 - diff --git a/rake/setup.rake b/rake/setup.rake new file mode 100644 index 00000000..0d458e4b --- /dev/null +++ b/rake/setup.rake @@ -0,0 +1,16 @@ +require_relative 'lib/output' + +desc "Update the node (based on hostname)" +task :default, :node do |t, args| + args.with_defaults(:node => `hostname`.gsub('.local', '').strip) + Rake::Task["setup:#{args.node}"].invoke +end + +desc "Wipe the slate clean" +task :destroy do + # are you sure? + # are you really really sure? + # TODO: EXTERMINATE! +end + +namespace :setup do load_all("node/*.rake") end diff --git a/rake/vim.rake b/rake/vim.rake deleted file mode 100644 index 9320c9cb..00000000 --- a/rake/vim.rake +++ /dev/null @@ -1,40 +0,0 @@ - -require_relative "lib/output" -require_relative "lib/homebrew" -require_relative "lib/sh" - -desc "Ensure vim/macvim is installed and up to date" -task :vim => "vim:update" - -namespace :vim do - - task :install do - %w{lua luajit}.each { |pkg| Homebrew.install pkg } - %w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') } - - unless Dir.exists? (File.expand_path("~/.vim")) - github('hlissner/vim', '~/.vim') - github('Shougo/neobundle.vim', '~/.vim/bundle/neobundle.vim') - end - end - - task :update => 'vim:install' do - path = File.expand_path("~/.vim") - - echo "Updating vim" - sh "cd #{path} && git pull" - - echo "Updating vim plugins" - Dir.glob("#{path}/bundle/*") do |f| - echo ":: Updating #{File.basename(f)}:" - sh_safe "cd #{f} && git pull" - end - end - - desc "Remove vim" - task :remove do - echo "Uninstalling vim" - %w{vim macvim}.each { |pkg| Homebrew.remove pkg } - end - -end