boxes 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.rubocop.yml +640 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -2
- data/CHANGELOG.md +21 -0
- data/Rakefile +17 -22
- data/boxes.gemspec +3 -4
- data/lib/boxes/command.rb +5 -5
- data/lib/boxes/testing.rb +6 -0
- data/lib/boxes/testing/command.rb +23 -0
- data/lib/boxes/testing/matchers.rb +16 -0
- data/lib/boxes/testing/matchers/base_matcher.rb +21 -0
- data/lib/boxes/testing/matchers/have_exit_status_matcher.rb +19 -0
- data/lib/boxes/testing/matchers/write_to_stdout_matcher.rb +23 -0
- data/lib/boxes/version.rb +1 -2
- data/scripts/postinstall.sh +2 -2
- data/scripts/ruby.sh +7 -7
- data/scripts/vmtools.sh +1 -0
- data/spec/acceptance/user_builds_box_spec.rb +51 -0
- data/spec/acceptance/user_cleans_the_env_spec.rb +15 -0
- data/spec/acceptance/user_shows_the_env_spec.rb +49 -0
- data/spec/acceptance/user_views_env_help_spec.rb +18 -0
- data/spec/acceptance/user_views_help_spec.rb +39 -0
- data/spec/acceptance/user_views_version_spec.rb +10 -0
- data/spec/acceptance_helper.rb +15 -0
- data/spec/boxes/subprocess_spec.rb +4 -1
- data/spec/boxes/testing/command_spec.rb +28 -0
- data/spec/boxes/testing/matchers/have_exit_status_matcher_spec.rb +33 -0
- data/spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb +33 -0
- data/spec/support/env.rb +5 -0
- data/spec/support/subprocess_command.sh +7 -0
- data/spec/support/tmp.rb +17 -0
- data/spec/tmp/.gitkeep +0 -0
- data/templates/debian/jessie64.erb +2 -2
- data/templates/debian/preseed.cfg +5 -1
- data/templates/debian/stretch64.erb +60 -0
- data/templates/ubuntu/trusty64.erb +2 -2
- data/templates/ubuntu/xenial64.erb +2 -2
- metadata +45 -33
- data/features/boxes.feature +0 -8
- data/features/build.feature +0 -16
- data/features/env.feature +0 -18
- data/features/support/env.rb +0 -1
- data/spec/support/subprocess_command.rb +0 -7
- data/templates/ubuntu/wily64.erb +0 -64
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 3.0.0 (05/02/2018)
|
4
|
+
|
5
|
+
* Update scripts/ruby.sh to follow ruby-lang.org current Rubies ([48]).
|
6
|
+
* Fix a bug with Shell Path Expansion ([44]).
|
7
|
+
* Add acceptance testing using RSpec ([43], [48], [49]).
|
8
|
+
* Remove Cucumber ([42]).
|
9
|
+
* Update Ubuntu Xenial to 16.04.3 ([40]).
|
10
|
+
* Update Ubuntu Trusty to 14.04.5 ([39]).
|
11
|
+
* Update Debian Stretch to 9.3.0 ([38]).
|
12
|
+
* Add support for Debian Stretch (9.1).
|
13
|
+
* Drop support for Ubuntu Wily 15.10.
|
14
|
+
* Switch to a working mirror for Debian Jessie.
|
15
|
+
|
16
|
+
[38]: https://github.com/nickcharlton/boxes/pull/38
|
17
|
+
[40]: https://github.com/nickcharlton/boxes/pull/40
|
18
|
+
[42]: https://github.com/nickcharlton/boxes/pull/42
|
19
|
+
[43]: https://github.com/nickcharlton/boxes/pull/43
|
20
|
+
[44]: https://github.com/nickcharlton/boxes/pull/44
|
21
|
+
[48]: https://github.com/nickcharlton/boxes/pull/48
|
22
|
+
[49]: https://github.com/nickcharlton/boxes/pull/49
|
23
|
+
|
3
24
|
## 2.5.0 (20/01/2017)
|
4
25
|
|
5
26
|
* Add Ruby 2.3.3.
|
data/Rakefile
CHANGED
@@ -1,34 +1,29 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
|
3
1
|
begin
|
4
|
-
require
|
2
|
+
require "bundler/setup"
|
5
3
|
rescue LoadError
|
6
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
5
|
end
|
8
6
|
|
9
|
-
require
|
7
|
+
require "bundler/gem_tasks"
|
10
8
|
|
11
9
|
##
|
12
10
|
# Configure the test suite.
|
13
11
|
##
|
14
|
-
require
|
15
|
-
require
|
16
|
-
|
17
|
-
RSpec::Core::RakeTask.new
|
12
|
+
require "rspec/core"
|
13
|
+
require "rspec/core/rake_task"
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
task(:spec).clear
|
16
|
+
desc "Run specs other than spec/acceptance"
|
17
|
+
RSpec::Core::RakeTask.new("spec") do |task|
|
18
|
+
task.exclude_pattern = "spec/acceptance/**/*_spec.rb"
|
19
|
+
task.verbose = false
|
20
|
+
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
desc "Run acceptance specs in spec/acceptance"
|
23
|
+
RSpec::Core::RakeTask.new("spec:acceptance") do |task|
|
24
|
+
task.pattern = "spec/acceptance/**/*_spec.rb"
|
25
|
+
task.verbose = false
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
##
|
34
|
-
task default: :spec
|
28
|
+
desc "Run the specs and acceptance tests"
|
29
|
+
task default: %w(spec spec:acceptance)
|
data/boxes.gemspec
CHANGED
@@ -30,10 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency "colored"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler"
|
33
|
-
spec.add_development_dependency "
|
34
|
-
spec.add_development_dependency "rspec"
|
35
|
-
spec.add_development_dependency "cucumber"
|
36
|
-
spec.add_development_dependency "aruba"
|
33
|
+
spec.add_development_dependency "climate_control"
|
37
34
|
spec.add_development_dependency "fakefs"
|
38
35
|
spec.add_development_dependency "pry"
|
36
|
+
spec.add_development_dependency "rake"
|
37
|
+
spec.add_development_dependency "rspec"
|
39
38
|
end
|
data/lib/boxes/command.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Boxes
|
2
|
-
# Class which encapsulates the command line handling.
|
3
2
|
class Command < CLAide::Command
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "boxes/command/build"
|
4
|
+
require "boxes/command/env"
|
6
5
|
|
7
6
|
self.abstract_command = true
|
8
|
-
self.command =
|
7
|
+
self.command = "boxes"
|
9
8
|
self.version = VERSION
|
10
|
-
self.description =
|
9
|
+
self.description = "A command line tool that takes the complexity out " \
|
10
|
+
"of building Vagrant boxes."
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Boxes
|
2
|
+
module Testing
|
3
|
+
module Command
|
4
|
+
attr_reader :response
|
5
|
+
|
6
|
+
def run_command(cmd)
|
7
|
+
stdout = `#{cmd}`
|
8
|
+
|
9
|
+
@response = Response.new(cmd, stdout, $?.exitstatus)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Response
|
13
|
+
attr_accessor :cmd, :stdout, :exit_status
|
14
|
+
|
15
|
+
def initialize(cmd, stdout, exit_status)
|
16
|
+
@cmd = cmd
|
17
|
+
@stdout = stdout
|
18
|
+
@exit_status = exit_status
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Boxes
|
2
|
+
module Testing
|
3
|
+
module Matchers
|
4
|
+
require "boxes/testing/matchers/have_exit_status_matcher"
|
5
|
+
require "boxes/testing/matchers/write_to_stdout_matcher"
|
6
|
+
|
7
|
+
def have_exit_status(status)
|
8
|
+
HaveExitStatusMatcher.new(status)
|
9
|
+
end
|
10
|
+
|
11
|
+
def write_to_stdout(data)
|
12
|
+
WriteToStdoutMatcher.new(data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Boxes
|
2
|
+
module Testing
|
3
|
+
module Matchers
|
4
|
+
class BaseMatcher
|
5
|
+
attr_reader :actual, :expected
|
6
|
+
|
7
|
+
# we can't compare to nil, because we might want nil
|
8
|
+
UNDEFINED = Object.new.freeze
|
9
|
+
|
10
|
+
def initialize(expected = UNDEFINED)
|
11
|
+
@expected = expected unless UNDEFINED.equal?(expected)
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches?(actual)
|
15
|
+
@actual = actual
|
16
|
+
match(actual, expected)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "boxes/testing/matchers/base_matcher"
|
2
|
+
|
3
|
+
module Boxes
|
4
|
+
module Testing
|
5
|
+
module Matchers
|
6
|
+
class HaveExitStatusMatcher < BaseMatcher
|
7
|
+
def failure_message
|
8
|
+
"expected that `#{actual.cmd}` would exit with #{expected}"
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def match(actual, expected)
|
14
|
+
expected == actual.exit_status
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "boxes/testing/matchers/base_matcher"
|
2
|
+
|
3
|
+
module Boxes
|
4
|
+
module Testing
|
5
|
+
module Matchers
|
6
|
+
class WriteToStdoutMatcher < BaseMatcher
|
7
|
+
def failure_message
|
8
|
+
"expected that '#{clean(actual.stdout)}' would be #{clean(expected)}"
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def match(actual, expected)
|
14
|
+
expected == actual.stdout
|
15
|
+
end
|
16
|
+
|
17
|
+
def clean(output)
|
18
|
+
output.gsub(/\n/, '\n')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/boxes/version.rb
CHANGED
data/scripts/postinstall.sh
CHANGED
@@ -34,10 +34,10 @@ curl -Lo /home/vagrant/.ssh/authorized_keys \
|
|
34
34
|
chmod 0600 /home/vagrant/.ssh/authorized_keys
|
35
35
|
chown -R vagrant:vagrant /home/vagrant/.ssh
|
36
36
|
|
37
|
-
# under systemd
|
37
|
+
# under systemd distributions, networking breaks on first reboot
|
38
38
|
# this is because it's renamed to follow the PCI slot
|
39
39
|
case $(lsb_release -cs) in
|
40
|
-
"wily" | "xenial")
|
40
|
+
"wily" | "xenial" | "stretch")
|
41
41
|
sed -i "s/ens33/ens32/g" /etc/network/interfaces
|
42
42
|
;;
|
43
43
|
*)
|
data/scripts/ruby.sh
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/bin/sh
|
2
2
|
|
3
3
|
# this installs chruby, ruby-install and a selection of rubies and is used in
|
4
4
|
# the 'ruby' special box type.
|
5
5
|
|
6
6
|
chruby_version=0.3.9
|
7
|
-
rubyinstall_version=0.6.
|
7
|
+
rubyinstall_version=0.6.1
|
8
8
|
|
9
9
|
# install chruby
|
10
10
|
wget -O chruby-$chruby_version.tar.gz https://github.com/postmodern/chruby/archive/v$chruby_version.tar.gz
|
@@ -27,11 +27,11 @@ cd ruby-install-$rubyinstall_version/
|
|
27
27
|
make install
|
28
28
|
|
29
29
|
# install a set of recent MRI Rubies.
|
30
|
-
ruby-install ruby 2.
|
31
|
-
ruby-install ruby 2.2.
|
32
|
-
ruby-install ruby 2.3.
|
33
|
-
ruby-install ruby 2.
|
34
|
-
ruby-install ruby 2.
|
30
|
+
ruby-install ruby 2.1.10
|
31
|
+
ruby-install ruby 2.2.9
|
32
|
+
ruby-install ruby 2.3.6
|
33
|
+
ruby-install ruby 2.4.3
|
34
|
+
ruby-install ruby 2.5.0
|
35
35
|
|
36
36
|
# update gems and install bundler
|
37
37
|
source /usr/local/share/chruby/chruby.sh
|
data/scripts/vmtools.sh
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "acceptance_helper"
|
2
|
+
|
3
|
+
RSpec.describe "User builds box" do
|
4
|
+
describe "boxes build" do
|
5
|
+
it "shows help when the name option is missing" do
|
6
|
+
run_command("boxes build --provider=vmware --template=debian/jessie64")
|
7
|
+
|
8
|
+
expect(response).to have_exit_status(1)
|
9
|
+
expect(response.stdout).to include("[!] A name is required!")
|
10
|
+
expect_response_to_show_build_help
|
11
|
+
end
|
12
|
+
|
13
|
+
it "shows help when the provider option is missing" do
|
14
|
+
run_command("boxes build --name=example --template=debian/jessie64")
|
15
|
+
|
16
|
+
expect(response).to have_exit_status(1)
|
17
|
+
expect(response.stdout).to include("[!] A provider is required!")
|
18
|
+
expect_response_to_show_build_help
|
19
|
+
end
|
20
|
+
|
21
|
+
it "shows help when the template option is missing" do
|
22
|
+
run_command("boxes build --name=example --provider=vmware")
|
23
|
+
|
24
|
+
expect(response).to have_exit_status(1)
|
25
|
+
expect(response.stdout).to include("[!] A template is required!")
|
26
|
+
expect_response_to_show_build_help
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def expect_response_to_show_build_help
|
31
|
+
expect(response.stdout).to include(
|
32
|
+
"Builds boxes using templates and scripts.",
|
33
|
+
)
|
34
|
+
|
35
|
+
expect(response.stdout).to include(
|
36
|
+
"--name The name for the build",
|
37
|
+
)
|
38
|
+
|
39
|
+
expect(response.stdout).to include(
|
40
|
+
"--provider=[virtualbox|vmware] The provider to build the box for",
|
41
|
+
)
|
42
|
+
|
43
|
+
expect(response.stdout).to include(
|
44
|
+
"--template Template to build the box with",
|
45
|
+
)
|
46
|
+
|
47
|
+
expect(response.stdout).to include(
|
48
|
+
"--scripts Scripts to apply to the box",
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "acceptance_helper"
|
2
|
+
|
3
|
+
RSpec.describe "User cleans the env" do
|
4
|
+
describe "boxes env" do
|
5
|
+
it "shows the environment details" do
|
6
|
+
mktmpdir
|
7
|
+
|
8
|
+
with_modified_env(BOXES_WORKING_DIR: tmpdir.to_s) do
|
9
|
+
run_command("boxes env clean")
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(tmpdir).not_to exist
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "acceptance_helper"
|
2
|
+
|
3
|
+
RSpec.describe "User shows the env" do
|
4
|
+
describe "boxes env" do
|
5
|
+
it "shows the environment details" do
|
6
|
+
run_command("boxes env")
|
7
|
+
|
8
|
+
expect(response).to have_exit_status(0)
|
9
|
+
expect_response_to_show_environment_details
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "boxes env show" do
|
14
|
+
it "shows the environment details" do
|
15
|
+
run_command("boxes env show")
|
16
|
+
|
17
|
+
expect(response).to have_exit_status(0)
|
18
|
+
expect_response_to_show_environment_details
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def expect_response_to_show_environment_details
|
23
|
+
expect(response.stdout).to include(
|
24
|
+
"WORKING_DIR=\"#{home_path('.boxes/tmp')}",
|
25
|
+
)
|
26
|
+
expect(response.stdout).to include("HOME_DIR=\"#{home_path('.boxes')}\"")
|
27
|
+
|
28
|
+
expect(response.stdout).to include(
|
29
|
+
"TEMPLATE_PATHS=\"#{project_path('templates')}\"",
|
30
|
+
)
|
31
|
+
|
32
|
+
expect(response.stdout).to include(
|
33
|
+
"SCRIPT_PATHS=\"#{project_path('scripts')}\"",
|
34
|
+
)
|
35
|
+
|
36
|
+
expect(response.stdout).to include(
|
37
|
+
"PACKER_CACHE_DIR=\"#{home_path('.boxes/packer_cache')}",
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def project_path(subpath)
|
42
|
+
project_root = Pathname.new("../../").expand_path
|
43
|
+
project_root.join(subpath)
|
44
|
+
end
|
45
|
+
|
46
|
+
def home_path(subpath)
|
47
|
+
Pathname.new(Dir.home).join(subpath)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "acceptance_helper"
|
2
|
+
|
3
|
+
RSpec.describe "User views env help" do
|
4
|
+
describe "boxes env" do
|
5
|
+
it "describes available subcommands" do
|
6
|
+
run_command("boxes env --help")
|
7
|
+
|
8
|
+
expect(response).to have_exit_status(0)
|
9
|
+
expect(response.stdout).to include(
|
10
|
+
"+ clean Clean up the environment.",
|
11
|
+
)
|
12
|
+
|
13
|
+
expect(response.stdout).to include(
|
14
|
+
"> show Show the environment and configuration",
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|