diff --git a/Gemfile b/Gemfile index 42cae2d..77d7481 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,7 @@ source "http://rubygems.org" -gem "boxen", "~> 0.1" +gem "boxen", "~> 0.4" + +group :development do + gem "aws-sdk" +end diff --git a/Gemfile.lock b/Gemfile.lock index 179673a..d4c580a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,11 @@ GEM specs: addressable (2.3.2) ansi (1.4.3) + aws-sdk (1.6.9) + httparty (~> 0.7) + json (~> 1.4) + nokogiri (>= 1.4.4) + uuidtools (~> 2.1) boxen (0.4.0) ansi (~> 1.4) hiera (~> 1.0.0) @@ -19,13 +24,19 @@ GEM hashie (1.2.0) hiera (1.0.0) highline (1.6.15) + httparty (0.9.0) + multi_json (~> 1.0) + multi_xml + json (1.7.5) json_pure (1.7.5) librarian-puppet (0.9.6) json_pure puppet thor (~> 0.15) multi_json (1.3.6) + multi_xml (0.5.1) multipart-post (1.1.5) + nokogiri (1.5.5) octokit (1.15.1) addressable (~> 2.2) faraday (~> 0.8) @@ -36,9 +47,11 @@ GEM facter (>= 1.6.11) hiera (>= 1.0.0rc) thor (0.16.0) + uuidtools (2.1.3) PLATFORMS ruby DEPENDENCIES - boxen (~> 0.1) + aws-sdk + boxen (~> 0.4) diff --git a/README.md b/README.md index d3502e8..7491ee5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This repository template is just a basic example of _how_ to do things with them 1. Install XCode Command Line Tools and/or full XCode. 1. Create a new repository on GitHub as your user for your Boxen. (eg. -`wfarr/my-boxen`). **Make sure it is a private repository!** for now +`wfarr/my-boxen`). **Make sure it is a private repository!** 1. Get running like so: ``` mkdir -p ~/src/my-boxen @@ -76,3 +76,8 @@ what-have-you for your organization. For organization projects (read: repositories that people will be working in), please see the documentation in the projects module template we provide. 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. + +## Binary packages + +We support binary packaging for everything in Homebrew, RBEnv, and NVM. +See `config/boxen.rb` for the environment variables to define. diff --git a/config/boxen.rb b/config/boxen.rb index 59b3348..50fd07d 100644 --- a/config/boxen.rb +++ b/config/boxen.rb @@ -6,3 +6,8 @@ # Change the repo boxen will use. # ENV['BOXEN_REPO_NAME'] = 'boxen/our-boxen' + +# Boxen binary packaging +# ENV["BOXEN_S3_ACCESS_KEY"] = '' +# ENV["BOXEN_S3_SECRET_KEY"] = '' +# ENV["BOXEN_S3_BUCKET"] = '' diff --git a/script/sync b/script/sync new file mode 100755 index 0000000..4628117 --- /dev/null +++ b/script/sync @@ -0,0 +1,112 @@ +#!/usr/bin/ruby +# Sync binary snapshots to S3. + +require "pathname" +require "tempfile" + +# Put us where we belong, in the root dir of our boxen repo. + +Dir.chdir Pathname.new(__FILE__).realpath + "../.." + +# Make sure our local dependencies are up to date. + +abort "Sorry, can't bootstrap." unless system "script/bootstrap" + +# Set up our local configuration, deps, and load path. + +load "config/basic.rb" + +require "aws-sdk" +require "boxen/config" + +access_key = ENV["BOXEN_S3_ACCESS_KEY"] +secret_key = ENV["BOXEN_S3_SECRET_KEY"] +bucket_name = ENV["BOXEN_S3_BUCKET"] + +unless access_key && secret_key && bucket_name + abort "Please set the BOXEN_S3_{ACCESS_KEY,SECRET_KEY,BUCKET} env vars." +end + +s3 = AWS::S3.new :access_key_id => access_key, :secret_access_key => secret_key +os = `sw_vers -productVersion`.strip.split(".")[0..1].join "." + +bucket = s3.buckets[bucket_name] +config = Boxen::Config.load + +# Sync Homebrew packages. + +Dir.chdir "#{config.homedir}/homebrew/Cellar" do + Dir["*/*"].each do |dir| + name, version = File.split dir + + file = "homebrew/#{os}/#{name}-#{version}.tar.bz2" + temp = Tempfile.new "homebrew" + obj = bucket.objects[file] + + next if obj.exists? + + printf "Snapshotting #{name} #{version}... " + $stdout.flush + + system "tar", "-cjf", temp.path, dir + puts "done." + + printf "Shipping #{name} #{version} to S3... " + $stdout.flush + + obj.write :acl => :public_read, :file => temp.path + puts "done." + end +end + +# Sync rbenv rubies. + +Dir.chdir "#{config.homedir}/rbenv/versions" do + Dir["*"].each do |dir| + next if File.symlink? dir + + version = File.basename dir + file = "rbenv/#{os}/#{version}.tar.bz2" + temp = Tempfile.new "rbenv" + obj = bucket.objects[file] + + next if obj.exists? + + printf "Snapshotting ruby #{version}... " + $stdout.flush + + system "tar -cjf #{temp.path} #{version}" + puts "done." + + printf "Shipping ruby #{version} to S3... " + $stdout.flush + + obj.write :acl => :public_read, :file => temp.path + puts "done." + end +end + +# Sync NVM nodes. + +Dir.chdir "#{config.homedir}/nvm" do + Dir["v*"].each do |dir| + version = File.basename dir + file = "nvm/#{os}/#{version}.tar.bz2" + temp = Tempfile.new "nvm" + obj = bucket.objects[file] + + next if obj.exists? + + printf "Snapshotting node.js #{version}... " + $stdout.flush + + system "tar -cjf #{temp.path} #{version}" + puts "done." + + printf "Shipping node.js #{version} to S3... " + $stdout.flush + + obj.write :acl => :public_read, :file => temp.path + puts "done." + end +end diff --git a/vendor/cache/aws-sdk-1.6.9.gem b/vendor/cache/aws-sdk-1.6.9.gem new file mode 100644 index 0000000..38c1332 Binary files /dev/null and b/vendor/cache/aws-sdk-1.6.9.gem differ diff --git a/vendor/cache/httparty-0.9.0.gem b/vendor/cache/httparty-0.9.0.gem new file mode 100644 index 0000000..62f851d Binary files /dev/null and b/vendor/cache/httparty-0.9.0.gem differ diff --git a/vendor/cache/json-1.7.5.gem b/vendor/cache/json-1.7.5.gem new file mode 100644 index 0000000..737f5c8 Binary files /dev/null and b/vendor/cache/json-1.7.5.gem differ diff --git a/vendor/cache/multi_xml-0.5.1.gem b/vendor/cache/multi_xml-0.5.1.gem new file mode 100644 index 0000000..27d7aa8 Binary files /dev/null and b/vendor/cache/multi_xml-0.5.1.gem differ diff --git a/vendor/cache/nokogiri-1.5.5.gem b/vendor/cache/nokogiri-1.5.5.gem new file mode 100644 index 0000000..9f556d5 Binary files /dev/null and b/vendor/cache/nokogiri-1.5.5.gem differ diff --git a/vendor/cache/uuidtools-2.1.3.gem b/vendor/cache/uuidtools-2.1.3.gem new file mode 100644 index 0000000..a489d97 Binary files /dev/null and b/vendor/cache/uuidtools-2.1.3.gem differ