From 61c4982fde9295aefed697e3ef5235006990af89 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 2 Mar 2013 20:36:06 -0300 Subject: [PATCH] Vendorize vagrant Closes #19 --- .gitmodules | 4 ++-- Gemfile | 6 ------ Gemfile.lock | 10 ++-------- bin/vagrant-lxc | 9 +++++++++ dev/Gemfile | 1 - dev/Gemfile.lock | 23 ----------------------- lib/vagrant-lxc.rb | 8 ++------ lib/vagrant-lxc/container.rb | 5 +++-- lib/vendored_vagrant.rb | 9 +++++++++ spec/spec_helper.rb | 4 +--- vagrant-lxc.gemspec | 13 ++++++++++++- vendor/.gitkeep | 0 vendor/vagrant | 1 + 13 files changed, 41 insertions(+), 52 deletions(-) create mode 100755 bin/vagrant-lxc create mode 100644 lib/vendored_vagrant.rb create mode 100644 vendor/.gitkeep create mode 160000 vendor/vagrant diff --git a/.gitmodules b/.gitmodules index bef6aa9..1ed2367 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "vagrant"] - path = vagrant +[submodule "vendor/vagrant"] + path = vendor/vagrant url = git://github.com/mitchellh/vagrant.git diff --git a/Gemfile b/Gemfile index b3f0dd4..21fb792 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,7 @@ source 'https://rubygems.org' -unless ENV['USER'] == 'vagrant' - puts 'This Gemfile is meant to be used from the dev box' - exit 1 -end - gemspec -gem 'vagrant', path: './vagrant' gem 'rake' gem 'net-ssh' gem 'rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 8f9673d..b0f41c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,15 +2,10 @@ PATH remote: . specs: vagrant-lxc (0.0.1) - -PATH - remote: ./vagrant - specs: - vagrant (1.1.0.dev) childprocess (~> 0.3.7) erubis (~> 2.7.0) i18n (~> 0.6.0) - json (~> 1.6.6) + json (>= 1.5.1, < 1.8.0) log4r (~> 1.1.9) net-scp (~> 1.0.4) net-ssh (~> 2.2.2) @@ -38,7 +33,7 @@ GEM guard-rspec (2.4.1) guard (>= 1.1) rspec (~> 2.11) - i18n (0.6.2) + i18n (0.6.3) json (1.6.8) listen (0.7.3) log4r (1.1.10) @@ -91,5 +86,4 @@ DEPENDENCIES rspec-fire rspec-spies simplecov - vagrant! vagrant-lxc! diff --git a/bin/vagrant-lxc b/bin/vagrant-lxc new file mode 100755 index 0000000..da2f41d --- /dev/null +++ b/bin/vagrant-lxc @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby + +if File.exists?(File.join(File.expand_path('../../', __FILE__), '.git')) + $:.unshift(File.expand_path('../../lib', __FILE__)) +end + +require 'vagrant-lxc' + +load Vagrant.source_root.join('bin/vagrant').to_s diff --git a/dev/Gemfile b/dev/Gemfile index 5ad4b27..6130da0 100644 --- a/dev/Gemfile +++ b/dev/Gemfile @@ -5,5 +5,4 @@ end source "https://rubygems.org" -gem 'vagrant', path: '../vagrant' gem 'vagrant-lxc', path: '../' diff --git a/dev/Gemfile.lock b/dev/Gemfile.lock index a7505a6..2bca673 100644 --- a/dev/Gemfile.lock +++ b/dev/Gemfile.lock @@ -3,35 +3,12 @@ PATH specs: vagrant-lxc (0.0.1) -PATH - remote: ../vagrant - specs: - vagrant (1.1.0.dev) - childprocess (~> 0.3.7) - erubis (~> 2.7.0) - i18n (~> 0.6.0) - json (~> 1.6.6) - log4r (~> 1.1.9) - net-scp (~> 1.0.4) - net-ssh (~> 2.2.2) - GEM remote: https://rubygems.org/ specs: - childprocess (0.3.8) - ffi (~> 1.0, >= 1.0.11) - erubis (2.7.0) - ffi (1.4.0) - i18n (0.6.2) - json (1.6.8) - log4r (1.1.10) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-ssh (2.2.2) PLATFORMS ruby DEPENDENCIES - vagrant! vagrant-lxc! diff --git a/lib/vagrant-lxc.rb b/lib/vagrant-lxc.rb index be87384..5a6e6d3 100644 --- a/lib/vagrant-lxc.rb +++ b/lib/vagrant-lxc.rb @@ -1,10 +1,6 @@ -require "vagrant-lxc/version" +require "vendored_vagrant" +require "vagrant-lxc/version" require "vagrant-lxc/plugin" I18n.load_path << File.expand_path(File.dirname(__FILE__) + '/../locales/en.yml') - -module Vagrant - module LXC - end -end diff --git a/lib/vagrant-lxc/container.rb b/lib/vagrant-lxc/container.rb index d13235e..f3ec3c7 100644 --- a/lib/vagrant-lxc/container.rb +++ b/lib/vagrant-lxc/container.rb @@ -1,8 +1,9 @@ # FIXME: Ruby 1.8 users dont have SecureRandom require 'securerandom' -require 'vagrant/util/retryable' -require 'vagrant/util/subprocess' +require "vendored_vagrant" +require "vagrant/util/retryable" +require "vagrant/util/subprocess" require "vagrant-lxc/errors" diff --git a/lib/vendored_vagrant.rb b/lib/vendored_vagrant.rb new file mode 100644 index 0000000..b005d18 --- /dev/null +++ b/lib/vendored_vagrant.rb @@ -0,0 +1,9 @@ +# Tks to: https://github.com/carlhuda/bundler/blob/master/lib/bundler/vendored_thor.rb + +if defined?(Vagrant) && Vagrant.respond_to?(:in_installer?) + puts "vagrant has already been required. This may cause vagrant-lxc to malfunction in unexpected ways." +end +vendor = File.expand_path('../../vendor/vagrant/lib', __FILE__) +$:.unshift(vendor) unless $:.include?(vendor) + +require 'vagrant' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7dc442f..f7e33a8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,9 +7,7 @@ if ENV['COVERAGE'] end end -require 'bundler/setup' - -Bundler.require +require 'bundler' require 'rspec-spies' diff --git a/vagrant-lxc.gemspec b/vagrant-lxc.gemspec index 8802c12..8d397e9 100644 --- a/vagrant-lxc.gemspec +++ b/vagrant-lxc.gemspec @@ -12,8 +12,19 @@ Gem::Specification.new do |gem| gem.summary = %q{TODO: Write a gem summary} gem.homepage = "" - gem.files = `git ls-files`.split($/) + gem.files = `git ls-files`.split($/) + gem.files << `cd vendor/vagrant && git ls-files`.split($/).map{|file| "vendor/vagrant/#{file}"} + gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + + # Vagrant's dependencies + gem.add_dependency "childprocess", "~> 0.3.7" + gem.add_dependency "erubis", "~> 2.7.0" + gem.add_dependency "i18n", "~> 0.6.0" + gem.add_dependency "json", ">= 1.5.1", "< 1.8.0" + gem.add_dependency "log4r", "~> 1.1.9" + gem.add_dependency "net-ssh", "~> 2.2.2" + gem.add_dependency "net-scp", "~> 1.0.4" end diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/vagrant b/vendor/vagrant new file mode 160000 index 0000000..0bb57fb --- /dev/null +++ b/vendor/vagrant @@ -0,0 +1 @@ +Subproject commit 0bb57fbe861de199293af22bf3111306ee37db70