boxgrinder-build 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/boxgrinder-build +5 -2
- data/lib/boxgrinder-build/appliance.rb +7 -4
- data/lib/boxgrinder-build/plugins/base-plugin.rb +1 -1
- data/lib/boxgrinder-build/plugins/os/base/kickstart.rb +0 -1
- data/lib/boxgrinder-build/plugins/os/base/rhel-based-os-plugin.rb +51 -0
- data/lib/boxgrinder-build/plugins/os/base/rpm-based-os-plugin.rb +6 -1
- data/lib/boxgrinder-build/plugins/os/base/validators/rpm-dependency-validator.rb +1 -1
- data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +4 -24
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +5 -3
- metadata +6 -5
data/bin/boxgrinder-build
CHANGED
@@ -26,7 +26,7 @@ require 'boxgrinder-core/helpers/log-helper'
|
|
26
26
|
require 'boxgrinder-build/helpers/plugin-helper'
|
27
27
|
require 'boxgrinder-build/appliance'
|
28
28
|
|
29
|
-
gem 'boxgrinder-core', '>= 0.0.
|
29
|
+
gem 'boxgrinder-core', '>= 0.0.9'
|
30
30
|
gem 'aws-s3', '>= 0.6.2'
|
31
31
|
gem 'amazon-ec2', '>= 0.9.6'
|
32
32
|
gem 'net-sftp', '>= 2.0.4'
|
@@ -40,7 +40,7 @@ gem 'commander', '>= 4.0.3'
|
|
40
40
|
#$stderr.reopen('/dev/null')
|
41
41
|
|
42
42
|
program :name, 'BoxGrinder'
|
43
|
-
program :version, '0.3.
|
43
|
+
program :version, '0.3.5'
|
44
44
|
program :description, 'A tool for building VM images from simple definition files.'
|
45
45
|
default_command :build
|
46
46
|
|
@@ -66,6 +66,9 @@ module BoxGrinder
|
|
66
66
|
options.default :delivery => :none
|
67
67
|
options.default :force => false
|
68
68
|
|
69
|
+
options.name = program(:name)
|
70
|
+
options.version = program(:version)
|
71
|
+
|
69
72
|
options.verbose = $verbose
|
70
73
|
options.platform = options.platform.to_s.downcase.to_sym
|
71
74
|
options.delivery = options.delivery.to_s.downcase.to_sym
|
@@ -28,11 +28,14 @@ require 'boxgrinder-core/validators/appliance-config-validator'
|
|
28
28
|
module BoxGrinder
|
29
29
|
class Appliance < Rake::TaskLib
|
30
30
|
|
31
|
-
def initialize(
|
32
|
-
@config
|
31
|
+
def initialize( appliance_definition_file, options = {} )
|
32
|
+
@config = Config.new
|
33
33
|
@appliance_definition_file = appliance_definition_file
|
34
|
-
@log
|
35
|
-
@options
|
34
|
+
@log = options[:log] || Logger.new(STDOUT)
|
35
|
+
@options = options[:options]
|
36
|
+
|
37
|
+
@config.name = @options.name
|
38
|
+
@config.version = @options.version
|
36
39
|
end
|
37
40
|
|
38
41
|
def create
|
@@ -34,13 +34,13 @@ module BoxGrinder
|
|
34
34
|
@plugin_helper = options[:plugin_helper] || PluginHelper.new( :log => @log )
|
35
35
|
|
36
36
|
@plugin_config = {}
|
37
|
+
@deliverables = Hash.new({})
|
37
38
|
|
38
39
|
if self.respond_to?(:info)
|
39
40
|
@config_file = "#{ENV['HOME']}/.boxgrinder/plugins/#{self.info[:name]}"
|
40
41
|
|
41
42
|
read_plugin_config
|
42
43
|
|
43
|
-
@deliverables = Hash.new({})
|
44
44
|
@deliverables[:disk] = nil
|
45
45
|
@deliverables[:platform] = self.info[:name]
|
46
46
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# JBoss, Home of Professional Open Source
|
2
|
+
# Copyright 2009, Red Hat Middleware LLC, and individual contributors
|
3
|
+
# by the @authors tag. See the copyright.txt in the distribution for a
|
4
|
+
# full listing of individual contributors.
|
5
|
+
#
|
6
|
+
# This is free software; you can redistribute it and/or modify it
|
7
|
+
# under the terms of the GNU Lesser General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2.1 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This software is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this software; if not, write to the Free
|
18
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
19
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
|
+
|
21
|
+
require 'boxgrinder-build/plugins/os/base/rpm-based-os-plugin'
|
22
|
+
|
23
|
+
module BoxGrinder
|
24
|
+
class RHELBasedOSPlugin < RPMBasedOSPlugin
|
25
|
+
def build_rhel( repos = {} )
|
26
|
+
adjust_partition_table
|
27
|
+
|
28
|
+
disk_path = build_with_appliance_creator( repos ) do |guestfs, guestfs_helper|
|
29
|
+
kernel_version = guestfs.ls("/lib/modules").first
|
30
|
+
|
31
|
+
@log.debug "Recreating initrd for #{kernel_version} kernel..."
|
32
|
+
guestfs.sh( "/sbin/mkinitrd -f -v --preload=mptspi /boot/initrd-#{kernel_version}.img #{kernel_version}" )
|
33
|
+
@log.debug "Initrd recreated."
|
34
|
+
|
35
|
+
@log.debug "Applying root password..."
|
36
|
+
guestfs.sh( "/usr/bin/passwd -d root" )
|
37
|
+
guestfs.sh( "/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map{65.+(rand(25)).chr}.join)}' root" )
|
38
|
+
@log.debug "Password applied."
|
39
|
+
end
|
40
|
+
|
41
|
+
@log.info "Done."
|
42
|
+
|
43
|
+
disk_path
|
44
|
+
end
|
45
|
+
|
46
|
+
# https://bugzilla.redhat.com/show_bug.cgi?id=466275
|
47
|
+
def adjust_partition_table
|
48
|
+
@appliance_config.hardware.partitions['/boot'] = { 'root' => '/boot', 'size' => 0.1 } if @appliance_config.hardware.partitions['/boot'].nil?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -30,7 +30,7 @@ module BoxGrinder
|
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
33
|
-
def build_with_appliance_creator( repos )
|
33
|
+
def build_with_appliance_creator( repos = {} )
|
34
34
|
Kickstart.new( @config, @appliance_config, repos, :log => @log ).create
|
35
35
|
RPMDependencyValidator.new( @config, @appliance_config, @options ).resolve_packages
|
36
36
|
|
@@ -124,6 +124,11 @@ module BoxGrinder
|
|
124
124
|
def install_repos( guestfs )
|
125
125
|
@log.debug "Installing repositories from appliance definition file..."
|
126
126
|
@appliance_config.repos.each do |repo|
|
127
|
+
if repo['ephemeral']
|
128
|
+
@log.debug "Repository '#{repo['name']}' is a ephemeral repo. It'll not be installed to appliance."
|
129
|
+
next
|
130
|
+
end
|
131
|
+
|
127
132
|
@log.debug "Installing #{repo['name']} repo..."
|
128
133
|
repo_file = File.read( "#{File.dirname( __FILE__ )}/src/base.repo").gsub( /#NAME#/, repo['name'] )
|
129
134
|
|
@@ -18,10 +18,10 @@
|
|
18
18
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
19
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
20
|
|
21
|
-
require 'boxgrinder-build/plugins/os/base/
|
21
|
+
require 'boxgrinder-build/plugins/os/base/rhel-based-os-plugin'
|
22
22
|
|
23
23
|
module BoxGrinder
|
24
|
-
class CentOSPlugin <
|
24
|
+
class CentOSPlugin < RHELBasedOSPlugin
|
25
25
|
|
26
26
|
CENTOS_REPOS = {
|
27
27
|
"5" => {
|
@@ -44,29 +44,9 @@ module BoxGrinder
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def execute
|
47
|
-
|
47
|
+
raise "Build cannot be started until the plugin isn't initialized" if @initialized.nil?
|
48
48
|
|
49
|
-
|
50
|
-
kernel_version = guestfs.ls("/lib/modules").first
|
51
|
-
|
52
|
-
@log.debug "Recreating initrd for #{kernel_version} kernel..."
|
53
|
-
guestfs.sh( "/sbin/mkinitrd -f -v --preload=mptspi /boot/initrd-#{kernel_version}.img #{kernel_version}" )
|
54
|
-
@log.debug "Initrd recreated."
|
55
|
-
|
56
|
-
@log.debug "Applying root password..."
|
57
|
-
guestfs.sh( "/usr/bin/passwd -d root" )
|
58
|
-
guestfs.sh( "/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map{65.+(rand(25)).chr}.join)}' root" )
|
59
|
-
@log.debug "Password applied."
|
60
|
-
end
|
61
|
-
|
62
|
-
@log.info "Done."
|
63
|
-
|
64
|
-
disk_path
|
65
|
-
end
|
66
|
-
|
67
|
-
# https://bugzilla.redhat.com/show_bug.cgi?id=466275
|
68
|
-
def adjust_partition_table
|
69
|
-
@appliance_config.hardware.partitions['/boot'] = { 'root' => '/boot', 'size' => 0.1 } if @appliance_config.hardware.partitions['/boot'].nil?
|
49
|
+
build_rhel( CENTOS_REPOS )
|
70
50
|
end
|
71
51
|
end
|
72
52
|
end
|
@@ -18,10 +18,10 @@
|
|
18
18
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
19
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
20
|
|
21
|
-
require 'boxgrinder-build/plugins/os/base/
|
21
|
+
require 'boxgrinder-build/plugins/os/base/rhel-based-os-plugin'
|
22
22
|
|
23
23
|
module BoxGrinder
|
24
|
-
class RHELPlugin <
|
24
|
+
class RHELPlugin < RHELBasedOSPlugin
|
25
25
|
def info
|
26
26
|
{
|
27
27
|
:name => :rhel,
|
@@ -31,8 +31,10 @@ module BoxGrinder
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def execute
|
35
35
|
raise "Build cannot be started until the plugin isn't initialized" if @initialized.nil?
|
36
|
+
|
37
|
+
build_rhel
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 5
|
9
|
+
version: 0.3.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- BoxGrinder Project
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-28 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +27,8 @@ dependencies:
|
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 0
|
30
|
-
-
|
31
|
-
version: 0.0.
|
30
|
+
- 9
|
31
|
+
version: 0.0.9
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/boxgrinder-build/plugins/os/base/src/base.repo
|
168
168
|
- lib/boxgrinder-build/plugins/os/base/validators/rpm-dependency-validator.rb
|
169
169
|
- lib/boxgrinder-build/plugins/os/base/kickstart.rb
|
170
|
+
- lib/boxgrinder-build/plugins/os/base/rhel-based-os-plugin.rb
|
170
171
|
- lib/boxgrinder-build/managers/base-plugin-manager.rb
|
171
172
|
- lib/boxgrinder-build/managers/platform-plugin-manager.rb
|
172
173
|
- lib/boxgrinder-build/managers/delivery-plugin-manager.rb
|