From 72115b8ced7b5bf7dc54c58cf6dcc958b8851756 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 25 Feb 2016 18:43:56 -0500 Subject: [PATCH] Remove rake provisioner (using ansible instead) --- rake/README.md | 73 ------------------ rake/edit.rake | 14 ---- rake/lib/git.rb | 12 --- rake/lib/os.rb | 9 --- rake/lib/output.rb | 9 --- rake/lib/package.rb | 13 ---- rake/lib/package_adapters/aptitude.rb | 30 -------- rake/lib/package_adapters/homebrew.rb | 66 ----------------- rake/lib/rake.rb | 3 - rake/lib/sh.rb | 19 ----- rake/node/callisto.rake | 9 --- rake/node/ganymede.rake | 2 - rake/node/io.rake | 46 ------------ rake/node/titan.rake | 2 - rake/packages.rake | 37 --------- rake/pkg/bash.rake | 30 -------- rake/pkg/emacs.rake | 79 -------------------- rake/pkg/love.rake | 39 ---------- rake/pkg/mjolnir.rake | 13 ---- rake/pkg/nodejs.rake | 40 ---------- rake/pkg/osx.rake | 99 ------------------------- rake/pkg/package.rake | 80 -------------------- rake/pkg/pyenv.rake | 83 --------------------- rake/pkg/rbenv.rake | 103 -------------------------- rake/pkg/vim.rake | 65 ---------------- rake/pkg/zsh.rake | 45 ----------- rake/provision.rake | 20 ----- 27 files changed, 1040 deletions(-) delete mode 100644 rake/README.md delete mode 100644 rake/edit.rake delete mode 100644 rake/lib/git.rb delete mode 100644 rake/lib/os.rb delete mode 100644 rake/lib/output.rb delete mode 100644 rake/lib/package.rb delete mode 100644 rake/lib/package_adapters/aptitude.rb delete mode 100644 rake/lib/package_adapters/homebrew.rb delete mode 100644 rake/lib/rake.rb delete mode 100644 rake/lib/sh.rb delete mode 100644 rake/node/callisto.rake delete mode 100644 rake/node/ganymede.rake delete mode 100644 rake/node/io.rake delete mode 100644 rake/node/titan.rake delete mode 100644 rake/packages.rake delete mode 100644 rake/pkg/bash.rake delete mode 100644 rake/pkg/emacs.rake delete mode 100644 rake/pkg/love.rake delete mode 100644 rake/pkg/mjolnir.rake delete mode 100644 rake/pkg/nodejs.rake delete mode 100644 rake/pkg/osx.rake delete mode 100644 rake/pkg/package.rake delete mode 100644 rake/pkg/pyenv.rake delete mode 100644 rake/pkg/rbenv.rake delete mode 100644 rake/pkg/vim.rake delete mode 100644 rake/pkg/zsh.rake delete mode 100644 rake/provision.rake diff --git a/rake/README.md b/rake/README.md deleted file mode 100644 index 811e25e2..00000000 --- a/rake/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Rake install scripts - -I use global rakefiles to provision my computers and servers. They -work for OSX and Ubuntu; a `rake -g -T` will reveal all the available -options. - -Running `rake -g update` will run the rake task that matches your -computer's hostname; they can be found in -`rake/nodes/.rake`. I have one for each of my computers. - -Feel free to take from it what you like. - -## Packages - -This currently provides: - -* Homebrew -* OSX settings -* Zsh + zprezto -- deploys my [zsh dotfiles](http://github.com/hlissner/dotfiles) -* Emacs (mac only) -- deploys my [emacs.d](http://github.com/hlissner/emacs.d) -* Vim -- deploys my [vimrc](https://github.com/hlissner/dotfiles/blob/master/vimrc) -* Pyenv -* Rbenv - -Planned features: - -* Gitlab -* Flexget seedbox -* Webserver stacks for vagrant - -## Installation - -Simply symlink `./rake` to `~/.rake`, then these commands will become -accessible globally via `rake -g [task]`. - -```sh -git clone https://github.com/hlissner/dotfiles ~/.dotfiles -ln -sf ~/.dotfiles/rake ~/.rake -``` - -Or just cd into `./rake` and work from there. - -## Usage - -```sh -rake -g # Same as: rake -g setup:`hostname` -rake -g update # Same as: rake -g setup:`hostname` - -# This will install all the things specified in -# rake/nodes/.rake and/or update them if already installed. -rake -g setup: - -# Installs , or updates it -rake -g pkg: -# Package sub-commands -rake -g pkg::install -rake -g pkg::remove -rake -g pkg::update - -rake -g destroy # Runs pkg:*:remove and deletes all packages -``` - -A couple examples: - -```sh -# Install/update homebrew, zsh and emacs -rake -g pkg:homebrew -rake -g pkg:zsh -rake -g pkg:emacs - -# Install/update my config for ganymede -rake -g setup:ganymede -``` diff --git a/rake/edit.rake b/rake/edit.rake deleted file mode 100644 index 4d3e9392..00000000 --- a/rake/edit.rake +++ /dev/null @@ -1,14 +0,0 @@ -desc "Open a task in your editor" -task :edit, :package do |t, args| - p "No package specified!" unless args.package - - #prefix = __dir__ - #path = "#{prefix}/#{args.package.gsub(":", "/").strip}.rake" - begin - path = Rake.application[args.package].actions.map(&:source_location).first.first - echo "Opening #{path}" - sh "$EDITOR #{path}" - rescue - error "No task found" - end -end diff --git a/rake/lib/git.rb b/rake/lib/git.rb deleted file mode 100644 index 13415bd2..00000000 --- a/rake/lib/git.rb +++ /dev/null @@ -1,12 +0,0 @@ -include Rake::DSL - -def git(url, dest) - unless Dir.exists?("#{dest}/.git") - rm_rf dest if Dir.exists?(dest) - sh "git clone '#{url}' '#{dest}'" - end -end - -def github(repo, dest, protocol = "https") - git "#{protocol}://github.com/#{repo}.git", dest -end diff --git a/rake/lib/os.rb b/rake/lib/os.rb deleted file mode 100644 index db422dd9..00000000 --- a/rake/lib/os.rb +++ /dev/null @@ -1,9 +0,0 @@ -def is_mac? - RUBY_PLATFORM =~ /darwin/ -end - -def is_linux? - RUBY_PLATFORM =~ /linux/ -end - -# TODO Implement other linux distro tests diff --git a/rake/lib/output.rb b/rake/lib/output.rb deleted file mode 100644 index 4717220f..00000000 --- a/rake/lib/output.rb +++ /dev/null @@ -1,9 +0,0 @@ -def echo(msg, level = 1) - # print green text - puts "\e[32m#{"="*level}> #{msg}\e[0m" -end - -def error(msg) - # print red text - puts "\e[31m=> #{msg}\e[0m" -end diff --git a/rake/lib/package.rb b/rake/lib/package.rb deleted file mode 100644 index d6c7dc8d..00000000 --- a/rake/lib/package.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative "sh" -require_relative "os" - -include Rake::DSL - -if is_mac? - require_relative "package_adapters/homebrew.rb" -elsif is_linux? - require_relative "package_adapters/aptitude.rb" - # TODO Implement centos yum support -else - raise "Could not detect OS" -end diff --git a/rake/lib/package_adapters/aptitude.rb b/rake/lib/package_adapters/aptitude.rb deleted file mode 100644 index 3c52b59d..00000000 --- a/rake/lib/package_adapters/aptitude.rb +++ /dev/null @@ -1,30 +0,0 @@ -# Aptitude (ubuntu/debian) package adapter -module Package - module_function - - def bootstrap; end - - def install(package) - self.run("install", "-y", package) - end - - def installed?; end - - def remove(package); end - - def update(*args); end - - def tap(repo) - sh_safe "sudo add-apt-repository #{repo}" - end - - def untap(repo); end - - def tapped?(repo); end - - # TODO Finish aptitude adapter - - def run(*args) - system("sudo apt-get #{args.join(' ')}") - end -end diff --git a/rake/lib/package_adapters/homebrew.rb b/rake/lib/package_adapters/homebrew.rb deleted file mode 100644 index b1d17ea2..00000000 --- a/rake/lib/package_adapters/homebrew.rb +++ /dev/null @@ -1,66 +0,0 @@ -# Homebrew package adapter -module Package - module_function - - @@brew_bin = "/usr/local/bin/brew" - - def bootstrap - unless self.installed? - sh_safe 'ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"' - end - end - - def install(package) - self.run("install", package) unless self.installed?(package) - end - - def installed?(package = nil) - return File.exists?(@@brew_bin) if !package - - self.run("list | grep -w '^#{package.split(" ")[0]}$' >& /dev/null") - end - - def remove(package) - self.run("remove", package) - end - - def update(*args) - if args.length > 0 - self.run("upgrade #{args.join(' ')}") - else - self.run("update") - self.run("upgrade") - end - end - - def tap(repo) - self.run("tap", repo) unless self.tapped?(repo) - end - - def untap(repo) - self.run("untap #{repo}") - end - - def tapped?(repo) - self.run("tap | grep -w '^#{repo}$' >& /dev/null") - end - - # Homebrew-specific functions - def cask_install(cask) - self.run("cask", "install", cask) unless self.cask_installed?(cask) - end - - def cask_remove(cask) - self.run("cask", "uninstall", cask) unless self.cask_installed?(cask) - end - - def cask_installed?(cask) - self.run("cask list | grep -w '^#{cask}$' >& /dev/null") - end - - def run(*args) - raise "Homebrew isn't installed!" unless self.installed? - - system("#{@@brew_bin} #{args.join(' ')}") - end -end diff --git a/rake/lib/rake.rb b/rake/lib/rake.rb deleted file mode 100644 index c275d2d7..00000000 --- a/rake/lib/rake.rb +++ /dev/null @@ -1,3 +0,0 @@ -def load_all(glob) - Dir.glob("#{File.dirname(__FILE__)}/../#{glob}") { |file| load file } -end diff --git a/rake/lib/sh.rb b/rake/lib/sh.rb deleted file mode 100644 index 9e8b8b7a..00000000 --- a/rake/lib/sh.rb +++ /dev/null @@ -1,19 +0,0 @@ -require_relative 'output' - -# A 'safe' sh function that won't stop rake in its tracks -# when it encounters a problem. I'll leave it up to the -# programmer to expect problems and terminate when necessary. -def sh_safe(cmd) - begin - return sh(cmd) - rescue - error $! - return false - end -end - -def do_link(src, dest) - if not (File.exist?(path_to_file) || File.symlink?(path_to_file)) - sh_safe "ln -sf #{src} #{dest}" - end -end diff --git a/rake/node/callisto.rake b/rake/node/callisto.rake deleted file mode 100644 index b4ce49ff..00000000 --- a/rake/node/callisto.rake +++ /dev/null @@ -1,9 +0,0 @@ -desc "My home server" -task :callisto do - %w{ - update - pkg:zsh - pkg:vim - pkg:rbenv - }.each { |task| Rake::Task[task].invoke } -end diff --git a/rake/node/ganymede.rake b/rake/node/ganymede.rake deleted file mode 100644 index c4ab9d3e..00000000 --- a/rake/node/ganymede.rake +++ /dev/null @@ -1,2 +0,0 @@ -desc "My work laptop" -task :ganymede => :io diff --git a/rake/node/io.rake b/rake/node/io.rake deleted file mode 100644 index d7404aec..00000000 --- a/rake/node/io.rake +++ /dev/null @@ -1,46 +0,0 @@ -desc "My main computer" -task :io do - sh "cd ~/.dotfiles && git pull" - - [ "pkg:update", - "pkg:osx", - "pkg:nodejs", - "pkg:zsh", - "pkg:vim", - "pkg:emacs", - "pkg:rbenv", - "pkg:pyenv" - # "pkg:love" - ].each { |task| Rake::Task[task].invoke } - - # Install my the mac-apps I commonly use - if is_mac? - [ "dropbox", - "imagealpha", - "imageoptim", - "xquartz", - "openemu", - "transmit", - "transmission", - "vlc", - "flux", - "skype", - "adium", - "mindnode-pro", - "sequel-pro", - "scrivener", - "omnigraffle", - - # Quicklook plugins - "qlcolorcode", - "qlstephen", - "qlmarkdown", - "quicklook-json", - "qlprettypatch", - "quicklook-csv", - "betterzipql", - "webp-quicklook", - "suspicious-package" - ].each { |app| Package.cask_install app } - end -end diff --git a/rake/node/titan.rake b/rake/node/titan.rake deleted file mode 100644 index 16e7b763..00000000 --- a/rake/node/titan.rake +++ /dev/null @@ -1,2 +0,0 @@ -desc "My media desktop" -task :titan => :io diff --git a/rake/packages.rake b/rake/packages.rake deleted file mode 100644 index 14752f84..00000000 --- a/rake/packages.rake +++ /dev/null @@ -1,37 +0,0 @@ -require_relative "lib/git" -require_relative "lib/os" -require_relative "lib/output" -require_relative "lib/rake" -require_relative "lib/sh" - -verbose(false) - -namespace :pkg do - desc 'Setup/update package manager & packages' - if is_mac? - task :update => 'homebrew:update' - elsif is_linux? - task :update => 'aptitude:update' - else - task :update do - echo "Package manager not implemented for this OS" - end - end - - load_all("pkg/*.rake") -end - -namespace :test do - task :output do - echo "Testing output" - echo "Testing sub-header output", 2 - echo "Another sub-header", 3 - - error "A big bad error!" - end - - task :tasks do - sh "echo 'This should pass'" - sh_safe "fake-command_ This should fail" # without disrupting the task - end -end diff --git a/rake/pkg/bash.rake b/rake/pkg/bash.rake deleted file mode 100644 index e087039e..00000000 --- a/rake/pkg/bash.rake +++ /dev/null @@ -1,30 +0,0 @@ -desc "Ensure bash is setup & up-to-date" -task :bash => 'bash:update' - -namespace :bash do - task :install do - echo "Attempting to install bash + completion" - Package.install "bash" - Package.install "bash-completion" - - if is_mac? - # Write the new bash into shells if it isn't already there - bash_bin = "/usr/local/bin/bash" - if `cat /etc/shells | grep "^#{bash_bin}$"` - echo "Writing '#{bash_bin}' to /etc/shells", 2 - sh_safe "echo '#{bash_bin}' | sudo tee -a /etc/shells" - end - - sh_safe "chsh -s #{bash_bin}" - end - end - - task :update => "bash:install" - - task :remove do - if is_mac? - Package.remove "bash" - Package.remove "bash-completion" - end - end -end diff --git a/rake/pkg/emacs.rake b/rake/pkg/emacs.rake deleted file mode 100644 index c381a26d..00000000 --- a/rake/pkg/emacs.rake +++ /dev/null @@ -1,79 +0,0 @@ -if is_mac? - - ENV["EMACS_D"] = File.expand_path("~/.emacs.d") - - def emacs_reqs - [ "emacs --with-cocoa --with-gnutls --with-imagemagick --with-librsvg --HEAD", - "ispell", - "cask", - "markdown" ] - end - - def node_reqs - %w{jshint jsonlint js-beautify git://github.com/ramitos/jsctags.git} - end - - def setup - echo "Installing emacs dependencies" - emacs_reqs.each { |pkg| Package.install pkg } - end - - def setup_node - echo "Installing node dependencies" - sh_safe "/usr/local/bin/npm install -g #{node_reqs.join(' ')}" - end - - def setup_emacs_d - echo "Setting up emacs.d & updating cask" - github 'hlissner/emacs.d', '~/.emacs.d' - sh_safe "cd '#{ENV["EMACS_D"]}' && cask install" - end - - def emacs_installed? - Dir.exists?(ENV["EMACS_D"]) - end - - # - desc "Ensure emacs 24.4 is installed & up to date" - task :emacs => "emacs:update" - - namespace :emacs do - desc "Install emacs completely" - task :install => ["pkg:nodejs:install", :setup, :setup_node, :setup_emacs_d] - - desc "Setup required homebrew packages" - task :setup do - setup if !emacs_installed? || ENV["FORCE"] - end - - desc "Setup required node & node plugins" - task :setup_node do - setup_node if !emacs_installed? || ENV["FORCE"] - end - - desc "Setup emacs.d folder, plugins and cask" - task :setup_emacs_d do - setup_emacs_d if !emacs_installed? || ENV["FORCE"] - end - - task :update => "emacs:install" do - if emacs_installed? && Dir.exists?("#{ENV['EMACS_D']}/.git") - echo "Updating emacs.d & packages" - sh_safe "cd '#{ENV["EMACS_D"]}' && git pull && cask update" - - # Update node - sh "/usr/local/bin/npm update -g #{node_reqs.join(' ')}" - end - end - - task :remove do - echo "Uninstalling emacs" - Package.remove "emacs" - Package.remove "homebrew/dupes/tidy" - emacs_reqs.each { |pkg| Package.remove pkg.split.first } - - rm_rf ENV["EMACS_D"] if Dir.exists? ENV["EMACS_D"] - end - end - -end diff --git a/rake/pkg/love.rake b/rake/pkg/love.rake deleted file mode 100644 index 2637ad2c..00000000 --- a/rake/pkg/love.rake +++ /dev/null @@ -1,39 +0,0 @@ -ENV["LINUX_PPA"] = "ppa:bartbes/love-stable" - -desc "Install/update Lua, Love2D & luarocks" -task :love => "love:update" - -namespace :love do - task :install do - if !system("which luarocks") - echo "Installing Lua, Love2D and luarocks" - if is_linux? - Package.install "lua5.1" - - Package.tap ENV["LINUX_PPA"] - Package.install "luarocks" - Package.install "love" - elsif is_mac? - Package.install "lua" - - Package.cask_install "love" - Package.install "luarocks --HEAD" - end - - sh_safe "luarocks install --server=http://rocks.moonscript.org moonrocks" - sh_safe "luarocks install busted" - end - end - - task :update - - task :remove do - Package.remove "luarocks" - if is_linux? - Package.remove "love" - Package.untap ENV["LINUX_PPA"] - elsif is_mac? - Package.cask_remove "love" - end - end -end diff --git a/rake/pkg/mjolnir.rake b/rake/pkg/mjolnir.rake deleted file mode 100644 index f0094e0d..00000000 --- a/rake/pkg/mjolnir.rake +++ /dev/null @@ -1,13 +0,0 @@ - -task :mjolnir => 'mjolnir:update' - -namespace :mjolnir do - task :install do - Package.install "lua", "luarocks" - sh "mkdir -p ~/.luarocks" - sh "echo 'rocks_servers = { \"http://rocks.moonscript.org\" }' > ~/.luarocks/config.lua" - sh "luarocks install mjolnir.hotkey" - sh "luarocks install mjolnir.application" - sh "luarocks install mjolnir._asm.modal_hotkey" - end -end diff --git a/rake/pkg/nodejs.rake b/rake/pkg/nodejs.rake deleted file mode 100644 index a09bbaf8..00000000 --- a/rake/pkg/nodejs.rake +++ /dev/null @@ -1,40 +0,0 @@ -def node_installed? - File.exists?(is_mac? ? "/usr/local/bin/node" : "/usr/bin/nodejs") -end - -desc "Ensure nodejs & its prerequisites are installed" -task :nodejs => "pkg:nodejs:update" - -namespace :nodejs do - desc "Install node.js completely" - task :install do - unless node_installed? - echo "Installing node" - if is_linux? - sh_safe "curl -sL https://deb.nodesource.com/setup | sudo bash -" - Package.update - end - - Package.install is_mac? ? "node" : "nodejs" - Package.install "npm" if is_linux? - end - end - - if node_installed? - task :update => :install do - echo "Updating node" - if is_mac? - Package.update "node" - elsif is_linux? - sh_safe "npm cache clean -f" - sh_safe "npm update npm -g" - end - end - - task :remove do - echo "Uninstalling node" - sh_safe "npm uninstall npm -g" - Package.remove is_mac? ? "node" : "nodejs" - end - end -end diff --git a/rake/pkg/osx.rake b/rake/pkg/osx.rake deleted file mode 100644 index 170906d5..00000000 --- a/rake/pkg/osx.rake +++ /dev/null @@ -1,99 +0,0 @@ -# coding: utf-8 -require_relative '../lib/output' - -desc "Set OSX default configuration" -task :osx do - next unless is_mac? - - if system('defaults read com.apple.finder _FXShowPosixPathInTitle >&/dev/null') - echo 'OSX settings already applied!' - next - end - - echo "Applying OSX settings" - [ - 'chflags nohidden "${HOME}/Library"', - # 'defaults write NSGlobalDomain KeyRepeat -int 0', - - # Disable press-and-hold for keys in favor of key repeat - 'defaults write ApplePressAndHoldEnabled -bool false', - - 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3', - 'defaults write NSGlobalDomain AppleFontSmoothing -int 2', - 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true', - 'defaults write com.apple.dock autohide -bool true', - - # Expand save panel by default - 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true', - 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true', - - # Disable app quarantine - 'defaults write com.apple.LaunchServices LSQuarantine -bool false', - - # Disable auto-correct - 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false', - - # Disable smart quotes - 'defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false', - # Disable smart dashes as they're annoying when typing code - 'defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false', - - # Avoid creating .DS_Store files on network volumes - 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true', - # Disable the warning when changing a file extension - 'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false', - - 'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true', - - # Disable local Time Machine backups - # sh_safe 'hash_safe tmutil &> /dev/null && sudo tmutil disablelocal' - # Prevent Time Machine from prompting to use new hard drives as backup volume - 'defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true', - - # Finder: allow text selection in Quick Look - 'defaults write com.apple.finder QLEnableTextSelection -bool true', - - # When performing a search, search the current folder by default - 'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"', - - ### FINDER ### - # Use column view - 'defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"', # default location for new finder windows - 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"', # column view by default - - 'defaults write com.apple.finder ShowPathbar -bool true', # path bar - 'defaults write com.apple.finder ShowStatusBar -bool true', # status bar - 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true', # path in window title - - # Disable the warning before emptying the Trash - 'defaults write com.apple.finder WarnOnEmptyTrash -bool false', - - # Disable Dashboard - 'defaults write com.apple.dashboard mcx-disabled -bool true', - # Don’t show Dashboard as a Space - 'defaults write com.apple.dock dashboard-in-overlay -bool true', - - # Make Dock icons of hidden applications translucent - 'defaults write com.apple.dock showhidden -bool true', - - # Disable Spotlight indexing for any volume that gets mounted and has not yet - # been indexed before. - # Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume. - 'sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes"', - - ### Text edit ### - # Use plain text mode for new TextEdit documents - 'defaults write com.apple.TextEdit RichText -int 0', - # Open and save files as UTF-8 in TextEdit - 'defaults write com.apple.TextEdit PlainTextEncoding -int 4', - 'defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4', - - # Disable the sudden motion sensor as it’s not useful for SSDs - 'sudo pmset -a sms 0', - - # Load new settings before rebuilding the index - 'killall mds > /dev/null 2>&1', - 'killall Finder', - 'killall Dock' - ].each { |cmd| sh_safe cmd } -end diff --git a/rake/pkg/package.rake b/rake/pkg/package.rake deleted file mode 100644 index 9eae6a65..00000000 --- a/rake/pkg/package.rake +++ /dev/null @@ -1,80 +0,0 @@ -require_relative "../lib/package" - -if is_mac? - - desc "Update/setup homebrew" - task :homebrew => "homebrew:update" - - namespace :homebrew do - task :setup do - unless Package.installed? - echo "Installing Homebrew..." - Package.bootstrap - - Package.tap 'homebrew/dupes' - Package.tap 'caskroom/cask' - end - - Package.install 'brew-cask' - - # Essentials for all macs; specific brews are placed - # in the node/*.rake files - [ "coreutils", - "wget", - "curl", - "tree", - "git", - "hub", - "the_silver_searcher", - "tmux", - "gist", - "lua", - "readline", - "openssl", - "node" - ].each { |pkg| Package.install pkg } - - [ "appcleaner", - "vagrant", - "virtualbox", - "growlnotify", - "iterm2", - "java", - "launchbar" - ].each { |app| Package.cask_install app } - - echo "Homebrew is installed. Moving on." - end - - task :update => "homebrew:setup" do - echo "Updating homebrew..." - Package.update - end - - task :remove do - Package.destroy if Package.installed? - end - end - -elsif is_linux? - - desc "Update/setup aptitude" - task :aptitude => "aptitude:update" - - namespace :aptitude do - task :setup do - echo "Updating packages..." - Package.update - - [ "git", - "tmux", - "curl", - "ruby2.0", - "rake" - ].each { |pkg| Package.install pkg } - end - - task :update => 'aptitude:setup' - end - -end diff --git a/rake/pkg/pyenv.rake b/rake/pkg/pyenv.rake deleted file mode 100644 index b22daf33..00000000 --- a/rake/pkg/pyenv.rake +++ /dev/null @@ -1,83 +0,0 @@ -PYENV_ROOT = File.expand_path("~/.pyenv") - -def pyenv_installed? - Dir.exists?(PYENV_ROOT) -end - -def pyenv_versions - `ls -1 #{PYENV_ROOT}/versions`.split("\n") if Dir.exists? "#{PYENV_ROOT}/versions" -end - -def pyenv_plugins - Dir.glob("#{PYENV_ROOT}/plugins/*") -end - -def pyenv_version_installed?(version) - versions = pyenv_versions - versions.include?(version) if versions -end - -### - -desc "Install/update pyenv & all pythons" -task :pyenv => 'pyenv:update' - -namespace :pyenv do - task :install do - unless pyenv_installed? - echo "Installing pyenv" - github "yyuu/pyenv", PYENV_ROOT - - [ "yyuu/pyenv-doctor", - "yyuu/pyenv-installer", - "yyuu/pyenv-pip-rehash", - "yyuu/pyenv-update", - "yyuu/pyenv-virtualenv", - "yyuu/pyenv-which-ext" - ].each do |pkg| - echo "Installing #{pkg}", 2 - github pkg, "#{PYENV_ROOT}/plugins/#{pkg.split("/")[1]}" - end - - echo "Initializing pyenv", 2 - sh_safe "eval \"$(#{PYENV_ROOT}/bin/pyenv init -)\"" - sh_safe "eval \"$(#{PYENV_ROOT}/bin/pyenv virtualenv-init -)\"" - end - - ['3.4.3', '2.7.10'].each do |version| - unless pyenv_version_installed? version - # Install global python + packages - echo "Setting up default python (#{version})", 2 - sh_safe "pyenv install #{version}" - sh_safe "pyenv global #{version}" - sh_safe "PYENV_VERSION=#{version} #{PYENV_ROOT}/shims/pip install flake8" - sh_safe "PYENV_VERSION=#{version} #{PYENV_ROOT}/shims/pip install nose virtualenv pyyaml ipython" - end - end - end - - task :update => "pyenv:install" do - echo "Updating pyenv & plugins" - sh_safe "cd #{PYENV_ROOT} && git pull" - pyenv_plugins.each do |dir| - echo "Updating #{File.basename(dir)}", 2 - sh_safe "cd #{dir} && git pull" - end - - pyenv_versions.each do |version| - echo "Updating python #{version}", 2 - - cmd = "#{PYENV_ROOT}/shims/pip" - cmd = "sudo #{version}" if version == "system" - - sh_safe "PYENV_VERSION=#{version} #{cmd} freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs #{cmd} install -U" - end - end - - if pyenv_installed? - task :remove do - echo "Deleting pyenv" - sh_safe "rm -rf #{PYENV_ROOT}" - end - end -end diff --git a/rake/pkg/rbenv.rake b/rake/pkg/rbenv.rake deleted file mode 100644 index 3c11d0fa..00000000 --- a/rake/pkg/rbenv.rake +++ /dev/null @@ -1,103 +0,0 @@ -RBENV_ROOT = File.expand_path('~/.rbenv') - -def rbenv_installed? - Dir.exist?(RBENV_ROOT) -end - -def rbenv_versions - return [] unless Dir.exist? "#{RBENV_ROOT}/versions" - `ls -1 #{RBENV_ROOT}/versions`.split("\n") -end - -def rbenv_plugins - Dir.glob("#{RBENV_ROOT}/plugins/*") -end - -def rbenv_set_default_gems(*gems) - default_gems_file = "#{RBENV_ROOT}/default-gems" - File.write(default_gems_file, gems.join("\n")) -end - -def rbenv_version_installed?(version) - rbenv_versions.include?(version) -end - -### - -desc 'Install/update rbenv & all rubies' -task rbenv: 'rbenv:update' - -namespace :rbenv do - task :install do - unless rbenv_installed? - echo 'Installing rbenv' - github 'sstephenson/rbenv', RBENV_ROOT - - mkdir_p "#{RBENV_ROOT}/plugins" - ['sstephenson/rbenv-vars', - 'sstephenson/ruby-build', - 'sstephenson/rbenv-default-gems', - 'sstephenson/rbenv-gem-rehash', - 'fesplugas/rbenv-installer', - 'fesplugas/rbenv-bootstrap', - 'rkh/rbenv-update', - 'rkh/rbenv-whatis', - 'rkh/rbenv-use' - ].each do |pkg| - echo "Installing #{pkg}", 2 - github pkg, "#{RBENV_ROOT}/plugins/#{pkg.split('/')[1]}" - end - - echo 'Initializing rbenv', 2 - sh_safe "eval \"$(#{RBENV_ROOT}/bin/rbenv init -)\"" - end - - # Set default gems - rbenv_set_default_gems( - 'bundler', - 'rspec', - 'doing', - 'pry', - 'pry-doc', - 'pry-byebug', - 'pry-rescue', - 'pry-stack_explorer', - 'ripper-tags', - 'gem-ripper-tags' - ) - - # Install global ruby + gems - ruby_version = '2.1.6' - unless rbenv_version_installed? ruby_version - echo "Setting up default ruby (#{ruby_version})", 2 - sh_safe "rbenv install #{ruby_version}" - sh_safe "rbenv global #{ruby_version}" - sh_safe "RBENV_VERSION=#{ruby_version} #{RBENV_ROOT}/shims/gem install -f jekyll sass mercenary colorize pry pry-doc pry-byebug rake" - end - end - - task update: 'rbenv:install' do - echo 'Updating rbenv & plugins' - sh_safe 'rbenv update' - - rbenv_versions.each do |version| - echo "Updating ruby #{version}" - - cmd = "#{RBENV_ROOT}/shims/gem" - cmd = "sudo #{cmd}" if version == 'system' - - sh_safe "RBENV_VERSION=#{version} #{cmd} update --system -f" - sh_safe "RBENV_VERSION=#{version} #{cmd} update -f" - sh_safe "RBENV_VERSION=#{version} #{cmd} clean" - end - - sh_safe 'rbenv rehash' - end - - if rbenv_installed? - task :remove do - echo 'Deleting rbenv' - sh_safe "rm -rf #{RBENV_ROOT}" - end - end -end diff --git a/rake/pkg/vim.rake b/rake/pkg/vim.rake deleted file mode 100644 index 14a36175..00000000 --- a/rake/pkg/vim.rake +++ /dev/null @@ -1,65 +0,0 @@ -desc "Ensure vim/macvim is installed and up to date" -task :vim => "vim:update" - -namespace :vim do - task :install do - vim_path = File.expand_path("~/.vim") - - if is_mac? - Package.install "lua" - %w{vim macvim}.each { |pkg| Package.install "#{pkg} --with-lua --with-luajit" } - elsif is_linux? - Package.install "lua5.1" - - unless Dir.exists?(vim_path) - sh_safe "sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \ - libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ - libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby1.9-dev mercurial" - - sh_safe "hg clone https://code.google.com/p/vim/ /tmp/vim" - sh_safe "cd /tmp/vim && ./configure --with-features=huge \ - --enable-multibyte \ - --enable-rubyinterp \ - --enable-pythoninterp \ - --enable-perlinterp \ - --enable-luainterp \ - --enable-clipboard \ - --enable-cscope --prefix=/usr \ - && make VIMRUNTIMEDIR=/usr/share/vim/vim74 - && sudo make install" - sh_safe "rm -rf /tmp/vim" - end - end - Package.install "luajit" - - unless Dir.exists?(vim_path) - github('hlissner/vim', vim_path) - github('Shougo/neobundle.vim', "#{vim_path}/bundle/neobundle.vim") - end - end - - task :update => 'vim:install' do - path = File.expand_path("~/.vim") - - echo "Updating vim" - sh_safe "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 - - if is_linux? - echo "Can't update compiled vim itself! Use pkg:vim:install" - end - end - - task :remove do - if is_mac? - echo "Uninstalling vim" - Package.remove "vim" - Package.remove "macvim" - end - end -end diff --git a/rake/pkg/zsh.rake b/rake/pkg/zsh.rake deleted file mode 100644 index b4846449..00000000 --- a/rake/pkg/zsh.rake +++ /dev/null @@ -1,45 +0,0 @@ -desc "Ensure zsh & prezto are installed" -task :zsh => 'zsh:update' - -ENV["PREZTO_PATH"] = File.expand_path("~/.zprezto") - -namespace :zsh do - task :install do - echo "Attempting to install ZSH" - Package.install "zsh" - - unless Dir.exists? ENV["PREZTO_PATH"] - echo "Installing prezto", 2 - github 'hlissner/prezto', ENV["PREZTO_PATH"] - end - sh_safe '~/.dotfiles/install.sh' - - unless `printenv SHELL | grep "/zsh$"` - echo "Setting shell to ZSH", 2 - zsh_bin = is_mac? ? "/usr/local/bin/zsh" : "/usr/bin/zsh" - unless File.exists? zsh_bin - error "ZSH isn't in #{File.dirname(zsh_bin)}" - next - end - - # Write the new zsh into shells if it isn't already there - if `cat /etc/shells | grep "^#{zsh_bin}$"` - echo "Writing '#{zsh_bin}' to /etc/shells", 3 - sh_safe "echo '#{zsh_bin}' | sudo tee -a /etc/shells" - end - - sh "chsh -s #{zsh_bin}" - end - - echo "Comment out path_helper to fix PATH in emacs!" if is_mac? - end - - task :update => "zsh:install" do - echo "Updating zprezto" - sh_safe 'cd ~/.zprezto && git pull' - end - - task :remove do - sh_safe 'rm -rf ~/.zprezto' if Dir.exists? ENV["PREZTO_PATH"] - end -end diff --git a/rake/provision.rake b/rake/provision.rake deleted file mode 100644 index 202843e4..00000000 --- a/rake/provision.rake +++ /dev/null @@ -1,20 +0,0 @@ -require_relative 'lib/output' - -task :default => :update - -desc "Update the node (based on hostname)" -task :update, :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