Commit 966c19f70b02e2395d0ea1ba7260c305dce61eef
1 parent
553c2e33d0
Update for script/sync
Showing 11 changed files with 142 additions and 3 deletions Side-by-side Diff
Gemfile
Gemfile.lock
| ... | ... | @@ -3,6 +3,11 @@ |
| 3 | 3 | specs: |
| 4 | 4 | addressable (2.3.2) |
| 5 | 5 | ansi (1.4.3) |
| 6 | + aws-sdk (1.6.9) | |
| 7 | + httparty (~> 0.7) | |
| 8 | + json (~> 1.4) | |
| 9 | + nokogiri (>= 1.4.4) | |
| 10 | + uuidtools (~> 2.1) | |
| 6 | 11 | boxen (0.4.0) |
| 7 | 12 | ansi (~> 1.4) |
| 8 | 13 | hiera (~> 1.0.0) |
| 9 | 14 | |
| 10 | 15 | |
| ... | ... | @@ -19,13 +24,19 @@ |
| 19 | 24 | hashie (1.2.0) |
| 20 | 25 | hiera (1.0.0) |
| 21 | 26 | highline (1.6.15) |
| 27 | + httparty (0.9.0) | |
| 28 | + multi_json (~> 1.0) | |
| 29 | + multi_xml | |
| 30 | + json (1.7.5) | |
| 22 | 31 | json_pure (1.7.5) |
| 23 | 32 | librarian-puppet (0.9.6) |
| 24 | 33 | json_pure |
| 25 | 34 | puppet |
| 26 | 35 | thor (~> 0.15) |
| 27 | 36 | multi_json (1.3.6) |
| 37 | + multi_xml (0.5.1) | |
| 28 | 38 | multipart-post (1.1.5) |
| 39 | + nokogiri (1.5.5) | |
| 29 | 40 | octokit (1.15.1) |
| 30 | 41 | addressable (~> 2.2) |
| 31 | 42 | faraday (~> 0.8) |
| 32 | 43 | |
| ... | ... | @@ -36,10 +47,12 @@ |
| 36 | 47 | facter (>= 1.6.11) |
| 37 | 48 | hiera (>= 1.0.0rc) |
| 38 | 49 | thor (0.16.0) |
| 50 | + uuidtools (2.1.3) | |
| 39 | 51 | |
| 40 | 52 | PLATFORMS |
| 41 | 53 | ruby |
| 42 | 54 | |
| 43 | 55 | DEPENDENCIES |
| 44 | - boxen (~> 0.1) | |
| 56 | + aws-sdk | |
| 57 | + boxen (~> 0.4) |
README.md
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | 1. Install XCode Command Line Tools and/or full XCode. |
| 12 | 12 | 1. Create a new repository on GitHub as your user for your Boxen. (eg. |
| 13 | -`wfarr/my-boxen`). **Make sure it is a private repository!** for now | |
| 13 | +`wfarr/my-boxen`). **Make sure it is a private repository!** | |
| 14 | 14 | 1. Get running like so: |
| 15 | 15 | ``` |
| 16 | 16 | mkdir -p ~/src/my-boxen |
| ... | ... | @@ -76,4 +76,9 @@ |
| 76 | 76 | For organization projects (read: repositories that people will be working in), please see the documentation in the projects module template we provide. |
| 77 | 77 | |
| 78 | 78 | For per-user configuration that doesn't need to be applied globally to everyone, please see the documentation in the people module template we provide. |
| 79 | + | |
| 80 | +## Binary packages | |
| 81 | + | |
| 82 | +We support binary packaging for everything in Homebrew, RBEnv, and NVM. | |
| 83 | +See `config/boxen.rb` for the environment variables to define. |
config/boxen.rb
script/sync
| 1 | +#!/usr/bin/ruby | |
| 2 | +# Sync binary snapshots to S3. | |
| 3 | + | |
| 4 | +require "pathname" | |
| 5 | +require "tempfile" | |
| 6 | + | |
| 7 | +# Put us where we belong, in the root dir of our boxen repo. | |
| 8 | + | |
| 9 | +Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |
| 10 | + | |
| 11 | +# Make sure our local dependencies are up to date. | |
| 12 | + | |
| 13 | +abort "Sorry, can't bootstrap." unless system "script/bootstrap" | |
| 14 | + | |
| 15 | +# Set up our local configuration, deps, and load path. | |
| 16 | + | |
| 17 | +load "config/basic.rb" | |
| 18 | + | |
| 19 | +require "aws-sdk" | |
| 20 | +require "boxen/config" | |
| 21 | + | |
| 22 | +access_key = ENV["BOXEN_S3_ACCESS_KEY"] | |
| 23 | +secret_key = ENV["BOXEN_S3_SECRET_KEY"] | |
| 24 | +bucket_name = ENV["BOXEN_S3_BUCKET"] | |
| 25 | + | |
| 26 | +unless access_key && secret_key && bucket_name | |
| 27 | + abort "Please set the BOXEN_S3_{ACCESS_KEY,SECRET_KEY,BUCKET} env vars." | |
| 28 | +end | |
| 29 | + | |
| 30 | +s3 = AWS::S3.new :access_key_id => access_key, :secret_access_key => secret_key | |
| 31 | +os = `sw_vers -productVersion`.strip.split(".")[0..1].join "." | |
| 32 | + | |
| 33 | +bucket = s3.buckets[bucket_name] | |
| 34 | +config = Boxen::Config.load | |
| 35 | + | |
| 36 | +# Sync Homebrew packages. | |
| 37 | + | |
| 38 | +Dir.chdir "#{config.homedir}/homebrew/Cellar" do | |
| 39 | + Dir["*/*"].each do |dir| | |
| 40 | + name, version = File.split dir | |
| 41 | + | |
| 42 | + file = "homebrew/#{os}/#{name}-#{version}.tar.bz2" | |
| 43 | + temp = Tempfile.new "homebrew" | |
| 44 | + obj = bucket.objects[file] | |
| 45 | + | |
| 46 | + next if obj.exists? | |
| 47 | + | |
| 48 | + printf "Snapshotting #{name} #{version}... " | |
| 49 | + $stdout.flush | |
| 50 | + | |
| 51 | + system "tar", "-cjf", temp.path, dir | |
| 52 | + puts "done." | |
| 53 | + | |
| 54 | + printf "Shipping #{name} #{version} to S3... " | |
| 55 | + $stdout.flush | |
| 56 | + | |
| 57 | + obj.write :acl => :public_read, :file => temp.path | |
| 58 | + puts "done." | |
| 59 | + end | |
| 60 | +end | |
| 61 | + | |
| 62 | +# Sync rbenv rubies. | |
| 63 | + | |
| 64 | +Dir.chdir "#{config.homedir}/rbenv/versions" do | |
| 65 | + Dir["*"].each do |dir| | |
| 66 | + next if File.symlink? dir | |
| 67 | + | |
| 68 | + version = File.basename dir | |
| 69 | + file = "rbenv/#{os}/#{version}.tar.bz2" | |
| 70 | + temp = Tempfile.new "rbenv" | |
| 71 | + obj = bucket.objects[file] | |
| 72 | + | |
| 73 | + next if obj.exists? | |
| 74 | + | |
| 75 | + printf "Snapshotting ruby #{version}... " | |
| 76 | + $stdout.flush | |
| 77 | + | |
| 78 | + system "tar -cjf #{temp.path} #{version}" | |
| 79 | + puts "done." | |
| 80 | + | |
| 81 | + printf "Shipping ruby #{version} to S3... " | |
| 82 | + $stdout.flush | |
| 83 | + | |
| 84 | + obj.write :acl => :public_read, :file => temp.path | |
| 85 | + puts "done." | |
| 86 | + end | |
| 87 | +end | |
| 88 | + | |
| 89 | +# Sync NVM nodes. | |
| 90 | + | |
| 91 | +Dir.chdir "#{config.homedir}/nvm" do | |
| 92 | + Dir["v*"].each do |dir| | |
| 93 | + version = File.basename dir | |
| 94 | + file = "nvm/#{os}/#{version}.tar.bz2" | |
| 95 | + temp = Tempfile.new "nvm" | |
| 96 | + obj = bucket.objects[file] | |
| 97 | + | |
| 98 | + next if obj.exists? | |
| 99 | + | |
| 100 | + printf "Snapshotting node.js #{version}... " | |
| 101 | + $stdout.flush | |
| 102 | + | |
| 103 | + system "tar -cjf #{temp.path} #{version}" | |
| 104 | + puts "done." | |
| 105 | + | |
| 106 | + printf "Shipping node.js #{version} to S3... " | |
| 107 | + $stdout.flush | |
| 108 | + | |
| 109 | + obj.write :acl => :public_read, :file => temp.path | |
| 110 | + puts "done." | |
| 111 | + end | |
| 112 | +end |
vendor/cache/aws-sdk-1.6.9.gem
No preview for this file type
vendor/cache/httparty-0.9.0.gem
No preview for this file type
vendor/cache/json-1.7.5.gem
No preview for this file type
vendor/cache/multi_xml-0.5.1.gem
No preview for this file type
vendor/cache/nokogiri-1.5.5.gem
No preview for this file type
vendor/cache/uuidtools-2.1.3.gem
No preview for this file type