boxgrinder-build 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Manifest +30 -0
- data/Rakefile +70 -2
- data/bin/boxgrinder-build +1 -5
- data/boxgrinder-build.gemspec +6 -6
- data/lib/boxgrinder-build/helpers/augeas-helper.rb +11 -9
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +4 -2
- data/lib/boxgrinder-build/helpers/image-helper.rb +20 -11
- data/lib/boxgrinder-build/plugins/base-plugin.rb +3 -2
- data/rubygem-boxgrinder-build.spec +32 -9
- data/spec/Rakefile +1 -0
- data/spec/appliance-spec.rb +89 -56
- data/spec/helpers/appliance-customize-helper-spec.rb +32 -6
- data/spec/helpers/augeas-helper-spec.rb +24 -6
- data/spec/helpers/image-helper-spec.rb +40 -11
- data/spec/helpers/plugin-helper-spec.rb +0 -3
- data/spec/plugins/base-plugin-spec.rb +21 -17
- metadata +8 -8
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
LICENSE
|
3
|
+
Manifest
|
4
|
+
README
|
5
|
+
Rakefile
|
6
|
+
bin/boxgrinder-build
|
7
|
+
boxgrinder-build.gemspec
|
8
|
+
lib/boxgrinder-build/appliance.rb
|
9
|
+
lib/boxgrinder-build/helpers/appliance-customize-helper.rb
|
10
|
+
lib/boxgrinder-build/helpers/augeas-helper.rb
|
11
|
+
lib/boxgrinder-build/helpers/guestfs-helper.rb
|
12
|
+
lib/boxgrinder-build/helpers/image-helper.rb
|
13
|
+
lib/boxgrinder-build/helpers/linux-helper.rb
|
14
|
+
lib/boxgrinder-build/helpers/package-helper.rb
|
15
|
+
lib/boxgrinder-build/helpers/plugin-helper.rb
|
16
|
+
lib/boxgrinder-build/managers/plugin-manager.rb
|
17
|
+
lib/boxgrinder-build/plugins/base-plugin.rb
|
18
|
+
rubygem-boxgrinder-build.spec
|
19
|
+
spec/Rakefile
|
20
|
+
spec/appliance-spec.rb
|
21
|
+
spec/helpers/appliance-customize-helper-spec.rb
|
22
|
+
spec/helpers/augeas-helper-spec.rb
|
23
|
+
spec/helpers/guestfs-helper-spec.rb
|
24
|
+
spec/helpers/image-helper-spec.rb
|
25
|
+
spec/helpers/linux-helper-spec.rb
|
26
|
+
spec/helpers/package-helper-spec.rb
|
27
|
+
spec/helpers/plugin-helper-spec.rb
|
28
|
+
spec/managers/plugin-manager-spec.rb
|
29
|
+
spec/plugins/base-plugin-spec.rb
|
30
|
+
spec/rspec/src/appliances/jeos-f13.appl
|
data/Rakefile
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2010 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This is free software; you can redistribute it and/or modify it
|
5
|
+
# under the terms of the GNU Lesser General Public License as
|
6
|
+
# published by the Free Software Foundation; either version 3 of
|
7
|
+
# the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This software is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this software; if not, write to the Free
|
16
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'spec/rake/spectask'
|
1
21
|
require 'echoe'
|
2
22
|
|
3
23
|
Echoe.new("boxgrinder-build") do |p|
|
@@ -6,6 +26,54 @@ Echoe.new("boxgrinder-build") do |p|
|
|
6
26
|
p.summary = "A tool for creating appliances from simple plain text files for various virtual environments."
|
7
27
|
p.url = "http://www.jboss.org/boxgrinder"
|
8
28
|
p.email = "info@boxgrinder.org"
|
9
|
-
p.
|
10
|
-
|
29
|
+
p.runtime_dependencies = ["commander ~>4.0.3", "boxgrinder-core ~>0.1.2"]
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Run all tests"
|
33
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
34
|
+
t.libs.unshift "../boxgrinder-core/lib"
|
35
|
+
t.rcov = false
|
36
|
+
t.spec_files = FileList["spec/**/*-spec.rb"]
|
37
|
+
t.spec_opts = ['--colour', '--format', 'specdoc', '-b']
|
38
|
+
t.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Run all tests and generate code coverage report"
|
42
|
+
Spec::Rake::SpecTask.new('spec:coverage') do |t|
|
43
|
+
t.libs.unshift "../boxgrinder-core/lib"
|
44
|
+
t.spec_files = FileList["spec/**/*-spec.rb"]
|
45
|
+
t.spec_opts = ['--colour', '--format', 'html:pkg/rspec_report.html', '-b']
|
46
|
+
t.rcov = true
|
47
|
+
t.rcov_opts = ['--exclude', 'spec,teamcity/*,/usr/lib/ruby/,.gem/ruby,/boxgrinder-core/,/gems/']
|
48
|
+
t.verbose = true
|
49
|
+
end
|
50
|
+
|
51
|
+
topdir = "#{Dir.pwd}/pkg/rpmbuild"
|
52
|
+
directory "#{topdir}/SOURCES"
|
53
|
+
|
54
|
+
task 'gem:copy' => [:clean, :manifest, :gem, 'rpm:topdir'] do
|
55
|
+
Dir["**/pkg/*.gem"].each { |gem| FileUtils.cp(gem, "#{topdir}/SOURCES", :verbose => true) }
|
56
|
+
end
|
57
|
+
|
58
|
+
task 'rpm:topdir' do
|
59
|
+
FileUtils.mkdir_p(["#{topdir}/SOURCES", "#{topdir}/RPMS", "#{topdir}/BUILD", "#{topdir}/SPECS", "#{topdir}/SRPMS"], :verbose => true)
|
11
60
|
end
|
61
|
+
|
62
|
+
desc "Create RPM"
|
63
|
+
task 'rpm' => ['gem:copy'] do
|
64
|
+
Dir["**/rubygem-*.spec"].each do |spec|
|
65
|
+
`rpmbuild --define '_topdir #{topdir}' -ba #{spec}`
|
66
|
+
exit 1 unless $? == 0
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Install RPM"
|
71
|
+
task 'rpm:install' => ['rpm'] do
|
72
|
+
puts "sudo yum -y remove rubygem-boxgrinder-build"
|
73
|
+
system "sudo yum -y remove rubygem-boxgrinder-build"
|
74
|
+
exit 1 unless $? == 0
|
75
|
+
|
76
|
+
puts "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
77
|
+
system "sudo yum -y --nogpgcheck localinstall #{topdir}/RPMS/noarch/*.rpm"
|
78
|
+
exit 1 unless $? == 0
|
79
|
+
end
|
data/bin/boxgrinder-build
CHANGED
@@ -18,10 +18,6 @@
|
|
18
18
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
19
|
|
20
20
|
require 'rubygems'
|
21
|
-
|
22
|
-
gem 'boxgrinder-core', '>= 0.1.1'
|
23
|
-
gem 'commander', '>= 4.0.3'
|
24
|
-
|
25
21
|
require 'boxgrinder-core/helpers/log-helper'
|
26
22
|
require 'boxgrinder-build/appliance'
|
27
23
|
|
@@ -35,7 +31,7 @@ end
|
|
35
31
|
require 'commander/import'
|
36
32
|
|
37
33
|
program :name, 'BoxGrinder Build'
|
38
|
-
program :version, '0.6.
|
34
|
+
program :version, '0.6.3'
|
39
35
|
program :description, "A tool for building VM images from simple definition files."
|
40
36
|
program :help, 'Homepage', 'http://www.jboss.org/boxgrinder/build.html'
|
41
37
|
program :help, 'Documentation', 'http://community.jboss.org/docs/DOC-14358'
|
data/boxgrinder-build.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{boxgrinder-build}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marek Goldmann"]
|
9
|
-
s.date = %q{2010-11-
|
9
|
+
s.date = %q{2010-11-11}
|
10
10
|
s.default_executable = %q{boxgrinder-build}
|
11
11
|
s.description = %q{A tool for creating appliances from simple plain text files for various virtual environments.}
|
12
12
|
s.email = %q{info@boxgrinder.org}
|
13
13
|
s.executables = ["boxgrinder-build"]
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
|
15
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/image-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb", "spec/rspec/src/appliances/jeos-f13.appl"
|
15
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder-build", "boxgrinder-build.gemspec", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/image-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb", "spec/rspec/src/appliances/jeos-f13.appl"]
|
16
16
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README"]
|
18
18
|
s.require_paths = ["lib"]
|
@@ -26,13 +26,13 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<commander>, ["~> 4.0.3"])
|
29
|
-
s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.1.
|
29
|
+
s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.1.2"])
|
30
30
|
else
|
31
31
|
s.add_dependency(%q<commander>, ["~> 4.0.3"])
|
32
|
-
s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.
|
32
|
+
s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.2"])
|
33
33
|
end
|
34
34
|
else
|
35
35
|
s.add_dependency(%q<commander>, ["~> 4.0.3"])
|
36
|
-
s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.
|
36
|
+
s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.2"])
|
37
37
|
end
|
38
38
|
end
|
@@ -20,7 +20,7 @@ require 'logger'
|
|
20
20
|
|
21
21
|
module BoxGrinder
|
22
22
|
class AugeasHelper
|
23
|
-
def initialize(
|
23
|
+
def initialize(guestfs, guestfs_helper, options = {})
|
24
24
|
@guestfs = guestfs
|
25
25
|
@guestfs_helper = guestfs_helper
|
26
26
|
@log = options[:log] || Logger.new(STDOUT)
|
@@ -28,7 +28,7 @@ module BoxGrinder
|
|
28
28
|
@files = {}
|
29
29
|
end
|
30
30
|
|
31
|
-
def edit(
|
31
|
+
def edit(&block)
|
32
32
|
@log.debug "Changing configuration files using augeas..."
|
33
33
|
|
34
34
|
instance_eval &block if block
|
@@ -38,10 +38,12 @@ module BoxGrinder
|
|
38
38
|
return
|
39
39
|
end
|
40
40
|
|
41
|
-
@
|
42
|
-
|
41
|
+
if @guestfs.debug("help", []).include?('core_pattern')
|
42
|
+
@log.trace "Enabling coredump catching for augeas..."
|
43
|
+
@guestfs.debug("core_pattern", ["/sysroot/core"])
|
44
|
+
end
|
43
45
|
|
44
|
-
@guestfs.aug_init(
|
46
|
+
@guestfs.aug_init("/", 32)
|
45
47
|
|
46
48
|
unload = []
|
47
49
|
|
@@ -49,7 +51,7 @@ module BoxGrinder
|
|
49
51
|
unload << ". != '#{file_name}'"
|
50
52
|
end
|
51
53
|
|
52
|
-
@guestfs.aug_rm(
|
54
|
+
@guestfs.aug_rm("/augeas/load//incl[#{unload.join(' and ')}]")
|
53
55
|
@guestfs.aug_load
|
54
56
|
|
55
57
|
@files.each do |file, changes|
|
@@ -64,13 +66,13 @@ module BoxGrinder
|
|
64
66
|
@log.debug "Augeas changes saved."
|
65
67
|
end
|
66
68
|
|
67
|
-
def set(
|
68
|
-
unless @guestfs.exists(
|
69
|
+
def set(name, key, value)
|
70
|
+
unless @guestfs.exists(name) != 0
|
69
71
|
@log.debug "File '#{name}' doesn't exists, skipping augeas changes..."
|
70
72
|
return
|
71
73
|
end
|
72
74
|
|
73
|
-
@files[name] = {} unless @files.has_key?(
|
75
|
+
@files[name] = {} unless @files.has_key?(name)
|
74
76
|
@files[name][key] = value
|
75
77
|
end
|
76
78
|
end
|
@@ -159,8 +159,10 @@ module BoxGrinder
|
|
159
159
|
@guestfs.add_drive(@raw_disk)
|
160
160
|
@log.trace "Drive added."
|
161
161
|
|
162
|
-
@
|
163
|
-
|
162
|
+
if @guestfs.respond_to?('set_network')
|
163
|
+
@log.debug "Enabling networking for GuestFS..."
|
164
|
+
@guestfs.set_network(1)
|
165
|
+
end
|
164
166
|
|
165
167
|
@log.debug "Launching guestfs..."
|
166
168
|
@guestfs.launch
|
@@ -21,7 +21,10 @@ require 'boxgrinder-build/helpers/guestfs-helper'
|
|
21
21
|
|
22
22
|
module BoxGrinder
|
23
23
|
class ImageHelper
|
24
|
-
def initialize(options = {})
|
24
|
+
def initialize(config, appliance_config, options = {})
|
25
|
+
@config = config
|
26
|
+
@appliance_config = appliance_config
|
27
|
+
|
25
28
|
@log = options[:log] || Logger.new(STDOUT)
|
26
29
|
@exec_helper = options[:exec_helper] || ExecHelper.new(:log => @log)
|
27
30
|
end
|
@@ -42,10 +45,10 @@ module BoxGrinder
|
|
42
45
|
mounts[label] = loop_device
|
43
46
|
end
|
44
47
|
|
45
|
-
@exec_helper.execute("mount #{mounts['/']}
|
48
|
+
@exec_helper.execute("mount #{mounts['/']} #{mount_dir}")
|
46
49
|
|
47
50
|
mounts.reject { |key, value| key == '/' }.each do |mount_point, loop_device|
|
48
|
-
@exec_helper.execute("mount #{loop_device}
|
51
|
+
@exec_helper.execute("mount #{loop_device} #{mount_dir}#{mount_point}")
|
49
52
|
end
|
50
53
|
|
51
54
|
@log.trace "Mounts:\n#{mounts}"
|
@@ -53,12 +56,6 @@ module BoxGrinder
|
|
53
56
|
mounts
|
54
57
|
end
|
55
58
|
|
56
|
-
def get_filesystem_type(device, default_type = 'ext3')
|
57
|
-
fs_type = @exec_helper.execute("df -T #{device} | tail -1 | awk '{print $2}'")
|
58
|
-
return default_type if fs_type.empty? or fs_type == '-'
|
59
|
-
fs_type
|
60
|
-
end
|
61
|
-
|
62
59
|
def umount_image(disk, mount_dir, mounts)
|
63
60
|
@log.debug "Unmounting image '#{File.basename(disk)}'..."
|
64
61
|
|
@@ -85,6 +82,8 @@ module BoxGrinder
|
|
85
82
|
|
86
83
|
@exec_helper.execute("losetup #{loop_device} #{disk}")
|
87
84
|
offsets = @exec_helper.execute("parted #{loop_device} 'unit B print' | grep -e '^ [0-9]' | awk '{ print $2 }'").scan(/\d+/)
|
85
|
+
# wait one secont before freeing loop device
|
86
|
+
sleep 1
|
88
87
|
@exec_helper.execute("losetup -d #{loop_device}")
|
89
88
|
|
90
89
|
@log.trace "Offsets:\n#{offsets}"
|
@@ -99,10 +98,20 @@ module BoxGrinder
|
|
99
98
|
end
|
100
99
|
|
101
100
|
def create_filesystem(disk, options = {})
|
102
|
-
options = {
|
101
|
+
options = {
|
102
|
+
:type => @appliance_config.hardware.partitions['/']['type'],
|
103
|
+
:label => '/'
|
104
|
+
}.merge(options)
|
103
105
|
|
104
106
|
@log.trace "Creating filesystem..."
|
105
|
-
|
107
|
+
|
108
|
+
case options[:type]
|
109
|
+
when 'ext3', 'ext4'
|
110
|
+
@exec_helper.execute "mke2fs -T #{options[:type]} -L '#{options[:label]}' -F #{disk}"
|
111
|
+
else
|
112
|
+
raise "Unsupported filesystem specified: #{options[:type]}"
|
113
|
+
end
|
114
|
+
|
106
115
|
@log.trace "Filesystem created"
|
107
116
|
end
|
108
117
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-core/helpers/exec-helper'
|
20
|
+
require 'boxgrinder-core/helpers/log-helper'
|
20
21
|
require 'boxgrinder-build/helpers/image-helper'
|
21
22
|
require 'ostruct'
|
22
23
|
require 'openhash/openhash'
|
@@ -32,7 +33,7 @@ module BoxGrinder
|
|
32
33
|
|
33
34
|
@log = options[:log] || Logger.new(STDOUT)
|
34
35
|
@exec_helper = options[:exec_helper] || ExecHelper.new(:log => @log)
|
35
|
-
@image_helper = options[:image_helper] || ImageHelper.new(:log => @log)
|
36
|
+
@image_helper = options[:image_helper] || ImageHelper.new(@config, @appliance_config, :log => @log)
|
36
37
|
|
37
38
|
@plugin_info = options[:plugin_info]
|
38
39
|
@previous_plugin_info = options[:previous_plugin_info]
|
@@ -84,7 +85,7 @@ module BoxGrinder
|
|
84
85
|
def supported_oses
|
85
86
|
supported = ""
|
86
87
|
|
87
|
-
@supported_oses.each do |name, versions|
|
88
|
+
@supported_oses.sort.each do |name, versions|
|
88
89
|
supported << ", " unless supported.empty?
|
89
90
|
supported << "#{name} (versions: #{versions.join(", ")})"
|
90
91
|
end
|
@@ -5,12 +5,13 @@
|
|
5
5
|
|
6
6
|
Summary: A tool for creating appliances from simple plain text files
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.6.
|
8
|
+
Version: 0.6.3
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
|
-
License:
|
11
|
+
License: LGPLv3+
|
12
12
|
URL: http://www.jboss.org/boxgrinder
|
13
13
|
Source0: http://rubygems.org/gems/%{gemname}-%{version}.gem
|
14
|
+
Buildroot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
14
15
|
|
15
16
|
Requires: ruby(abi) = %{rubyabi}
|
16
17
|
Requires: rubygems >= 1.2
|
@@ -19,8 +20,9 @@ Requires: rubygem(commander) => 4.0.3
|
|
19
20
|
Requires: rubygem(commander) < 4.1
|
20
21
|
Requires: rubygem(boxgrinder-core) => 0.1.1
|
21
22
|
Requires: rubygem(boxgrinder-core) < 0.2
|
22
|
-
|
23
|
-
BuildRequires:
|
23
|
+
|
24
|
+
BuildRequires: rubygem(boxgrinder-core) => 0.1.1
|
25
|
+
BuildRequires: rubygem(boxgrinder-core) < 0.2
|
24
26
|
|
25
27
|
BuildArch: noarch
|
26
28
|
Provides: rubygem(%{gemname}) = %{version}
|
@@ -29,6 +31,14 @@ Provides: rubygem(%{gemname}) = %{version}
|
|
29
31
|
A tool for creating appliances from simple plain text files for various
|
30
32
|
virtual environments
|
31
33
|
|
34
|
+
%package doc
|
35
|
+
Summary: Documentation for %{name}
|
36
|
+
Group: Documentation
|
37
|
+
Requires:%{name} = %{version}-%{release}
|
38
|
+
|
39
|
+
%description doc
|
40
|
+
Documentation for %{name}
|
41
|
+
|
32
42
|
%prep
|
33
43
|
|
34
44
|
%build
|
@@ -43,6 +53,12 @@ mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
|
|
43
53
|
rmdir %{buildroot}%{gemdir}/bin
|
44
54
|
find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
|
45
55
|
|
56
|
+
%check
|
57
|
+
pushd %{buildroot}/%{geminstdir}
|
58
|
+
rake spec
|
59
|
+
rm -rf log
|
60
|
+
popd
|
61
|
+
|
46
62
|
%clean
|
47
63
|
rm -rf %{buildroot}
|
48
64
|
|
@@ -52,19 +68,26 @@ rm -rf %{buildroot}
|
|
52
68
|
%dir %{geminstdir}
|
53
69
|
%{geminstdir}/bin
|
54
70
|
%{geminstdir}/lib
|
55
|
-
%doc %{gemdir}/doc/%{gemname}-%{version}
|
56
|
-
%doc %{geminstdir}/%{gemname}.gemspec
|
57
|
-
%doc %{geminstdir}/rubygem-%{gemname}.spec
|
58
71
|
%doc %{geminstdir}/CHANGELOG
|
59
72
|
%doc %{geminstdir}/LICENSE
|
60
73
|
%doc %{geminstdir}/README
|
61
74
|
%doc %{geminstdir}/Manifest
|
62
|
-
%doc %{geminstdir}/Rakefile
|
63
|
-
%doc %{geminstdir}/spec
|
64
75
|
%{gemdir}/cache/%{gemname}-%{version}.gem
|
65
76
|
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
|
66
77
|
|
78
|
+
%files doc
|
79
|
+
%defattr(-, root, root, -)
|
80
|
+
%{geminstdir}/spec
|
81
|
+
%{geminstdir}/Rakefile
|
82
|
+
%{geminstdir}/rubygem-%{gemname}.spec
|
83
|
+
%{geminstdir}/%{gemname}.gemspec
|
84
|
+
%{gemdir}/doc/%{gemname}-%{version}
|
85
|
+
|
67
86
|
%changelog
|
87
|
+
* Tue Nov 09 2010 <mgoldman@redhat.com> - 0.6.3-1
|
88
|
+
- [BGBUILD-94] Check if set_network call is avaialbe in libguestfs
|
89
|
+
- Added 'check' section that executes tests
|
90
|
+
|
68
91
|
* Wed Nov 03 2010 <mgoldman@redhat.com> - 0.6.2-1
|
69
92
|
- [BGBUILD-84] Don't use in libguestfs qemu-kvm where hardware accleration isn't available
|
70
93
|
|
data/spec/Rakefile
CHANGED
data/spec/appliance-spec.rb
CHANGED
@@ -16,41 +16,66 @@
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
|
+
require 'rubygems'
|
19
20
|
require 'boxgrinder-build/appliance'
|
20
|
-
require 'rspec/rspec-config-helper'
|
21
|
+
#require 'rspec/rspec-config-helper'
|
21
22
|
require 'ostruct'
|
23
|
+
require 'logger'
|
22
24
|
|
23
25
|
module BoxGrinder
|
24
26
|
describe Appliance do
|
25
|
-
|
26
|
-
|
27
|
-
before(:all) do
|
28
|
-
@arch = `uname -m`.chomp.strip
|
29
|
-
end
|
30
|
-
|
31
|
-
def prepare_appliance( options = OpenStruct.new )
|
27
|
+
def prepare_appliance(options = OpenStruct.new)
|
32
28
|
options.name = 'boxgrinder'
|
33
29
|
options.version = '1.0'
|
34
30
|
|
35
31
|
@options = options
|
36
32
|
@log = Logger.new('/dev/null')
|
37
33
|
|
38
|
-
@plugin_manager = mock(
|
34
|
+
@plugin_manager = mock(PluginManager)
|
39
35
|
|
40
|
-
PluginManager.stub!(:instance).and_return(
|
36
|
+
PluginManager.stub!(:instance).and_return(@plugin_manager)
|
41
37
|
|
42
|
-
@appliance = Appliance.new(
|
38
|
+
@appliance = Appliance.new("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.appl", :log => @log, :options => @options)
|
43
39
|
end
|
44
40
|
|
45
|
-
|
46
|
-
|
41
|
+
def prepare_appliance_config
|
42
|
+
@appliance_config = mock('ApplianceConfig')
|
43
|
+
|
44
|
+
@appliance_config.stub!(:path).and_return(OpenHash.new({:build => 'build/path'}))
|
45
|
+
@appliance_config.stub!(:name).and_return('full')
|
46
|
+
@appliance_config.stub!(:summary).and_return('asd')
|
47
|
+
@appliance_config.stub!(:version).and_return(1)
|
48
|
+
@appliance_config.stub!(:release).and_return(0)
|
49
|
+
@appliance_config.stub!(:os).and_return(OpenHash.new({:name => 'fedora', :version => '11'}))
|
50
|
+
|
51
|
+
@appliance_config.stub!(:hardware).and_return(
|
52
|
+
OpenHash.new({
|
53
|
+
:partitions =>
|
54
|
+
{
|
55
|
+
'/' => {'size' => 2},
|
56
|
+
'/home' => {'size' => 3},
|
57
|
+
},
|
58
|
+
:arch => 'i686',
|
59
|
+
:base_arch => 'i386',
|
60
|
+
:cpus => 1,
|
61
|
+
:memory => 256,
|
62
|
+
})
|
63
|
+
)
|
64
|
+
|
65
|
+
@appliance_config
|
47
66
|
end
|
48
67
|
|
68
|
+
# before(:each) do
|
69
|
+
# prepare_appliance
|
70
|
+
# end
|
71
|
+
|
49
72
|
it "should prepare appliance to build" do
|
73
|
+
prepare_appliance
|
74
|
+
|
50
75
|
plugin_helper = mock(PluginHelper)
|
51
76
|
plugin_helper.should_receive(:load_plugins)
|
52
77
|
|
53
|
-
PluginHelper.should_receive(
|
78
|
+
PluginHelper.should_receive(:new).with(:options => @options, :log => @log).and_return(plugin_helper)
|
54
79
|
|
55
80
|
@appliance.should_receive(:read_and_validate_definition)
|
56
81
|
@appliance.should_not_receive(:remove_old_builds)
|
@@ -60,12 +85,12 @@ module BoxGrinder
|
|
60
85
|
end
|
61
86
|
|
62
87
|
it "should prepare appliance to build with removing old files" do
|
63
|
-
prepare_appliance(
|
88
|
+
prepare_appliance(OpenStruct.new(:force => true))
|
64
89
|
|
65
90
|
plugin_helper = mock(PluginHelper)
|
66
91
|
plugin_helper.should_receive(:load_plugins)
|
67
92
|
|
68
|
-
PluginHelper.should_receive(
|
93
|
+
PluginHelper.should_receive(:new).with(:options => @options, :log => @log).and_return(plugin_helper)
|
69
94
|
|
70
95
|
@appliance.should_receive(:read_and_validate_definition)
|
71
96
|
@appliance.should_receive(:remove_old_builds)
|
@@ -75,12 +100,14 @@ module BoxGrinder
|
|
75
100
|
end
|
76
101
|
|
77
102
|
it "should read and validate definition" do
|
103
|
+
prepare_appliance
|
104
|
+
|
78
105
|
appliance_config = ApplianceConfig.new
|
79
106
|
|
80
107
|
appliance_helper = mock(ApplianceHelper)
|
81
|
-
appliance_helper.should_receive(:read_definitions).with(
|
108
|
+
appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.appl").and_return([{}, appliance_config])
|
82
109
|
|
83
|
-
ApplianceHelper.should_receive(:new).with(
|
110
|
+
ApplianceHelper.should_receive(:new).with(:log => @log).and_return(appliance_helper)
|
84
111
|
|
85
112
|
appliance_config_helper = mock(ApplianceConfigHelper)
|
86
113
|
|
@@ -88,120 +115,126 @@ module BoxGrinder
|
|
88
115
|
appliance_config.should_receive(:init_arch).and_return(appliance_config)
|
89
116
|
appliance_config.should_receive(:initialize_paths).and_return(appliance_config)
|
90
117
|
|
91
|
-
appliance_config_helper.should_receive(:merge).with(
|
118
|
+
appliance_config_helper.should_receive(:merge).with(appliance_config).and_return(appliance_config)
|
92
119
|
|
93
|
-
ApplianceConfigHelper.should_receive(:new).with(
|
120
|
+
ApplianceConfigHelper.should_receive(:new).with({}).and_return(appliance_config_helper)
|
94
121
|
|
95
122
|
appliance_config_validator = mock(ApplianceConfigValidator)
|
96
123
|
appliance_config_validator.should_receive(:validate)
|
97
124
|
|
98
|
-
ApplianceConfigValidator.should_receive(:new).with(
|
125
|
+
ApplianceConfigValidator.should_receive(:new).with(appliance_config).and_return(appliance_config_validator)
|
99
126
|
|
100
127
|
@appliance.read_and_validate_definition
|
101
128
|
end
|
102
129
|
|
103
130
|
it "should remove old builds" do
|
104
|
-
|
105
|
-
|
131
|
+
prepare_appliance
|
132
|
+
|
133
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
134
|
+
FileUtils.should_receive(:rm_rf).with("build/path")
|
106
135
|
@appliance.remove_old_builds
|
107
136
|
end
|
108
137
|
|
109
138
|
it "should build base appliance" do
|
110
|
-
|
139
|
+
prepare_appliance
|
140
|
+
|
141
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
111
142
|
|
112
143
|
os_plugin = mock('FedoraPlugin')
|
113
144
|
os_plugin.should_receive(:init)
|
114
145
|
os_plugin.should_receive(:deliverables_exists?).and_return(false)
|
115
146
|
os_plugin.should_receive(:run)
|
116
|
-
os_plugin.should_receive(:deliverables).and_return({
|
147
|
+
os_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
|
117
148
|
|
118
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
119
|
-
@plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([
|
149
|
+
@plugin_manager.should_receive(:plugins).and_return({:os => "something"})
|
150
|
+
@plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
|
120
151
|
|
121
152
|
@appliance.execute_plugin_chain
|
122
153
|
end
|
123
154
|
|
124
155
|
it "should not build base appliance because deliverable already exists" do
|
125
|
-
|
156
|
+
prepare_appliance
|
157
|
+
|
158
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
126
159
|
|
127
160
|
os_plugin = mock('FedoraPlugin')
|
128
161
|
os_plugin.should_receive(:init)
|
129
162
|
os_plugin.should_receive(:deliverables_exists?).and_return(true)
|
130
163
|
os_plugin.should_not_receive(:run)
|
131
|
-
os_plugin.should_receive(:deliverables).and_return({
|
164
|
+
os_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
|
132
165
|
|
133
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
134
|
-
@plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([
|
166
|
+
@plugin_manager.should_receive(:plugins).and_return({:os => "something"})
|
167
|
+
@plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
|
135
168
|
|
136
169
|
@appliance.execute_plugin_chain
|
137
170
|
end
|
138
171
|
|
139
172
|
it "should build appliance and convert it to VMware format" do
|
140
|
-
prepare_appliance(
|
173
|
+
prepare_appliance(OpenStruct.new({:platform => :vmware}))
|
141
174
|
|
142
|
-
@appliance.instance_variable_set(:@appliance_config,
|
143
|
-
@appliance.should_receive(
|
175
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
176
|
+
@appliance.should_receive(:execute_os_plugin).and_return({})
|
144
177
|
|
145
178
|
platform_plugin = mock('VMware Plugin')
|
146
179
|
platform_plugin.should_receive(:init)
|
147
180
|
platform_plugin.should_receive(:deliverables_exists?).and_return(false)
|
148
181
|
platform_plugin.should_receive(:run)
|
149
|
-
platform_plugin.should_receive(:deliverables).and_return({
|
182
|
+
platform_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
|
150
183
|
|
151
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
152
|
-
@plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([
|
184
|
+
@plugin_manager.should_receive(:plugins).and_return({:platform => "something"})
|
185
|
+
@plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
|
153
186
|
|
154
187
|
@appliance.execute_plugin_chain
|
155
188
|
end
|
156
189
|
|
157
190
|
it "should build appliance and convert it to VMware format because deliverable already exists" do
|
158
|
-
prepare_appliance(
|
191
|
+
prepare_appliance(OpenStruct.new({:platform => :vmware}))
|
159
192
|
|
160
|
-
@appliance.instance_variable_set(:@appliance_config,
|
161
|
-
@appliance.should_receive(
|
193
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
194
|
+
@appliance.should_receive(:execute_os_plugin).and_return({})
|
162
195
|
|
163
196
|
platform_plugin = mock('VMware Plugin')
|
164
197
|
platform_plugin.should_receive(:init)
|
165
198
|
platform_plugin.should_receive(:deliverables_exists?).and_return(true)
|
166
199
|
platform_plugin.should_not_receive(:run)
|
167
|
-
platform_plugin.should_receive(:deliverables).and_return({
|
200
|
+
platform_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
|
168
201
|
|
169
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
170
|
-
@plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([
|
202
|
+
@plugin_manager.should_receive(:plugins).and_return({:platform => "something"})
|
203
|
+
@plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
|
171
204
|
|
172
205
|
@appliance.execute_plugin_chain
|
173
206
|
end
|
174
207
|
|
175
208
|
it "should build appliance, convert it to EC2 format and deliver it using S3 ami type" do
|
176
|
-
prepare_appliance(
|
209
|
+
prepare_appliance(OpenStruct.new({:platform => :ec2, :delivery => :ami}))
|
177
210
|
|
178
|
-
@appliance.instance_variable_set(:@appliance_config,
|
179
|
-
@appliance.should_receive(
|
180
|
-
@appliance.should_receive(
|
211
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
212
|
+
@appliance.should_receive(:execute_os_plugin).and_return({:abc => 'def'})
|
213
|
+
@appliance.should_receive(:execute_platform_plugin).with({:abc => 'def'}).and_return({:def => 'ghi'})
|
181
214
|
|
182
215
|
delivery_plugin = mock('S3 Plugin')
|
183
216
|
delivery_plugin.should_receive(:init)
|
184
217
|
delivery_plugin.should_receive(:run).with(:ami)
|
185
218
|
|
186
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
187
|
-
@plugin_manager.should_receive(:initialize_plugin).with(:delivery, :ami).and_return([
|
219
|
+
@plugin_manager.should_receive(:plugins).and_return({:delivery => "something"})
|
220
|
+
@plugin_manager.should_receive(:initialize_plugin).with(:delivery, :ami).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :s3, :full_name => "Amazon Simple Storage Service (Amazon S3)", :types => [:s3, :cloudfront, :ami]}])
|
188
221
|
|
189
222
|
@appliance.execute_plugin_chain
|
190
223
|
end
|
191
224
|
|
192
225
|
it "should build appliance, convert it to EC2 format and deliver it using delivery plugin with only one delivery type" do
|
193
|
-
prepare_appliance(
|
226
|
+
prepare_appliance(OpenStruct.new({:platform => :ec2, :delivery => :same}))
|
194
227
|
|
195
|
-
@appliance.instance_variable_set(:@appliance_config,
|
196
|
-
@appliance.should_receive(
|
197
|
-
@appliance.should_receive(
|
228
|
+
@appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
|
229
|
+
@appliance.should_receive(:execute_os_plugin).and_return({:abc => 'def'})
|
230
|
+
@appliance.should_receive(:execute_platform_plugin).with({:abc => 'def'}).and_return({:def => 'ghi'})
|
198
231
|
|
199
232
|
delivery_plugin = mock('S3 Plugin')
|
200
233
|
delivery_plugin.should_receive(:init)
|
201
|
-
delivery_plugin.should_receive(:run).with(
|
234
|
+
delivery_plugin.should_receive(:run).with(:same)
|
202
235
|
|
203
|
-
@plugin_manager.should_receive(:plugins).and_return(
|
204
|
-
@plugin_manager.should_receive(:initialize_plugin).with(:delivery, :same).and_return([
|
236
|
+
@plugin_manager.should_receive(:plugins).and_return({:delivery => "something"})
|
237
|
+
@plugin_manager.should_receive(:initialize_plugin).with(:delivery, :same).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :same, :full_name => "A plugin"}])
|
205
238
|
|
206
239
|
@appliance.execute_plugin_chain
|
207
240
|
end
|
@@ -17,14 +17,40 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-build/helpers/appliance-customize-helper'
|
20
|
-
require 'rspec/rspec-config-helper'
|
21
20
|
|
22
21
|
module BoxGrinder
|
23
22
|
describe ApplianceCustomizeHelper do
|
24
|
-
include RSpecConfigHelper
|
25
23
|
|
26
24
|
before(:each) do
|
27
|
-
@
|
25
|
+
@config = mock('Config')
|
26
|
+
@config.stub!(:name).and_return('BoxGrinder')
|
27
|
+
@config.stub!(:version_with_release).and_return('0.1.2')
|
28
|
+
|
29
|
+
@appliance_config = mock('ApplianceConfig')
|
30
|
+
|
31
|
+
@appliance_config.stub!(:path).and_return(OpenHash.new({:build => 'build/path'}))
|
32
|
+
@appliance_config.stub!(:name).and_return('full')
|
33
|
+
@appliance_config.stub!(:summary).and_return('asd')
|
34
|
+
@appliance_config.stub!(:version).and_return(1)
|
35
|
+
@appliance_config.stub!(:release).and_return(0)
|
36
|
+
@appliance_config.stub!(:os).and_return(OpenHash.new({:name => 'fedora', :version => '11'}))
|
37
|
+
@appliance_config.stub!(:post).and_return(OpenHash.new({:vmware => []}))
|
38
|
+
|
39
|
+
@appliance_config.stub!(:hardware).and_return(
|
40
|
+
OpenHash.new({
|
41
|
+
:partitions =>
|
42
|
+
{
|
43
|
+
'/' => {'size' => 2},
|
44
|
+
'/home' => {'size' => 3},
|
45
|
+
},
|
46
|
+
:arch => 'i686',
|
47
|
+
:base_arch => 'i386',
|
48
|
+
:cpus => 1,
|
49
|
+
:memory => 256,
|
50
|
+
})
|
51
|
+
)
|
52
|
+
|
53
|
+
@helper = ApplianceCustomizeHelper.new(@config, @appliance_config, 'a/disk', :log => Logger.new('/dev/null'))
|
28
54
|
|
29
55
|
@log = @helper.instance_variable_get(:@log)
|
30
56
|
end
|
@@ -37,11 +63,11 @@ module BoxGrinder
|
|
37
63
|
guestfs_helper.should_receive(:guestfs).and_return(guestfs)
|
38
64
|
guestfs_helper.should_receive(:clean_close)
|
39
65
|
|
40
|
-
GuestFSHelper.should_receive(:new).with('a/disk', :log => @log
|
66
|
+
GuestFSHelper.should_receive(:new).with('a/disk', :log => @log).and_return(guestfs_helper)
|
41
67
|
|
42
68
|
@helper.customize do |gf, gf_helper|
|
43
|
-
gf_helper.should
|
44
|
-
gf.should
|
69
|
+
gf_helper.should == guestfs_helper
|
70
|
+
gf.should == guestfs
|
45
71
|
end
|
46
72
|
end
|
47
73
|
end
|
@@ -27,7 +27,7 @@ module BoxGrinder
|
|
27
27
|
@guestfs = mock('GuestFS')
|
28
28
|
@guestfs_helper = mock('GuestFSHelper')
|
29
29
|
|
30
|
-
@helper = AugeasHelper.new(
|
30
|
+
@helper = AugeasHelper.new(@guestfs, @guestfs_helper, :log => @log)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not execute augeas commands if there a no files to change" do
|
@@ -36,6 +36,7 @@ module BoxGrinder
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should change configuration for one file" do
|
39
|
+
@guestfs.should_receive(:debug).with("help", []).and_return("core_pattern")
|
39
40
|
@guestfs.should_receive(:debug).with("core_pattern", ["/sysroot/core"])
|
40
41
|
@guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
|
41
42
|
@guestfs.should_receive(:aug_init).with('/', 32)
|
@@ -45,11 +46,12 @@ module BoxGrinder
|
|
45
46
|
@guestfs.should_receive(:aug_save)
|
46
47
|
|
47
48
|
@helper.edit do
|
48
|
-
set(
|
49
|
+
set('/etc/ssh/sshd_config', 'UseDNS', 'no')
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should change configuration for two files" do
|
54
|
+
@guestfs.should_receive(:debug).with("help", []).and_return("core_pattern")
|
53
55
|
@guestfs.should_receive(:debug).with("core_pattern", ["/sysroot/core"])
|
54
56
|
@guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
|
55
57
|
@guestfs.should_receive(:exists).with('/etc/sysconfig/selinux').and_return(1)
|
@@ -61,12 +63,13 @@ module BoxGrinder
|
|
61
63
|
@guestfs.should_receive(:aug_save)
|
62
64
|
|
63
65
|
@helper.edit do
|
64
|
-
set(
|
65
|
-
set(
|
66
|
+
set('/etc/ssh/sshd_config', 'UseDNS', 'no')
|
67
|
+
set('/etc/sysconfig/selinux', 'SELINUX', 'permissive')
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
it "should change one configuration for two files because one file doesn't exists" do
|
72
|
+
@guestfs.should_receive(:debug).with("help", []).and_return("core_pattern")
|
70
73
|
@guestfs.should_receive(:debug).with("core_pattern", ["/sysroot/core"])
|
71
74
|
@guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
|
72
75
|
@guestfs.should_receive(:exists).with('/etc/sysconfig/selinux').and_return(0)
|
@@ -77,8 +80,23 @@ module BoxGrinder
|
|
77
80
|
@guestfs.should_receive(:aug_save)
|
78
81
|
|
79
82
|
@helper.edit do
|
80
|
-
set(
|
81
|
-
set(
|
83
|
+
set('/etc/ssh/sshd_config', 'UseDNS', 'no')
|
84
|
+
set('/etc/sysconfig/selinux', 'SELINUX', 'permissive')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not set core_patter debug method because it's not supported" do
|
89
|
+
@guestfs.should_receive(:debug).with("help", []).and_return("something")
|
90
|
+
@guestfs.should_not_receive(:debug).with("core_pattern", ["/sysroot/core"])
|
91
|
+
@guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
|
92
|
+
@guestfs.should_receive(:aug_init).with('/', 32)
|
93
|
+
@guestfs.should_receive(:aug_rm).with("/augeas/load//incl[. != '/etc/ssh/sshd_config']")
|
94
|
+
@guestfs.should_receive(:aug_load)
|
95
|
+
@guestfs.should_receive(:aug_set).with("/files/etc/ssh/sshd_config/UseDNS", "no")
|
96
|
+
@guestfs.should_receive(:aug_save)
|
97
|
+
|
98
|
+
@helper.edit do
|
99
|
+
set('/etc/ssh/sshd_config', 'UseDNS', 'no')
|
82
100
|
end
|
83
101
|
end
|
84
102
|
end
|
@@ -22,7 +22,26 @@ module BoxGrinder
|
|
22
22
|
describe ImageHelper do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
@
|
25
|
+
@config = mock('Config')
|
26
|
+
|
27
|
+
@appliance_config = mock('ApplianceConfig')
|
28
|
+
|
29
|
+
@appliance_config.stub!(:name).and_return('full')
|
30
|
+
@appliance_config.stub!(:hardware).and_return(
|
31
|
+
OpenHash.new({
|
32
|
+
:partitions =>
|
33
|
+
{
|
34
|
+
'/' => {'size' => 2, 'type' => 'ext4'},
|
35
|
+
'/home' => {'size' => 3, 'type' => 'ext3'},
|
36
|
+
},
|
37
|
+
:arch => 'i686',
|
38
|
+
:base_arch => 'i386',
|
39
|
+
:cpus => 1,
|
40
|
+
:memory => 256,
|
41
|
+
})
|
42
|
+
)
|
43
|
+
|
44
|
+
@helper = ImageHelper.new(@config, @appliance_config, :log => Logger.new('/dev/null'))
|
26
45
|
|
27
46
|
@log = @helper.instance_variable_get(:@log)
|
28
47
|
@exec_helper = @helper.instance_variable_get(:@exec_helper)
|
@@ -34,8 +53,7 @@ module BoxGrinder
|
|
34
53
|
@helper.should_receive(:get_loop_device).and_return('/dev/loop0')
|
35
54
|
@exec_helper.should_receive(:execute).with('losetup -o 0 /dev/loop0 disk.raw')
|
36
55
|
@exec_helper.should_receive(:execute).with('e2label /dev/loop0').and_return('/')
|
37
|
-
@exec_helper.should_receive(:execute).with(
|
38
|
-
@exec_helper.should_receive(:execute).with('mount /dev/loop0 -t ext3 mount_dir')
|
56
|
+
@exec_helper.should_receive(:execute).with('mount /dev/loop0 mount_dir')
|
39
57
|
|
40
58
|
@helper.mount_image('disk.raw', 'mount_dir').should == {"/"=>"/dev/loop0"}
|
41
59
|
end
|
@@ -50,11 +68,8 @@ module BoxGrinder
|
|
50
68
|
@exec_helper.should_receive(:execute).with('losetup -o 562 /dev/loop1 disk.raw')
|
51
69
|
@exec_helper.should_receive(:execute).with('e2label /dev/loop1').and_return('_/')
|
52
70
|
|
53
|
-
@exec_helper.should_receive(:execute).with(
|
54
|
-
@exec_helper.should_receive(:execute).with(
|
55
|
-
|
56
|
-
@exec_helper.should_receive(:execute).with('mount /dev/loop1 -t ext3 mount_dir')
|
57
|
-
@exec_helper.should_receive(:execute).with('mount /dev/loop0 -t ext4 mount_dir/home')
|
71
|
+
@exec_helper.should_receive(:execute).with('mount /dev/loop1 mount_dir')
|
72
|
+
@exec_helper.should_receive(:execute).with('mount /dev/loop0 mount_dir/home')
|
58
73
|
|
59
74
|
@helper.mount_image('disk.raw', 'mount_dir').should == {"/"=>"/dev/loop1", "/home"=>"/dev/loop0"}
|
60
75
|
end
|
@@ -100,15 +115,29 @@ module BoxGrinder
|
|
100
115
|
end
|
101
116
|
|
102
117
|
it "should create default filesystem on selected device" do
|
103
|
-
@exec_helper.should_receive(:execute).with("mke2fs -T
|
118
|
+
@exec_helper.should_receive(:execute).with("mke2fs -T ext4 -L '/' -F /dev/loop0")
|
104
119
|
|
105
120
|
@helper.create_filesystem('/dev/loop0')
|
106
121
|
end
|
107
122
|
|
108
123
|
it "should create ext4 filesystem on selected device" do
|
109
|
-
@
|
124
|
+
@appliance_config.should_receive(:hardware).and_return(
|
125
|
+
OpenHash.new({
|
126
|
+
:partitions =>
|
127
|
+
{
|
128
|
+
'/' => {'size' => 2, 'type' => 'ext3'},
|
129
|
+
'/home' => {'size' => 3, 'type' => 'ext3'},
|
130
|
+
},
|
131
|
+
:arch => 'i686',
|
132
|
+
:base_arch => 'i386',
|
133
|
+
:cpus => 1,
|
134
|
+
:memory => 256,
|
135
|
+
})
|
136
|
+
)
|
110
137
|
|
111
|
-
@
|
138
|
+
@exec_helper.should_receive(:execute).with("mke2fs -T ext3 -L '/' -F /dev/loop0")
|
139
|
+
|
140
|
+
@helper.create_filesystem('/dev/loop0')
|
112
141
|
end
|
113
142
|
|
114
143
|
it "should create ext4 filesystem on selected device with a label" do
|
@@ -17,13 +17,10 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-build/helpers/plugin-helper'
|
20
|
-
require 'rspec/rspec-config-helper'
|
21
20
|
require 'ostruct'
|
22
21
|
|
23
22
|
module BoxGrinder
|
24
23
|
describe PluginHelper do
|
25
|
-
include RSpecConfigHelper
|
26
|
-
|
27
24
|
before(:all) do
|
28
25
|
@current_arch = (-1.size) == 8 ? "x86_64" : "i386"
|
29
26
|
@plugin_array = %w(boxgrinder-build-fedora-os-plugin boxgrinder-build-rhel-os-plugin boxgrinder-build-centos-os-plugin boxgrinder-build-ec2-platform-plugin boxgrinder-build-vmware-platform-plugin boxgrinder-build-s3-delivery-plugin boxgrinder-build-sftp-delivery-plugin boxgrinder-build-local-delivery-plugin boxgrinder-build-ebs-delivery-plugin)
|
@@ -16,20 +16,24 @@
|
|
16
16
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
|
+
require 'rubygems'
|
19
20
|
require 'boxgrinder-build/plugins/base-plugin'
|
20
|
-
require '
|
21
|
+
require 'yaml'
|
21
22
|
|
22
23
|
module BoxGrinder
|
23
24
|
describe BasePlugin do
|
24
|
-
|
25
|
+
before(:each) do
|
26
|
+
@config = mock('Config')
|
27
|
+
@config.stub!(:name).and_return('BoxGrinder')
|
28
|
+
@config.stub!(:version_with_release).and_return('0.1.2')
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
@appliance_config = mock('ApplianceConfig')
|
31
|
+
|
32
|
+
@appliance_config.stub!(:path).and_return(OpenHash.new({:build => 'build/path'}))
|
33
|
+
@appliance_config.stub!(:os).and_return(OpenHash.new({:name => 'fedora', :version => '11'}))
|
29
34
|
|
30
|
-
before(:each) do
|
31
35
|
@plugin = BasePlugin.new
|
32
|
-
@plugin.init(
|
36
|
+
@plugin.init(@config, @appliance_config, :plugin_info => {:name => :plugin_name}, :log => Logger.new('/dev/null'))
|
33
37
|
end
|
34
38
|
|
35
39
|
it "should be initialized after running init method" do
|
@@ -41,7 +45,7 @@ module BoxGrinder
|
|
41
45
|
|
42
46
|
deliverables = @plugin.instance_variable_get(:@deliverables)
|
43
47
|
|
44
|
-
deliverables.disk.should == "build/
|
48
|
+
deliverables.disk.should == "build/path/plugin_name-plugin/tmp/name"
|
45
49
|
end
|
46
50
|
|
47
51
|
it "should register a metadata deliverable" do
|
@@ -50,7 +54,7 @@ module BoxGrinder
|
|
50
54
|
deliverables = @plugin.instance_variable_get(:@deliverables)
|
51
55
|
|
52
56
|
deliverables.size.should == 1
|
53
|
-
deliverables.a_name.should == "build/
|
57
|
+
deliverables.a_name.should == "build/path/plugin_name-plugin/tmp/a_path"
|
54
58
|
end
|
55
59
|
|
56
60
|
it "should register multiple other deliverables" do
|
@@ -59,12 +63,12 @@ module BoxGrinder
|
|
59
63
|
deliverables = @plugin.instance_variable_get(:@deliverables)
|
60
64
|
|
61
65
|
deliverables.size.should == 2
|
62
|
-
deliverables.a_name.should == "build/
|
63
|
-
deliverables.a_second_name.should == "build/
|
66
|
+
deliverables.a_name.should == "build/path/plugin_name-plugin/tmp/a_path"
|
67
|
+
deliverables.a_second_name.should == "build/path/plugin_name-plugin/tmp/a_path_too"
|
64
68
|
end
|
65
69
|
|
66
70
|
it "should have a valid path to tmp directory" do
|
67
|
-
@plugin.instance_variable_get(:@dir).tmp.should == "build/
|
71
|
+
@plugin.instance_variable_get(:@dir).tmp.should == "build/path/plugin_name-plugin/tmp"
|
68
72
|
end
|
69
73
|
|
70
74
|
it "should check if deliverables exists and return true" do
|
@@ -92,13 +96,13 @@ module BoxGrinder
|
|
92
96
|
it "should run the plugin" do
|
93
97
|
@plugin.register_deliverable(:disk => "disk")
|
94
98
|
|
95
|
-
FileUtils.should_receive(:rm_rf).with("build/
|
96
|
-
FileUtils.should_receive(:mkdir_p).with("build/
|
99
|
+
FileUtils.should_receive(:rm_rf).with("build/path/plugin_name-plugin/tmp")
|
100
|
+
FileUtils.should_receive(:mkdir_p).with("build/path/plugin_name-plugin/tmp")
|
97
101
|
|
98
102
|
@plugin.should_receive(:execute).with('a', 3)
|
99
103
|
|
100
|
-
FileUtils.should_receive(:mv).with("build/
|
101
|
-
FileUtils.should_receive(:rm_rf).with("build/
|
104
|
+
FileUtils.should_receive(:mv).with("build/path/plugin_name-plugin/tmp/disk", "build/path/plugin_name-plugin/disk")
|
105
|
+
FileUtils.should_receive(:rm_rf).with("build/path/plugin_name-plugin/tmp")
|
102
106
|
|
103
107
|
@plugin.run('a', 3)
|
104
108
|
end
|
@@ -135,7 +139,7 @@ module BoxGrinder
|
|
135
139
|
@plugin.register_supported_os('fedora', ['12', '13'])
|
136
140
|
@plugin.register_supported_os('centos', ['5'])
|
137
141
|
|
138
|
-
@plugin.supported_oses.should == "
|
142
|
+
@plugin.supported_oses.should == "centos (versions: 5), fedora (versions: 12, 13)"
|
139
143
|
end
|
140
144
|
|
141
145
|
it "should set default config value" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxgrinder-build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 3
|
10
|
+
version: 0.6.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-11 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 31
|
46
46
|
segments:
|
47
47
|
- 0
|
48
48
|
- 1
|
49
|
-
-
|
50
|
-
version: 0.1.
|
49
|
+
- 2
|
50
|
+
version: 0.1.2
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
description: A tool for creating appliances from simple plain text files for various virtual environments.
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- README
|
79
79
|
- Rakefile
|
80
80
|
- bin/boxgrinder-build
|
81
|
+
- boxgrinder-build.gemspec
|
81
82
|
- lib/boxgrinder-build/appliance.rb
|
82
83
|
- lib/boxgrinder-build/helpers/appliance-customize-helper.rb
|
83
84
|
- lib/boxgrinder-build/helpers/augeas-helper.rb
|
@@ -101,7 +102,6 @@ files:
|
|
101
102
|
- spec/managers/plugin-manager-spec.rb
|
102
103
|
- spec/plugins/base-plugin-spec.rb
|
103
104
|
- spec/rspec/src/appliances/jeos-f13.appl
|
104
|
-
- boxgrinder-build.gemspec
|
105
105
|
has_rdoc: true
|
106
106
|
homepage: http://www.jboss.org/boxgrinder
|
107
107
|
licenses: []
|