Refactor global rakefiles
This commit is contained in:
parent
f27d4d09ec
commit
1ef01b1055
|
@ -1,6 +1,73 @@
|
||||||
# Rake install scripts
|
# Rake install scripts
|
||||||
|
|
||||||
My global rakefiles for my macs. Installs homebrew, vim and zsh; configures OSX; and
|
I use global rakefiles to provision my computers and servers. They
|
||||||
sets up my gamedev/programming environments.
|
work for OSX and Ubuntu; a `rake -g -T` will reveal all the available
|
||||||
|
options.
|
||||||
|
|
||||||
I leave home without it.
|
Running `rake -g update` will run the rake task that matches your
|
||||||
|
computer's hostname; they can be found in
|
||||||
|
`rake/nodes/<hostname>.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/<hostname>.rake and/or update them if already installed.
|
||||||
|
rake -g setup:<hostname>
|
||||||
|
|
||||||
|
# Installs <package>, or updates it
|
||||||
|
rake -g pkg:<package>
|
||||||
|
# Package sub-commands
|
||||||
|
rake -g pkg:<package>:install
|
||||||
|
rake -g pkg:<package>:remove
|
||||||
|
rake -g pkg:<package>: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
|
||||||
|
```
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
|
|
||||||
module Project
|
class Project
|
||||||
|
|
||||||
def create(dirs=[])
|
template_folder = "templates"
|
||||||
|
|
||||||
|
def dirs(dirs=[])
|
||||||
|
dirs.each do |d|
|
||||||
|
mkdir_p d unless Dir.exists? d
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def template(template, vars={}, dest="")
|
def template(template, dest="", vars={})
|
||||||
|
template_file = "#{template_folder}/#{template}.erb"
|
||||||
|
dest_file = "#{dest}/#{File.basename(template)}"
|
||||||
|
|
||||||
end
|
raise "Template file doesn't exist" unless File.exists? template_file
|
||||||
|
raise "Destination folder doesn't exist" unless Dir.exists? dest
|
||||||
def update(name)
|
raise "Destination file already exists" unless File.exists? dest_file
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def remove(name)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
class Template
|
|
||||||
|
|
||||||
|
erb = ERB.new(File.read(template_file))
|
||||||
|
File.open(dest_file) do |f|
|
||||||
|
f.puts(erb.result(binding))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,76 +3,76 @@ require_relative 'sh'
|
||||||
include Rake::DSL
|
include Rake::DSL
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
BIN = "/usr/local/bin/brew"
|
BIN = "/usr/local/bin/brew"
|
||||||
|
|
||||||
def self.bootstrap
|
def self.bootstrap
|
||||||
unless self.is_installed?
|
unless self.is_installed?
|
||||||
sh_safe 'ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"'
|
sh_safe 'ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"'
|
||||||
echo "Homebrew is installed! Restart the shell then rake."
|
echo "Homebrew is installed! Restart the shell then rake."
|
||||||
exit
|
exit
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.destroy
|
def self.destroy
|
||||||
if self.is_installed?
|
if self.is_installed?
|
||||||
sh_safe 'rm -rf /usr/local/Cellar /usr/local/.git ~/Library/Caches/Homebrew'
|
sh_safe 'rm -rf /usr/local/Cellar /usr/local/.git ~/Library/Caches/Homebrew'
|
||||||
sh_safe 'brew prune'
|
sh_safe 'brew prune'
|
||||||
|
|
||||||
['Library/Homebrew', 'Library/Aliases', 'Library/Formula', 'Library/Contributions'].each do |dir|
|
['Library/Homebrew', 'Library/Aliases', 'Library/Formula', 'Library/Contributions'].each do |dir|
|
||||||
sh_safe "rm -r #{dir}"
|
sh_safe "rm -r #{dir}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.install(keg, options=nil)
|
def self.install(keg, options=nil)
|
||||||
sh_safe "#{BIN} install #{keg} #{options}" unless self.is_keg_installed?(keg)
|
sh_safe "#{BIN} install #{keg} #{options}" unless self.is_keg_installed?(keg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install_cask(cask, options=nil)
|
def self.install_cask(cask, options=nil)
|
||||||
sh_safe "#{BIN} cask install #{cask} #{options}" unless self.is_cask_installed?(cask)
|
sh_safe "#{BIN} cask install #{cask} #{options}" unless self.is_cask_installed?(cask)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tap(tap)
|
def self.tap(tap)
|
||||||
sh_safe "#{BIN} tap #{tap}" unless self.is_tapped? tap
|
sh_safe "#{BIN} tap #{tap}" unless self.is_tapped? tap
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.remove(keg)
|
def self.remove(keg)
|
||||||
sh_safe "#{BIN} remove #{keg}"
|
sh_safe "#{BIN} remove #{keg}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.remove_cask(keg)
|
def self.remove_cask(keg)
|
||||||
sh_safe "#{BIN} cask uninstall #{keg}"
|
sh_safe "#{BIN} cask uninstall #{keg}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.has_keg?(keg)
|
def self.has_keg?(keg)
|
||||||
system("#{BIN} search #{keg}")
|
system("#{BIN} search #{keg}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_keg_installed?(keg)
|
def self.is_keg_installed?(keg)
|
||||||
system("#{BIN} list | grep -w '#{keg}' >& /dev/null")
|
system("#{BIN} list | grep -w '#{keg}' >& /dev/null")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_cask_installed?(cask)
|
def self.is_cask_installed?(cask)
|
||||||
system("#{BIN} cask list | grep -w '#{cask}' >& /dev/null")
|
system("#{BIN} cask list | grep -w '#{cask}' >& /dev/null")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_tapped?(tap)
|
def self.is_tapped?(tap)
|
||||||
system("#{BIN} tap | grep -w '#{tap}' >& /dev/null")
|
system("#{BIN} tap | grep -w '#{tap}' >& /dev/null")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_installed?
|
def self.is_installed?
|
||||||
File.exists?("/usr/local/bin/brew")
|
File.exists?("/usr/local/bin/brew")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prefix(keg)
|
def self.prefix(keg)
|
||||||
`#{BIN} --prefix #{keg}`.strip
|
`#{BIN} --prefix #{keg}`.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update(*args)
|
def self.update(*args)
|
||||||
if args.length > 0
|
if args.length > 0
|
||||||
sh_safe "#{BIN} upgrade #{args.join(' ')}"
|
sh_safe "#{BIN} upgrade #{args.join(' ')}"
|
||||||
else
|
else
|
||||||
sh_safe "#{BIN} update && #{BIN} upgrade"
|
sh_safe "#{BIN} update && #{BIN} upgrade"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
9
rake/lib/os.rb
Normal file
9
rake/lib/os.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
def is_mac?
|
||||||
|
RUBY_PLATFORM =~ /darwin/
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_linux?
|
||||||
|
RUBY_PLATFORM =~ /linux/
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO Implement other linux distro tests
|
13
rake/lib/package.rb
Normal file
13
rake/lib/package.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
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
|
16
rake/lib/package_adapters/aptitude.rb
Normal file
16
rake/lib/package_adapters/aptitude.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Aptitude (ubuntu/debian) package adapter
|
||||||
|
module Package
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def bootstrap; end
|
||||||
|
|
||||||
|
def install(package)
|
||||||
|
self.run("install", "-y", package)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO Finish aptitude adapter
|
||||||
|
|
||||||
|
def run(*args)
|
||||||
|
system("sudo apt-get #{args.join(' ')}")
|
||||||
|
end
|
||||||
|
end
|
58
rake/lib/package_adapters/homebrew.rb
Normal file
58
rake/lib/package_adapters/homebrew.rb
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
# 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}' >& /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
|
||||||
|
|
||||||
|
# Homebrew-specific functions
|
||||||
|
def cask_install(cask)
|
||||||
|
self.run("cask", "install", cask) unless self.cask_installed?(cask)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cask_installed?(cask)
|
||||||
|
self.run("cask list | grep -w '#{cask}' >& /dev/null")
|
||||||
|
end
|
||||||
|
|
||||||
|
def tap(repo)
|
||||||
|
self.run("tap", repo) unless self.tapped?(repo)
|
||||||
|
end
|
||||||
|
|
||||||
|
def tapped?(repo)
|
||||||
|
self.run("tap | grep -w '#{repo}' >& /dev/null")
|
||||||
|
end
|
||||||
|
|
||||||
|
def run(*args)
|
||||||
|
raise "Homebrew isn't installed!" unless self.installed?
|
||||||
|
|
||||||
|
`#{@@brew_bin} #{args.join(' ')}`
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
module Pyenv
|
||||||
|
|
||||||
|
BREWS = %w{pbenv pyenv-pip-rehash pyenv-virtualenv}
|
||||||
|
|
||||||
|
PIP_BIN = "/usr/local/opt/pyenv/shims/pip"
|
||||||
|
|
||||||
|
def self.bootstrap
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
def load_all(glob)
|
def load_all(glob)
|
||||||
Dir.glob("#{File.dirname(__FILE__)}/../#{glob}") { |file| load file }
|
Dir.glob("#{File.dirname(__FILE__)}/../#{glob}") { |file| load file }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
require_relative 'output'
|
require_relative 'output'
|
||||||
|
|
||||||
# A 'safe' sh function that won't stop rake in its tracks
|
# A 'safe' sh function that won't stop rake in its tracks
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
desc "Provision home server"
|
desc "Provision home server"
|
||||||
task :callisto do
|
task :callisto do
|
||||||
%w{
|
%w{
|
||||||
zsh
|
update
|
||||||
vim
|
pkg:zsh
|
||||||
}.each { |task| Rake::Task[task].invoke }
|
pkg:vim
|
||||||
|
pkg:rbenv
|
||||||
|
}.each { |task| Rake::Task[task].invoke }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
|
|
||||||
desc "Provision main laptop"
|
desc "Provision main laptop"
|
||||||
task :ganymede => :io
|
task :ganymede => :io
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
require_relative '../lib/homebrew'
|
|
||||||
|
|
||||||
desc "Provision main desktop"
|
desc "Provision main desktop"
|
||||||
task :io do
|
task :io do
|
||||||
%w{
|
%w{
|
||||||
pkg:osx
|
update
|
||||||
pkg:homebrew
|
pkg:osx
|
||||||
pkg:zsh
|
pkg:zsh
|
||||||
pkg:vim
|
pkg:vim
|
||||||
pkg:emacs
|
pkg:emacs
|
||||||
pkg:rbenv:v1_9
|
pkg:rbenv
|
||||||
pkg:rbenv:v2_0
|
pkg:pyenv
|
||||||
pkg:rbenv:update
|
}.each { |task| Rake::Task[task].invoke }
|
||||||
}.each { |task| Rake::Task[task].invoke }
|
|
||||||
|
|
||||||
|
if is_mac?
|
||||||
%w{
|
%w{
|
||||||
transmit
|
transmit
|
||||||
transmission
|
transmission
|
||||||
vlc
|
vlc
|
||||||
flux
|
flux
|
||||||
skype
|
skype
|
||||||
adium
|
adium
|
||||||
codekit
|
codekit
|
||||||
mongohub
|
sequel-pro
|
||||||
sequel-pro
|
scrivener
|
||||||
scrivener
|
omnigraffle
|
||||||
omnigraffle
|
love
|
||||||
love
|
}.each { |app| Package.cask_install app }
|
||||||
}.each { |app| Homebrew.install_cask app }
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
|
|
||||||
desc "Provision 2nd desktop"
|
desc "Provision 2nd desktop"
|
||||||
task :titan => :io
|
task :titan => :io
|
||||||
|
|
18
rake/packages.rake
Normal file
18
rake/packages.rake
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require_relative "lib/rake"
|
||||||
|
require_relative "lib/os"
|
||||||
|
require_relative "lib/sh"
|
||||||
|
require_relative "lib/output"
|
||||||
|
|
||||||
|
verbose(false)
|
||||||
|
|
||||||
|
if is_mac?
|
||||||
|
desc 'Setup/update homebrew & packages'
|
||||||
|
task :update => 'pkg:homebrew:update'
|
||||||
|
elsif is_linux?
|
||||||
|
desc 'Setup/update packages'
|
||||||
|
task :update => 'pkg:aptitude:update'
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :pkg do
|
||||||
|
load_all("pkg/*.rake")
|
||||||
|
end
|
|
@ -1,5 +0,0 @@
|
||||||
require_relative "lib/rake"
|
|
||||||
|
|
||||||
verbose(false)
|
|
||||||
|
|
||||||
namespace :pkg do load_all("pkg/*.rake") end
|
|
|
@ -1,32 +1,42 @@
|
||||||
desc "Ensure emacs is installed and up to date"
|
if is_mac?
|
||||||
task :emacs => "emacs:update"
|
|
||||||
|
|
||||||
namespace :emacs do
|
ENV['EMACS_D'] = File.expand_path("~/.emacs.d")
|
||||||
|
|
||||||
|
desc "Ensure emacs is installed and up to date"
|
||||||
|
task :emacs => "emacs:update"
|
||||||
|
|
||||||
|
namespace :emacs do
|
||||||
task :install do
|
task :install do
|
||||||
unless Dir.exists?(File.expand_path("~/.emacs.d"))
|
unless Dir.exists?(ENV[:EMACS_D])
|
||||||
github('hlissner/emacs.d', '~/.emacs.d')
|
github 'hlissner/emacs.d', '~/.emacs.d'
|
||||||
Homebrew.install("emacs", "--with-gnutls --cocoa --keep-ctags --srgb")
|
Package.install "emacs", "--with-gnutls --cocoa --keep-ctags --srgb"
|
||||||
Homebrew.install("homebrew/dupes/tidy", "--HEAD")
|
Package.install "homebrew/dupes/tidy", "--HEAD"
|
||||||
Homebrew.install "aspell"
|
emacs_reqs.each { |pkg| Package.install pkg }
|
||||||
|
|
||||||
sh_safe "/usr/local/bin/npm install jshint -g"
|
sh_safe "/usr/local/bin/npm install jshint -g"
|
||||||
sh_safe "/usr/local/bin/npm install jsonlint -g"
|
sh_safe "/usr/local/bin/npm install jsonlint -g"
|
||||||
end
|
sh_safe "cd ~/.emacs.d && cask"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :update do
|
task :update do
|
||||||
echo "Updating emacs.d"
|
echo "Updating emacs.d & packages"
|
||||||
sh_safe "cd ~/.emacs.d && git pull"
|
sh_safe "cd ~/.emacs.d && git pull && cask update"
|
||||||
|
|
||||||
echo "You'll have to update emacs packages manually!"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Remove emacs & dependencies"
|
||||||
task :remove do
|
task :remove do
|
||||||
echo "Uninstalling emacs"
|
echo "Uninstalling emacs"
|
||||||
Homebrew.remove "emacs"
|
Package.remove "emacs"
|
||||||
Homebrew.remove "aspell"
|
Package.remove "homebrew/dupes/tidy"
|
||||||
rm_rf "~/.emacs.d" if Dir.exists?(File.expand_path("~/.emacs.d"))
|
emacs_reqs.each { |pkg| Package.remove pkg }
|
||||||
|
|
||||||
|
rm_rf "~/.emacs.d" if Dir.exists?(ENV['EMACS_D'])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def emacs_reqs
|
||||||
|
%w{aspell cask rsense}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
if RUBY_PLATFORM =~ /darwin/
|
|
||||||
|
|
||||||
require_relative "../lib/output"
|
|
||||||
require_relative "../lib/homebrew"
|
|
||||||
require_relative "../lib/sh"
|
|
||||||
|
|
||||||
desc 'Install/update homebrew'
|
|
||||||
task :homebrew => 'homebrew:update'
|
|
||||||
|
|
||||||
namespace :homebrew do
|
|
||||||
|
|
||||||
task :install do
|
|
||||||
unless Homebrew.is_installed?
|
|
||||||
echo "Installing Homebrew..."
|
|
||||||
Homebrew.bootstrap
|
|
||||||
end
|
|
||||||
|
|
||||||
Homebrew.tap 'homebrew/dupes'
|
|
||||||
Homebrew.tap 'caskroom/cask'
|
|
||||||
Homebrew.install 'brew-cask'
|
|
||||||
|
|
||||||
%w{
|
|
||||||
coreutils
|
|
||||||
wget
|
|
||||||
curl
|
|
||||||
tree
|
|
||||||
git
|
|
||||||
the_silver_searcher
|
|
||||||
tmux
|
|
||||||
gist
|
|
||||||
lua
|
|
||||||
luajit
|
|
||||||
readline
|
|
||||||
openssl
|
|
||||||
node
|
|
||||||
}.each { |pkg| Homebrew.install pkg }
|
|
||||||
|
|
||||||
%w{
|
|
||||||
dropbox
|
|
||||||
appcleaner
|
|
||||||
vagrant
|
|
||||||
virtualbox
|
|
||||||
growlnotify
|
|
||||||
iterm2
|
|
||||||
java
|
|
||||||
launchbar
|
|
||||||
}.each { |app| Homebrew.install_cask app }
|
|
||||||
|
|
||||||
echo "Homebrew is installed. Moving on."
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Update homebrew and upgrade brews"
|
|
||||||
task :update => "homebrew:install" do
|
|
||||||
echo "Updating homebrew..."
|
|
||||||
Homebrew.update
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Remove homebrew cleanly"
|
|
||||||
task :remove do
|
|
||||||
Homebrew.destroy if Homebrew.is_installed?
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,52 +1,55 @@
|
||||||
require_relative '../lib/output'
|
require_relative '../lib/output'
|
||||||
|
|
||||||
|
desc "Set OSX default configuration"
|
||||||
task :osx do
|
task :osx do
|
||||||
if system('defaults read com.apple.finder _FXShowPosixPathInTitle >&/dev/null')
|
next unless is_mac?
|
||||||
echo 'OSX settings already applied!'
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
echo "Applying OSX settings"
|
if system('defaults read com.apple.finder _FXShowPosixPathInTitle >&/dev/null')
|
||||||
sh_safe 'chflags nohidden "${HOME}/Library"'
|
echo 'OSX settings already applied!'
|
||||||
sh_safe 'defaults write NSGlobalDomain KeyRepeat -int 0'
|
next
|
||||||
|
end
|
||||||
|
|
||||||
# Disable press-and-hold for keys in favor of key repeat
|
echo "Applying OSX settings"
|
||||||
sh_safe 'defaults write ApplePressAndHoldEnabled -bool false'
|
sh_safe 'chflags nohidden "${HOME}/Library"'
|
||||||
|
sh_safe 'defaults write NSGlobalDomain KeyRepeat -int 0'
|
||||||
|
|
||||||
sh_safe 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3'
|
# Disable press-and-hold for keys in favor of key repeat
|
||||||
sh_safe 'defaults write NSGlobalDomain AppleFontSmoothing -int 2'
|
sh_safe 'defaults write ApplePressAndHoldEnabled -bool false'
|
||||||
sh_safe 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true'
|
|
||||||
sh_safe 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
|
|
||||||
sh_safe 'defaults write com.apple.dock autohide -bool true'
|
|
||||||
|
|
||||||
# Disable app quarantine
|
sh_safe 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3'
|
||||||
sh_safe 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
|
sh_safe 'defaults write NSGlobalDomain AppleFontSmoothing -int 2'
|
||||||
|
sh_safe 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true'
|
||||||
|
sh_safe 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
|
||||||
|
sh_safe 'defaults write com.apple.dock autohide -bool true'
|
||||||
|
|
||||||
# Disable auto-correct
|
# Disable app quarantine
|
||||||
sh_safe 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
|
sh_safe 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
|
||||||
|
|
||||||
# Avoid creating .DS_Store files on network volumes
|
# Disable auto-correct
|
||||||
sh_safe 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
|
sh_safe 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
|
||||||
# Disable the warning when changing a file extension
|
|
||||||
sh_safe 'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false'
|
|
||||||
|
|
||||||
sh_safe 'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true'
|
# Avoid creating .DS_Store files on network volumes
|
||||||
|
sh_safe 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
|
||||||
|
# Disable the warning when changing a file extension
|
||||||
|
sh_safe 'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false'
|
||||||
|
|
||||||
# Disable local Time Machine backups
|
sh_safe 'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true'
|
||||||
# sh_safe 'hash_safe tmutil &> /dev/null && sudo tmutil disablelocal'
|
|
||||||
|
|
||||||
# Finder: allow text selection in Quick Look
|
# Disable local Time Machine backups
|
||||||
sh_safe 'defaults write com.apple.finder QLEnableTextSelection -bool true'
|
# sh_safe 'hash_safe tmutil &> /dev/null && sudo tmutil disablelocal'
|
||||||
|
|
||||||
# When performing a search, search the current folder by default
|
# Finder: allow text selection in Quick Look
|
||||||
sh_safe 'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"'
|
sh_safe 'defaults write com.apple.finder QLEnableTextSelection -bool true'
|
||||||
|
|
||||||
# Use column view
|
# When performing a search, search the current folder by default
|
||||||
sh_safe 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"'
|
sh_safe 'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"'
|
||||||
|
|
||||||
sh_safe 'defaults write com.apple.finder ShowStatusBar -bool true'
|
# Use column view
|
||||||
sh_safe 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
|
sh_safe 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"'
|
||||||
|
|
||||||
sh_safe 'killall Finder'
|
sh_safe 'defaults write com.apple.finder ShowStatusBar -bool true'
|
||||||
sh_safe 'killall Dock'
|
sh_safe 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
|
||||||
|
|
||||||
|
sh_safe 'killall Finder'
|
||||||
|
sh_safe 'killall Dock'
|
||||||
end
|
end
|
||||||
|
|
73
rake/pkg/package.rake
Normal file
73
rake/pkg/package.rake
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
require_relative "../lib/package"
|
||||||
|
|
||||||
|
if is_mac?
|
||||||
|
|
||||||
|
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
|
||||||
|
%w{
|
||||||
|
coreutils
|
||||||
|
wget
|
||||||
|
curl
|
||||||
|
tree
|
||||||
|
git
|
||||||
|
the_silver_searcher
|
||||||
|
tmux
|
||||||
|
gist
|
||||||
|
lua
|
||||||
|
luajit
|
||||||
|
readline
|
||||||
|
openssl
|
||||||
|
node
|
||||||
|
}.each { |pkg| Package.install pkg }
|
||||||
|
|
||||||
|
%w{
|
||||||
|
dropbox
|
||||||
|
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
|
||||||
|
|
||||||
|
desc "Remove homebrew cleanly"
|
||||||
|
task :remove do
|
||||||
|
Package.destroy if Package.installed?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
elsif is_linux?
|
||||||
|
|
||||||
|
namespace :aptitude do
|
||||||
|
task :setup do
|
||||||
|
# TODO Setup default linux package
|
||||||
|
end
|
||||||
|
|
||||||
|
task :update => 'aptitude:setup' do
|
||||||
|
echo "Updating packages..."
|
||||||
|
Package.update
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
54
rake/pkg/pyenv.rake
Normal file
54
rake/pkg/pyenv.rake
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
desc "Install/update pyenv & all pythons"
|
||||||
|
task :pyenv => 'pyenv:update'
|
||||||
|
|
||||||
|
namespace :pyenv do
|
||||||
|
task :install do
|
||||||
|
unless pyenv_installed?
|
||||||
|
echo "Installing pyenv"
|
||||||
|
if is_mac?
|
||||||
|
pyenv_reqs.each { |pkg| Package.install pkg }
|
||||||
|
elsif is_linux?
|
||||||
|
sh_safe "curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :update => "pyenv:install" do
|
||||||
|
pyenv_versions do |v|
|
||||||
|
echo "Updating python #{v}"
|
||||||
|
|
||||||
|
cmd = "pip"
|
||||||
|
cmd = "sudo #{cmd}" if v == "system"
|
||||||
|
|
||||||
|
sh_safe "PYENV_VERSION=#{v} #{cmd} freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs #{cmd} install -U"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Remove pyenv & installed pythons"
|
||||||
|
task :remove do
|
||||||
|
if pyenv_installed?
|
||||||
|
echo "pyenv isn't installed!"
|
||||||
|
else
|
||||||
|
echo "Deleting pyenv"
|
||||||
|
if is_mac?
|
||||||
|
pyenv_reqs.each { |pkg| Package.remove pkg }
|
||||||
|
elsif is_linux?
|
||||||
|
sh_safe "rm -rf $PYENV_ROOT"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
def pyenv_installed?
|
||||||
|
system("which pyenv")
|
||||||
|
end
|
||||||
|
|
||||||
|
def pyenv_versions
|
||||||
|
`ls -1 $PYENV_ROOT/versions`.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def pyenv_reqs
|
||||||
|
%w{pyenv pyenv-pip-rehash pyenv-virtualenv}
|
||||||
|
end
|
|
@ -1,31 +1,55 @@
|
||||||
require_relative '../lib/homebrew'
|
desc "Install/update rbenv & all rubies"
|
||||||
require_relative '../lib/rbenv'
|
|
||||||
|
|
||||||
task :rbenv => 'rbenv:update'
|
task :rbenv => 'rbenv:update'
|
||||||
|
|
||||||
namespace :rbenv do
|
namespace :rbenv do
|
||||||
|
task :install do
|
||||||
task :install do
|
unless rbenv_installed?
|
||||||
unless Rbenv.is_installed?
|
echo "Installing rbenv"
|
||||||
echo "Installing rbenv"
|
if is_mac?
|
||||||
Rbenv.bootstrap
|
rbenv_reqs.each { |pkg| Package.install pkg }
|
||||||
end
|
elsif is_linux?
|
||||||
|
sh_safe "curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task :remove do
|
task :update => "rbenv:install" do
|
||||||
if Rbenv.is_installed?
|
rbenv_versions do |v|
|
||||||
echo "rbenv isn't installed!"
|
echo "Updating ruby #{v}"
|
||||||
else
|
|
||||||
echo "Deleting rbenv"
|
cmd = "gem"
|
||||||
Rbenv.destroy
|
cmd = "sudo #{cmd}" if v == "system"
|
||||||
end
|
|
||||||
|
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} update"
|
||||||
|
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task :update => "rbenv:install" do
|
desc "Remove rbenv & installed rubies"
|
||||||
Rbenv.installed_versions.each do |v|
|
task :remove do
|
||||||
echo "Updating ruby #{v}"
|
if rbenv_installed?
|
||||||
Rbenv.update v
|
echo "rbenv isn't installed!"
|
||||||
end
|
else
|
||||||
|
echo "Deleting rbenv"
|
||||||
|
if is_mac?
|
||||||
|
rbenv_reqs.each { |pkg| Package.remove pkg }
|
||||||
|
elsif is_linux?
|
||||||
|
sh_safe "rm -rf $RBENV_ROOT"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
def rbenv_installed?
|
||||||
|
system("which rbenv")
|
||||||
|
end
|
||||||
|
|
||||||
|
def rbenv_versions
|
||||||
|
`ls -1 $RBENV_ROOT/versions`.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def rbenv_reqs
|
||||||
|
%w{rbenv ruby-build rbenv-vars rbenv-gem-rehash}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,40 @@
|
||||||
require_relative "../lib/output"
|
|
||||||
require_relative "../lib/homebrew"
|
|
||||||
require_relative "../lib/sh"
|
|
||||||
|
|
||||||
desc "Ensure vim/macvim is installed and up to date"
|
desc "Ensure vim/macvim is installed and up to date"
|
||||||
task :vim => "vim:update"
|
task :vim => "vim:update"
|
||||||
|
|
||||||
namespace :vim do
|
namespace :vim do
|
||||||
|
|
||||||
task :install do
|
task :install do
|
||||||
%w{lua luajit}.each { |pkg| Homebrew.install pkg }
|
vim_path = File.expand_path("~/.vim")
|
||||||
%w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') }
|
|
||||||
|
|
||||||
unless Dir.exists? (File.expand_path("~/.vim"))
|
if is_mac?
|
||||||
github('hlissner/vim', '~/.vim')
|
Package.install "lua"
|
||||||
github('Shougo/neobundle.vim', '~/.vim/bundle/neobundle.vim')
|
%w{vim macvim}.each { |pkg| Package.install "#{pkg} --with-lua --with-luajit" }
|
||||||
|
elsif is_linux?
|
||||||
|
Package.install "lua5.2"
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,19 +42,25 @@ namespace :vim do
|
||||||
path = File.expand_path("~/.vim")
|
path = File.expand_path("~/.vim")
|
||||||
|
|
||||||
echo "Updating vim"
|
echo "Updating vim"
|
||||||
sh "cd #{path} && git pull"
|
sh_safe "cd #{path} && git pull"
|
||||||
|
|
||||||
echo "Updating vim plugins"
|
echo "Updating vim plugins"
|
||||||
Dir.glob("#{path}/bundle/*") do |f|
|
Dir.glob("#{path}/bundle/*") do |f|
|
||||||
echo ":: Updating #{File.basename(f)}:"
|
echo ":: Updating #{File.basename(f)}:"
|
||||||
sh_safe "cd #{f} && git pull"
|
sh_safe "cd #{f} && git pull"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is_linux?
|
||||||
|
echo "Can't update compiled vim itself! Use pkg:vim:install"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Remove vim"
|
desc "Remove vim"
|
||||||
task :remove do
|
task :remove do
|
||||||
echo "Uninstalling vim"
|
if is_mac?
|
||||||
%w{vim macvim}.each { |pkg| Homebrew.remove pkg }
|
echo "Uninstalling vim"
|
||||||
|
Package.remove "vim"
|
||||||
|
Package.remove "macvim"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,29 +5,26 @@ desc "Ensure zsh and oh-my-zsh is installed and set"
|
||||||
task :zsh => 'zsh:update'
|
task :zsh => 'zsh:update'
|
||||||
|
|
||||||
namespace :zsh do
|
namespace :zsh do
|
||||||
|
task :install do
|
||||||
task :install do
|
unless Dir.exists?(File.expand_path("~/.zprezto"))
|
||||||
unless Dir.exists?(File.expand_path("~/.zprezto"))
|
echo "Installing prezto"
|
||||||
echo "Installing prezto"
|
github 'hlissner/prezto', '~/.zprezto'
|
||||||
github 'hlissner/prezto', '~/.zprezto'
|
|
||||||
end
|
|
||||||
sh_safe '~/.dotfiles/install.sh'
|
|
||||||
|
|
||||||
unless `printenv SHELL | grep "/bin/zsh"`
|
|
||||||
echo "Setting shell to zsh"
|
|
||||||
sh_safe "chsh -s /bin/zsh"
|
|
||||||
sh_safe "exec /bin/zsh -l"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
sh_safe '~/.dotfiles/install.sh'
|
||||||
|
|
||||||
task :update => "zsh:install" do
|
unless `printenv SHELL | grep "/bin/zsh"`
|
||||||
echo "Updating zprezto"
|
echo "Setting shell to zsh"
|
||||||
sh_safe 'cd ~/.zprezto && git pull'
|
sh_safe "chsh -s /bin/zsh"
|
||||||
# TODO: pull from parent repo
|
sh_safe "exec /bin/zsh -l"
|
||||||
end
|
|
||||||
|
|
||||||
task :remove do
|
|
||||||
sh_safe 'rm -rf ~/.zprezto' if Dir.exists?(File.expand_path("~/.zprezto"))
|
|
||||||
end
|
end
|
||||||
|
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?(File.expand_path("~/.zprezto"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
18
rake/provision.rake
Normal file
18
rake/provision.rake
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
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
|
|
@ -1,16 +0,0 @@
|
||||||
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
|
|
Loading…
Reference in a new issue