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 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.8'
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.0'
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( appliance_definition_file, options = {} )
32
- @config = Config.new
31
+ def initialize( appliance_definition_file, options = {} )
32
+ @config = Config.new
33
33
  @appliance_definition_file = appliance_definition_file
34
- @log = options[:log] || Logger.new(STDOUT)
35
- @options = options[: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
@@ -101,7 +101,6 @@ module BoxGrinder
101
101
  cost = 40
102
102
 
103
103
  for repo in valid_repos + @appliance_config.repos
104
-
105
104
  if repo.keys.include?('mirrorlist')
106
105
  urltype = 'mirrorlist'
107
106
  else
@@ -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
 
@@ -110,7 +110,7 @@ module BoxGrinder
110
110
 
111
111
  def generate_package_list
112
112
  packages = []
113
- for package in @appliance_config.packages
113
+ for package in @appliance_config.packages.includes
114
114
  packages << package unless package.match /^@/
115
115
  end
116
116
  packages
@@ -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/rpm-based-os-plugin'
21
+ require 'boxgrinder-build/plugins/os/base/rhel-based-os-plugin'
22
22
 
23
23
  module BoxGrinder
24
- class CentOSPlugin < RPMBasedOSPlugin
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
- adjust_partition_table
47
+ raise "Build cannot be started until the plugin isn't initialized" if @initialized.nil?
48
48
 
49
- disk_path = build_with_appliance_creator( CENTOS_REPOS ) do |guestfs, guestfs_helper|
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/rpm-based-os-plugin'
21
+ require 'boxgrinder-build/plugins/os/base/rhel-based-os-plugin'
22
22
 
23
23
  module BoxGrinder
24
- class RHELPlugin < RPMBasedOSPlugin
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 build
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
- - 3
9
- version: 0.3.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-20 00:00:00 +02:00
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
- - 8
31
- version: 0.0.8
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