Update for script/sync
This commit is contained in:
parent
553c2e33d0
commit
966c19f70b
11 changed files with 142 additions and 3 deletions
6
Gemfile
6
Gemfile
|
@ -1,3 +1,7 @@
|
|||
source "http://rubygems.org"
|
||||
|
||||
gem "boxen", "~> 0.1"
|
||||
gem "boxen", "~> 0.4"
|
||||
|
||||
group :development do
|
||||
gem "aws-sdk"
|
||||
end
|
||||
|
|
15
Gemfile.lock
15
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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"] = ''
|
||||
|
|
112
script/sync
Executable file
112
script/sync
Executable file
|
@ -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
|
BIN
vendor/cache/aws-sdk-1.6.9.gem
vendored
Normal file
BIN
vendor/cache/aws-sdk-1.6.9.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/httparty-0.9.0.gem
vendored
Normal file
BIN
vendor/cache/httparty-0.9.0.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/json-1.7.5.gem
vendored
Normal file
BIN
vendor/cache/json-1.7.5.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/multi_xml-0.5.1.gem
vendored
Normal file
BIN
vendor/cache/multi_xml-0.5.1.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/nokogiri-1.5.5.gem
vendored
Normal file
BIN
vendor/cache/nokogiri-1.5.5.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/uuidtools-2.1.3.gem
vendored
Normal file
BIN
vendor/cache/uuidtools-2.1.3.gem
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue