Commit a2d6ec482e4715707cd6c1904b0843c129c922d1

Authored by Jianwei Han
1 parent 42c5acab4d
Exists in master

Fix problems for Homebrew in standard location

Showing 8 changed files with 24 additions and 39 deletions Inline Diff

# This file manages Puppet module dependencies. 1 1 # This file manages Puppet module dependencies.
# 2 2 #
# It works a lot like Bundler. We provide some core modules by 3 3 # It works a lot like Bundler. We provide some core modules by
# default. This ensures at least the ability to construct a basic 4 4 # default. This ensures at least the ability to construct a basic
# environment. 5 5 # environment.
6 6
# Shortcut for a module from GitHub's boxen organization 7 7 # Shortcut for a module from GitHub's boxen organization
def github(name, *args) 8 8 def github(name, *args)
options ||= if args.last.is_a? Hash 9 9 options ||= if args.last.is_a? Hash
args.last 10 10 args.last
else 11 11 else
{} 12 12 {}
end 13 13 end
14 14
if path = options.delete(:path) 15 15 if path = options.delete(:path)
mod name, :path => path 16 16 mod name, :path => path
else 17 17 else
version = args.first 18 18 version = args.first
options[:repo] ||= "boxen/puppet-#{name}" 19 19 options[:repo] ||= "boxen/puppet-#{name}"
mod name, version, :github_tarball => options[:repo] 20 20 mod name, version, :github_tarball => options[:repo]
end 21 21 end
end 22 22 end
23 23
# Shortcut for a module under development 24 24 # Shortcut for a module under development
def dev(name, *args) 25 25 def dev(name, *args)
mod name, :path => "#{ENV['HOME']}/src/boxen/puppet-#{name}" 26 26 mod name, :path => "#{ENV['HOME']}/src/boxen/puppet-#{name}"
end 27 27 end
28 28
# Includes many of our custom types and providers, as well as global 29 29 # Includes many of our custom types and providers, as well as global
# config. Required. 30 30 # config. Required.
31 31
github "boxen", "3.6.1" 32 32 github "boxen", "3.6.3.rc", :repo => "hanjianwei/puppet-boxen"
33 33
# Support for default hiera data in modules 34 34 # Support for default hiera data in modules
35 35
github "module-data", "0.0.3", :repo => "ripienaar/puppet-module-data" 36 36 github "module-data", "0.0.3", :repo => "ripienaar/puppet-module-data"
37 37
# Core modules for a basic development environment. You can replace 38 38 # Core modules for a basic development environment. You can replace
# some/most of these if you want, but it's not recommended. 39 39 # some/most of these if you want, but it's not recommended.
40 40
github "dnsmasq", "1.0.1" 41
github "gcc", "2.0.101" 42
github "git", "2.4.0" 43 41 github "git", "2.4.0"
github "homebrew", "1.9.5.rc", :repo => "hanjianwei/puppet-homebrew" 44 42 github "homebrew", "1.9.5.rc", :repo => "hanjianwei/puppet-homebrew"
github "hub", "1.3.0" 45 43 github "hub", "1.3.0"
github "inifile", "1.0.3", :repo => "puppetlabs/puppetlabs-inifile" 46 44 github "inifile", "1.0.3", :repo => "puppetlabs/puppetlabs-inifile"
github "nginx", "1.4.3" 47
github "nodejs", "3.7.0" 48 45 github "nodejs", "3.7.0"
github "openssl", "1.0.0" 49 46 github "openssl", "1.0.0"
github "pkgconfig", "1.0.0" 50 47 github "pkgconfig", "1.0.0"
github "repository", "2.3.0" 51 48 github "repository", "2.3.0"
github "ruby", "8.0.4" 52 49 github "ruby", "8.0.4"
github "stdlib", "4.2.1", :repo => "puppetlabs/puppetlabs-stdlib" 53 50 github "stdlib", "4.2.1", :repo => "puppetlabs/puppetlabs-stdlib"
github "sudo", "1.0.0" 54 51 github "sudo", "1.0.0"
GITHUBTARBALL 1 1 GITHUBTARBALL
remote: boxen/puppet-boxen 2
specs: 3
boxen (3.6.1) 4
5
GITHUBTARBALL 6
remote: boxen/puppet-dnsmasq 7
specs: 8
dnsmasq (1.0.1) 9
10
GITHUBTARBALL 11
remote: boxen/puppet-gcc 12
specs: 13
gcc (2.0.101) 14
15
GITHUBTARBALL 16
remote: boxen/puppet-git 17 2 remote: boxen/puppet-git
specs: 18 3 specs:
git (2.4.0) 19 4 git (2.4.0)
20 5
GITHUBTARBALL 21 6 GITHUBTARBALL
remote: boxen/puppet-hub 22 7 remote: boxen/puppet-hub
specs: 23 8 specs:
hub (1.3.0) 24 9 hub (1.3.0)
25 10
GITHUBTARBALL 26 11 GITHUBTARBALL
remote: boxen/puppet-nginx 27
specs: 28
nginx (1.4.3) 29
30
GITHUBTARBALL 31
remote: boxen/puppet-nodejs 32 12 remote: boxen/puppet-nodejs
specs: 33 13 specs:
nodejs (3.7.0) 34 14 nodejs (3.7.0)
35 15
GITHUBTARBALL 36 16 GITHUBTARBALL
remote: boxen/puppet-openssl 37 17 remote: boxen/puppet-openssl
specs: 38 18 specs:
openssl (1.0.0) 39 19 openssl (1.0.0)
40 20
GITHUBTARBALL 41 21 GITHUBTARBALL
remote: boxen/puppet-osx 42 22 remote: boxen/puppet-osx
specs: 43 23 specs:
osx (2.7.0) 44 24 osx (2.7.0)
45 25
GITHUBTARBALL 46 26 GITHUBTARBALL
remote: boxen/puppet-pkgconfig 47 27 remote: boxen/puppet-pkgconfig
specs: 48 28 specs:
pkgconfig (1.0.0) 49 29 pkgconfig (1.0.0)
50 30
GITHUBTARBALL 51 31 GITHUBTARBALL
remote: boxen/puppet-repository 52 32 remote: boxen/puppet-repository
specs: 53 33 specs:
repository (2.3.0) 54 34 repository (2.3.0)
55 35
GITHUBTARBALL 56 36 GITHUBTARBALL
remote: boxen/puppet-ruby 57 37 remote: boxen/puppet-ruby
specs: 58 38 specs:
ruby (8.0.4) 59 39 ruby (8.0.4)
60 40
GITHUBTARBALL 61 41 GITHUBTARBALL
remote: boxen/puppet-sudo 62 42 remote: boxen/puppet-sudo
specs: 63 43 specs:
sudo (1.0.0) 64 44 sudo (1.0.0)
65 45
GITHUBTARBALL 66 46 GITHUBTARBALL
remote: boxen/puppet-xquartz 67 47 remote: boxen/puppet-xquartz
specs: 68 48 specs:
xquartz (1.1.1) 69 49 xquartz (1.1.1)
70 50
GITHUBTARBALL 71 51 GITHUBTARBALL
remote: glarizza/puppet-property_list_key 72 52 remote: hanjianwei/puppet-boxen
specs: 73 53 specs:
property_list_key (0.2.1) 74 54 boxen (3.6.3.rc)
75 55
GITHUBTARBALL 76 56 GITHUBTARBALL
remote: hanjianwei/puppet-brewcask 77 57 remote: hanjianwei/puppet-brewcask
specs: 78 58 specs:
brewcask (0.0.4.rc2) 79 59 brewcask (0.0.4.rc2)
80 60
GITHUBTARBALL 81 61 GITHUBTARBALL
remote: hanjianwei/puppet-dotfiles 82 62 remote: hanjianwei/puppet-dotfiles
specs: 83 63 specs:
dotfiles (0.0.6) 84 64 dotfiles (0.0.9)
85 65
GITHUBTARBALL 86 66 GITHUBTARBALL
remote: hanjianwei/puppet-homebrew 87 67 remote: hanjianwei/puppet-homebrew
specs: 88 68 specs:
homebrew (1.9.5.rc) 89 69 homebrew (1.9.5.rc)
90 70
GITHUBTARBALL 91 71 GITHUBTARBALL
remote: puppetlabs/puppetlabs-inifile 92 72 remote: puppetlabs/puppetlabs-inifile
specs: 93 73 specs:
inifile (1.0.3) 94 74 inifile (1.0.3)
95 75
GITHUBTARBALL 96 76 GITHUBTARBALL
remote: puppetlabs/puppetlabs-stdlib 97 77 remote: puppetlabs/puppetlabs-stdlib
specs: 98 78 specs:
stdlib (4.2.1) 99 79 stdlib (4.2.1)
100 80
GITHUBTARBALL 101 81 GITHUBTARBALL
remote: ripienaar/puppet-module-data 102 82 remote: ripienaar/puppet-module-data
specs: 103 83 specs:
module-data (0.0.3) 104 84 module-data (0.0.3)
105 85
DEPENDENCIES 106 86 DEPENDENCIES
boxen (= 3.6.1) 107 87 boxen (= 3.6.3.rc)
brewcask (= 0.0.4.rc2) 108 88 brewcask (= 0.0.4.rc2)
dnsmasq (= 1.0.1) 109 89 dotfiles (= 0.0.9)
dotfiles (= 0.0.6) 110
gcc (= 2.0.101) 111
# This file will be loaded by config/basic early in a Boxen run. Use 1 1 # This file will be loaded by config/basic early in a Boxen run. Use
# it to provide any custom code or behavior your Boxen setup requires. 2 2 # it to provide any custom code or behavior your Boxen setup requires.
3 3
# Change the prefix boxen is installed to. 4 4 # Change the prefix boxen is installed to.
# ENV['BOXEN_HOME'] = '/opt/boxen' 5 5 # ENV['BOXEN_HOME'] = '/opt/boxen'
6 6
# Change the repo boxen will use. 7 7 # Change the repo boxen will use.
# ENV['BOXEN_REPO_NAME'] = 'boxen/our-boxen' 8 8 # ENV['BOXEN_REPO_NAME'] = 'boxen/our-boxen'
9 9
# Boxen binary packaging 10 10 # Boxen binary packaging
# ENV["BOXEN_S3_ACCESS_KEY"] = '' 11 11 # ENV["BOXEN_S3_ACCESS_KEY"] = ''
# ENV["BOXEN_S3_SECRET_KEY"] = '' 12 12 # ENV["BOXEN_S3_SECRET_KEY"] = ''
# ENV["BOXEN_S3_BUCKET"] = '' 13 13 # ENV["BOXEN_S3_BUCKET"] = ''
14 14
# Auto-report issues on failed runs 15 15 # Auto-report issues on failed runs
# ENV["BOXEN_ISSUES_ENABLED"] = 'yes' 16 16 # ENV["BOXEN_ISSUES_ENABLED"] = 'yes'
17 17
# Submit audit data to an arbitrary HTTP endpoint 18 18 # Submit audit data to an arbitrary HTTP endpoint
# ENV["BOXEN_WEB_HOOK_URL"] = 'https://some-uri.com/boxen' 19 19 # ENV["BOXEN_WEB_HOOK_URL"] = 'https://some-uri.com/boxen'
# 20 20 #
# required for Github Enterprise 21 21 # required for Github Enterprise
# ENV["BOXEN_GITHUB_ENTERPRISE_URL"] = 'https://github.yourdomain.com' 22 22 # ENV["BOXEN_GITHUB_ENTERPRISE_URL"] = 'https://github.yourdomain.com'
23 23
# required for Github Enterprise (defaults to "https://github.com/%s") 24 24 # required for Github Enterprise (defaults to "https://github.com/%s")
# ENV['BOXEN_REPO_URL_TEMPLATE'] = 'https://github.yourdomain.com/%s' 25 25 # ENV['BOXEN_REPO_URL_TEMPLATE'] = 'https://github.yourdomain.com/%s'
26
27 # Setup config for Homebrew
28 require 'fileutils'
hiera/users/hanjianwei.yaml
ruby::global::version: "2.1.2" 1 1 ruby::global::version: "2.1.2"
nodejs::global::version: "v0.10" 2 2 nodejs::global::version: "v0.10"
3 boxen::config::homebrewdir: "/usr/local"
require boxen::environment 1 1 require boxen::environment
require homebrew 2 2 require homebrew
3 3
Exec { 4 4 Exec {
group => 'staff', 5 5 group => 'staff',
logoutput => on_failure, 6 6 logoutput => on_failure,
user => $boxen_user, 7 7 user => $boxen_user,
8 8
path => [ 9 9 path => [
"${boxen::config::home}/rbenv/shims", 10 10 "${boxen::config::home}/rbenv/shims",
"${boxen::config::home}/rbenv/bin", 11 11 "${boxen::config::home}/rbenv/bin",
"${boxen::config::home}/rbenv/plugins/ruby-build/bin", 12 12 "${boxen::config::home}/rbenv/plugins/ruby-build/bin",
"${boxen::config::home}/homebrew/bin", 13 13 "/usr/local/bin",
'/usr/bin', 14 14 '/usr/bin',
'/bin', 15 15 '/bin',
'/usr/sbin', 16 16 '/usr/sbin',
'/sbin' 17 17 '/sbin'
], 18 18 ],
19 19
environment => [ 20 20 environment => [
"HOMEBREW_CACHE=${homebrew::config::cachedir}", 21 21 "HOMEBREW_CACHE=${homebrew::config::cachedir}",
"HOME=/Users/${::boxen_user}" 22 22 "HOME=/Users/${::boxen_user}"
] 23 23 ]
} 24 24 }
25 25
File { 26 26 File {
group => 'staff', 27 27 group => 'staff',
owner => $boxen_user 28 28 owner => $boxen_user
} 29 29 }
30 30
Package { 31 31 Package {
provider => homebrew, 32 32 provider => homebrew,
require => Class['homebrew'] 33 33 require => Class['homebrew']
} 34 34 }
35 35
Repository { 36 36 Repository {
provider => git, 37 37 provider => git,
extra => [ 38 38 extra => [
'--recurse-submodules' 39 39 '--recurse-submodules'
], 40 40 ],
require => File["${boxen::config::bindir}/boxen-git-credential"], 41 41 require => File["${boxen::config::bindir}/boxen-git-credential"],
config => { 42 42 config => {
'credential.helper' => "${boxen::config::bindir}/boxen-git-credential" 43 43 'credential.helper' => "${boxen::config::bindir}/boxen-git-credential"
} 44 44 }
} 45 45 }
46 46
Service { 47 47 Service {
provider => ghlaunchd 48 48 provider => ghlaunchd
} 49 49 }
50 50
Homebrew::Formula <| |> -> Package <| |> 51 51 Homebrew::Formula <| |> -> Package <| |>
52 52
node default { 53 53 node default {
# core modules, needed for most things 54 54 # core modules, needed for most things
include git 55 55 include git
include hub 56 56 include hub
57 57
# fail if FDE is not enabled 58 58 # fail if FDE is not enabled
if $::root_encrypted == 'no' { 59 59 if $::root_encrypted == 'no' {
fail('Please enable full disk encryption and try again') 60 60 fail('Please enable full disk encryption and try again')
} 61 61 }
62 62
# node versions 63 63 # node versions
include nodejs::v0_10 64 64 include nodejs::v0_10
modules/people/manifests/hanjianwei/applications.pp
class people::hanjianwei::applications { 1 1 class people::hanjianwei::applications {
2 2
# Declare all Homebrew packages 3 3 # Declare all Homebrew packages
package { ['ack', 4 4 package { ['ack',
'qt5', 5 5 'qt5',
'reattach-to-user-namespace', 6 6 'reattach-to-user-namespace',
'tmux', 7 7 'tmux',
'vim', 8
'wget']: 9 8 'wget']:
9 }
10
11 package { 'vim':
12 install_options => ['--override-system-vi'],
} 10 13 }
11 14
homebrew::tap { 'homebrew/science': } 12 15 homebrew::tap { 'homebrew/science': }
-> 13 16 ->
package { 'opencv': } 14 17 package { 'opencv': }
15 18
# Declare all Homebrew Cask packages 16 19 # Declare all Homebrew Cask packages
include brewcask 17 20 include brewcask
18 21
package { ['acorn', 19 22 package { ['acorn',
'alfred', 20 23 'alfred',
'atom', 21 24 'atom',
'bettertouchtool', 22 25 'bettertouchtool',
'caffeine', 23 26 'caffeine',
'cleanmymac', 24 27 'cleanmymac',
'dropbox', 25 28 'dropbox',
'evernote', 26 29 'evernote',
'fantastical', 27 30 'fantastical',
'firefox', 28 31 'firefox',
'google-chrome', 29 32 'google-chrome',
'hazel', 30 33 'hazel',
'iterm2', 31 34 'iterm2',
'karabiner', 32 35 'karabiner',
'keyboard-maestro', 33 36 'keyboard-maestro',
'mactex', 34 37 'mactex',
'omnifocus', 35 38 'omnifocus',
'onepassword', 36 39 'onepassword',
'parallels', 37 40 'parallels',
'pycharm-ce', 38 41 'pycharm-ce',
'scapple', 39 42 'scapple',
'screenflow', 40 43 'screenflow',
'scrivener', 41 44 'scrivener',
'seil', 42 45 'seil',
'shiori', 43 46 'shiori',
'trim-enabler', 44 47 'trim-enabler',
'qq', 45 48 'qq',
'qt-creator', 46 49 'qt-creator',
'vagrant', 47 50 'vagrant',
'virtualbox', 48 51 'virtualbox',
'welly', 49 52 'welly',
'xmind']: 50 53 'xmind']:
provider => 'brewcask' 51 54 provider => 'brewcask'
} 52 55 }
53 56
# Taps 54 57 # Taps
homebrew::tap { 'hanjianwei/apps': } 55 58 homebrew::tap { 'hanjianwei/apps': }
-> 56 59 ->
package { 'squirrel': 57 60 package { 'squirrel':
provider => 'brewcask' 58 61 provider => 'brewcask'
} 59 62 }
60 63
homebrew::tap { 'caskroom/fonts': } 61 64 homebrew::tap { 'caskroom/fonts': }
-> 62 65 ->
package { ['font-anonymous-pro', 63 66 package { ['font-anonymous-pro',
'font-dejavu-sans', 64 67 'font-dejavu-sans',
'font-dejavu-sans-mono-for-powerline', 65 68 'font-dejavu-sans-mono-for-powerline',
'font-inconsolata-dz-for-powerline', 66 69 'font-inconsolata-dz-for-powerline',
'font-inconsolata-for-powerline', 67 70 'font-inconsolata-for-powerline',
'font-sauce-code-powerline', 68 71 'font-sauce-code-powerline',
'font-source-code-pro', 69 72 'font-source-code-pro',
'font-source-sans-pro', 70 73 'font-source-sans-pro',
'font-source-serif-pro', 71 74 'font-source-serif-pro',
'font-terminus', 72 75 'font-terminus',
'font-ubuntu-mono-powerline']: 73 76 'font-ubuntu-mono-powerline']:
provider => 'brewcask' 74 77 provider => 'brewcask'
} 75 78 }
76 79
homebrew::tap { 'caskroom/versions': } 77 80 homebrew::tap { 'caskroom/versions': }
-> 78 81 ->
package { 'intellij-idea-ultimate12': 79 82 package { 'intellij-idea-ultimate12':
provider => 'brewcask' 80 83 provider => 'brewcask'
} 81 84 }
82 85
homebrew::tap { 'railwaycat/emacsmacport': } 83 86 homebrew::tap { 'railwaycat/emacsmacport': }
-> 84 87 ->
package { 'emacs-mac': 85 88 package { 'emacs-mac':
provider => 'brewcask' 86 89 provider => 'brewcask'
} 87 90 }
88 91
# Apps configuration 89 92 # Apps configuration
Package <| |> -> Dotfiles::Deploy <| |> 90 93 Package <| |> -> Dotfiles::Deploy <| |>
91 94
osx_chsh { $boxen_user: 92 95 osx_chsh { $boxen_user:
shell => '/bin/zsh' 93 96 shell => '/bin/zsh'
} 94 97 }
95 98
dotfiles::deploy { ['atom', 96 99 dotfiles::deploy { ['atom',
'bettertouchtool', 97 100 'bettertouchtool',
'emacs', 98 101 'emacs',
'git', 99 102 'git',
'iterm2', 100 103 'iterm2',
script/boxen-git-credential
#!/usr/bin/ruby 1 1 #!/usr/bin/ruby
# Provide git credentials using Boxen's config. 2 2 # Provide git credentials using Boxen's config.
3 3
unless command = ARGV[0] 4 4 unless command = ARGV[0]
this = File.basename $0 5 5 this = File.basename $0
abort "Usage: #{this} <get|store|erase>" 6 6 abort "Usage: #{this} <get|store|erase>"
end 7 7 end
8 8
require "pathname" 9 9 require "pathname"
10 10
# It's a UTF-8, UTF-8, UTF-8 world. 11 11 # It's a UTF-8, UTF-8, UTF-8 world.
12 12
Encoding.default_external = Encoding::UTF_8 if RUBY_VERSION > "1.9" 13 13 Encoding.default_external = Encoding::UTF_8 if RUBY_VERSION > "1.9"
14 14
# Put us where we belong, in the root dir of our boxen repo. 15 15 # Put us where we belong, in the root dir of our boxen repo.
16 16
Dir.chdir Pathname.new(__FILE__).realpath + "../.." 17 17 Dir.chdir Pathname.new(__FILE__).realpath + "../.."
18 18
# Because we can be called from inside other Ruby processes, unset any 19 19 # Because we can be called from inside other Ruby processes, unset any
# `BUNDLE_` environment variables. 20 20 # `BUNDLE_` environment variables.
21 21
ENV.keys.select { |k| /^BUNDLE_/i }.each { |k| ENV.delete k } 22 22 ENV.keys.select { |k| /^BUNDLE_/i }.each { |k| ENV.delete k }
23 23
# Set up our local configuration, deps, and load path. 24 24 # Set up our local configuration, deps, and load path.
25 25
load "config/basic.rb" 26 26 load "config/basic.rb"
require "boxen/config" 27 27 require "boxen/config"
28 28
config = Boxen::Config.load 29 29 config = Boxen::Config.load
input = $stdin.read 30 30 input = $stdin.read
attrs = Hash[input.split($/).map { |l| l.split("=") }] 31 31 attrs = Hash[input.split($/).map { |l| l.split("=") }]
# find GitHub or GitHub Enterprise host 32 32 # find GitHub or GitHub Enterprise host
ghhost = URI(config.ghurl).host 33 33 ghhost = URI(config.ghurl).host
34 34
host_exp = Regexp.new "(^|\.)" + Regexp.escape(ghhost) 35 35 host_exp = Regexp.new "(^|\.)" + Regexp.escape(ghhost)
if command == "get" && host_exp.match(attrs["host"]) 36 36 if command == "get" && host_exp.match(attrs["host"])
puts "username=#{config.token}" 37 37 puts "username=#{config.token}"
puts "password=x-oauth-basic" 38 38 puts "password=x-oauth-basic"
#!/usr/bin/ruby 1 1 #!/usr/bin/ruby
# Sync binary snapshots to S3. 2 2 # Sync binary snapshots to S3.
3 3
require "pathname" 4 4 require "pathname"
require "tempfile" 5 5 require "tempfile"
6 6
# Put us where we belong, in the root dir of our boxen repo. 7 7 # Put us where we belong, in the root dir of our boxen repo.
8 8
Dir.chdir Pathname.new(__FILE__).realpath + "../.." 9 9 Dir.chdir Pathname.new(__FILE__).realpath + "../.."
10 10
# Make sure our local dependencies are up to date. 11 11 # Make sure our local dependencies are up to date.
12 12
abort "Sorry, can't bootstrap." unless system "script/bootstrap" 13 13 abort "Sorry, can't bootstrap." unless system "script/bootstrap"
14 14
# Set up our local configuration, deps, and load path. 15 15 # Set up our local configuration, deps, and load path.
16 16
load "config/basic.rb" 17 17 load "config/basic.rb"
18 18
require "aws-sdk" 19 19 require "aws-sdk"
require "boxen/config" 20 20 require "boxen/config"
21 21
access_key = ENV["BOXEN_S3_ACCESS_KEY"] 22 22 access_key = ENV["BOXEN_S3_ACCESS_KEY"]
secret_key = ENV["BOXEN_S3_SECRET_KEY"] 23 23 secret_key = ENV["BOXEN_S3_SECRET_KEY"]
bucket_name = ENV["BOXEN_S3_BUCKET"] 24 24 bucket_name = ENV["BOXEN_S3_BUCKET"]
25 25
unless access_key && secret_key && bucket_name 26 26 unless access_key && secret_key && bucket_name
abort "Please set the BOXEN_S3_{ACCESS_KEY,SECRET_KEY,BUCKET} env vars." 27 27 abort "Please set the BOXEN_S3_{ACCESS_KEY,SECRET_KEY,BUCKET} env vars."
end 28 28 end
29 29
s3 = AWS::S3.new :access_key_id => access_key, :secret_access_key => secret_key 30 30 s3 = AWS::S3.new :access_key_id => access_key, :secret_access_key => secret_key
os = `sw_vers -productVersion`.strip.split(".")[0..1].join "." 31 31 os = `sw_vers -productVersion`.strip.split(".")[0..1].join "."
32 32
bucket = s3.buckets[bucket_name] 33 33 bucket = s3.buckets[bucket_name]
config = Boxen::Config.load 34 34 config = Boxen::Config.load
35 35
# Sync Homebrew packages. 36 36 # Sync Homebrew packages.
37 37
Dir.chdir "#{config.homedir}/homebrew/Cellar" do 38 38 Dir.chdir "/usr/local/Cellar" do
Dir["*/*"].each do |dir| 39 39 Dir["*/*"].each do |dir|
name, version = File.split dir 40 40 name, version = File.split dir
41 41
file = "homebrew/#{os}/#{name}-#{version}.tar.bz2" 42 42 file = "homebrew/#{os}/#{name}-#{version}.tar.bz2"
temp = Tempfile.new "homebrew" 43 43 temp = Tempfile.new "homebrew"
obj = bucket.objects[file] 44 44 obj = bucket.objects[file]
45 45
next if obj.exists? 46 46 next if obj.exists?
47 47
printf "Snapshotting #{name} #{version}... " 48 48 printf "Snapshotting #{name} #{version}... "
$stdout.flush 49 49 $stdout.flush
50 50
system "tar", "-cjf", temp.path, dir 51 51 system "tar", "-cjf", temp.path, dir
puts "done." 52 52 puts "done."
53 53
printf "Shipping #{name} #{version} to S3... " 54 54 printf "Shipping #{name} #{version} to S3... "
$stdout.flush 55 55 $stdout.flush
56 56
obj.write :acl => :public_read, :file => temp.path 57 57 obj.write :acl => :public_read, :file => temp.path
puts "done." 58 58 puts "done."
end 59 59 end
end 60 60 end
61 61
# Sync rbenv rubies. 62 62 # Sync rbenv rubies.
63 63
Dir.chdir "#{config.homedir}/rbenv/versions" do 64 64 Dir.chdir "#{config.homedir}/rbenv/versions" do
Dir["*"].each do |dir| 65 65 Dir["*"].each do |dir|
next if File.symlink? dir 66 66 next if File.symlink? dir
67 67
version = File.basename dir 68 68 version = File.basename dir
file = "rbenv/#{os}/#{version}.tar.bz2" 69 69 file = "rbenv/#{os}/#{version}.tar.bz2"
temp = Tempfile.new "rbenv" 70 70 temp = Tempfile.new "rbenv"
obj = bucket.objects[file] 71 71 obj = bucket.objects[file]
72 72
next if obj.exists? 73 73 next if obj.exists?
74 74
printf "Snapshotting ruby #{version}... " 75 75 printf "Snapshotting ruby #{version}... "
$stdout.flush 76 76 $stdout.flush
77 77
system "tar -cjf #{temp.path} #{version}" 78 78 system "tar -cjf #{temp.path} #{version}"
puts "done." 79 79 puts "done."