boxgrinder-build 0.2.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/boxgrinder-build +81 -0
- data/docs/examples/appliances/appliances.appl +5 -0
- data/docs/examples/appliances/minimal.appl +9 -0
- data/docs/examples/appliances/mix.appl +8 -0
- data/docs/examples/appliances/packages.appl +13 -0
- data/lib/boxgrinder-build/appliance.rb +85 -18
- data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +2 -2
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +18 -15
- data/lib/boxgrinder-build/helpers/package-helper.rb +65 -0
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +89 -0
- data/lib/boxgrinder-build/{defaults.rb → managers/base-plugin-manager.rb} +41 -8
- data/lib/{boxgrinder-build.rb → boxgrinder-build/managers/delivery-plugin-manager.rb} +15 -18
- data/lib/boxgrinder-build/managers/operating-system-plugin-manager.rb +6 -0
- data/{bin/boxgrinder → lib/boxgrinder-build/managers/platform-plugin-manager.rb} +6 -3
- data/lib/boxgrinder-build/plugins/base-plugin.rb +98 -0
- data/lib/boxgrinder-build/plugins/delivery/base/base-delivery-plugin.rb +43 -0
- data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +57 -0
- data/lib/boxgrinder-build/{helpers → plugins/delivery/s3}/aws-helper.rb +0 -0
- data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +133 -0
- data/lib/boxgrinder-build/{helpers/ssh-helper.rb → plugins/delivery/sftp/sftp-plugin.rb} +61 -42
- data/lib/boxgrinder-build/{appliance-kickstart.rb → plugins/os/base/kickstart.rb} +45 -55
- data/lib/boxgrinder-build/{images/raw-image.rb → plugins/os/base/rpm-based-os-plugin.rb} +63 -60
- data/lib/boxgrinder-build/{erb → plugins/os/base/src}/appliance.ks.erb +2 -5
- data/{src → lib/boxgrinder-build/plugins/os/base/src}/base.repo +0 -0
- data/{src → lib/boxgrinder-build/plugins/os/base/src}/motd.init +0 -0
- data/lib/boxgrinder-build/{validators/appliance-dependency-validator.rb → plugins/os/base/validators/rpm-dependency-validator.rb} +1 -1
- data/lib/boxgrinder-build/{models/ssh-config.rb → plugins/os/base-operating-system-plugin.rb} +10 -17
- data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +72 -0
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +66 -0
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +38 -0
- data/lib/boxgrinder-build/plugins/platform/base-platform-plugin.rb +37 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +283 -0
- data/{src → lib/boxgrinder-build/plugins/platform/ec2/src}/f12/yum.conf +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/f12-i386-boxgrinder.repo +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/f12-x86_64-boxgrinder.repo +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/fstab_32bit +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/fstab_64bit +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/ifcfg-eth0 +0 -0
- data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/rc_local +1 -4
- data/{src/README.vmware → lib/boxgrinder-build/plugins/platform/vmware/src/README} +10 -10
- data/{src → lib/boxgrinder-build/plugins/platform/vmware/src}/base.vmdk +1 -1
- data/{src → lib/boxgrinder-build/plugins/platform/vmware/src}/base.vmx +0 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +181 -0
- data/lib/boxgrinder-build/validators/config-validator.rb +0 -19
- metadata +73 -44
- data/docs/examples/appliances/appliances-appliance/appliances-appliance.appl +0 -6
- data/docs/examples/appliances/appliances-appliance/appliances-appliance.pp +0 -16
- data/docs/examples/appliances/minimal-appliance/minimal-appliance.appl +0 -2
- data/docs/examples/appliances/minimal-appliance/minimal-appliance.pp +0 -16
- data/docs/examples/appliances/mix-appliance/mix-appliance.appl +0 -9
- data/docs/examples/appliances/mix-appliance/mix-appliance.pp +0 -16
- data/docs/examples/appliances/packages-appliance/packages-appliance.appl +0 -6
- data/docs/examples/appliances/packages-appliance/packages-appliance.pp +0 -16
- data/extras/sign-rpms +0 -12
- data/lib/boxgrinder-build/boxgrinder.rb +0 -93
- data/lib/boxgrinder-build/helpers/release-helper.rb +0 -136
- data/lib/boxgrinder-build/images/ec2-image.rb +0 -317
- data/lib/boxgrinder-build/images/vmware-image.rb +0 -214
- data/lib/boxgrinder-build/validators/appliance-definition-validator.rb +0 -89
- data/lib/progressbar/progressbar.rb +0 -236
- data/src/oddthesis/RPM-GPG-KEY-oddthesis +0 -30
- data/src/oddthesis/oddthesis.repo +0 -23
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# JBoss, Home of Professional Open Source
|
4
|
+
# Copyright 2009, Red Hat Middleware LLC, and individual contributors
|
5
|
+
# by the @authors tag. See the copyright.txt in the distribution for a
|
6
|
+
# full listing of individual contributors.
|
7
|
+
#
|
8
|
+
# This is free software; you can redistribute it and/or modify it
|
9
|
+
# under the terms of the GNU Lesser General Public License as
|
10
|
+
# published by the Free Software Foundation; either version 2.1 of
|
11
|
+
# the License, or (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This software is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
+
# Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public
|
19
|
+
# License along with this software; if not, write to the Free
|
20
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
21
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'commander/import'
|
25
|
+
require 'boxgrinder-core/helpers/log-helper'
|
26
|
+
require 'boxgrinder-build/helpers/plugin-helper'
|
27
|
+
require 'boxgrinder-build/appliance'
|
28
|
+
|
29
|
+
gem 'boxgrinder-core', '>= 0.0.6'
|
30
|
+
gem 'aws-s3', '>= 0.6.2'
|
31
|
+
gem 'amazon-ec2', '>= 0.9.6'
|
32
|
+
gem 'net-sftp', '>= 2.0.4'
|
33
|
+
gem 'net-ssh', '>= 2.0.20'
|
34
|
+
gem 'rake', '>= 0.8.7'
|
35
|
+
gem 'progressbar', '>= 0.9.0'
|
36
|
+
gem 'commander', '>= 4.0.3'
|
37
|
+
|
38
|
+
# :name is optional, otherwise uses the basename of this executable
|
39
|
+
|
40
|
+
#$stderr.reopen('/dev/null')
|
41
|
+
|
42
|
+
program :name, 'BoxGrinder'
|
43
|
+
program :version, '0.3.0'
|
44
|
+
program :description, 'A tool for building VM images from simple definition files.'
|
45
|
+
default_command :build
|
46
|
+
|
47
|
+
global_option('-V', '--verbose', TrueClass, "Prints verbose information while building. Default: false.") { ENV['BG_LOG_THRESHOLD'] = 'debug'}
|
48
|
+
|
49
|
+
module BoxGrinder
|
50
|
+
log = LogHelper.new
|
51
|
+
|
52
|
+
PluginHelper.new( :log => log ).load_plugins
|
53
|
+
|
54
|
+
command :build do |c|
|
55
|
+
c.syntax = 'build appliance_definition.appl [options]'
|
56
|
+
c.description = 'Creates a base image for selected appliance definition.'
|
57
|
+
|
58
|
+
c.option '-p STRING', '--platform STRING', String, "The type of platform. Valid types are: #{PlatformPluginManager.instance.plugins.keys.join(', ')}. Default: none."
|
59
|
+
c.option '-d STRING', '--delivery STRING', String, "The delivery type for selected image. Valid types are: #{DeliveryPluginManager.instance.types.keys.join(', ')}. Default: none."
|
60
|
+
c.option '-f', '--force', TrueClass, "Force image creation - removes all previous builds for selected appliance. Default: false."
|
61
|
+
#c.option '-V', '--verbose', TrueClass, "Prints verbose information while building. Default: false."
|
62
|
+
|
63
|
+
c.action do |args, options|
|
64
|
+
options.default :platform => :none
|
65
|
+
options.default :delivery => :none
|
66
|
+
options.default :force => false
|
67
|
+
options.default :verbose => false
|
68
|
+
|
69
|
+
options.platform = options.platform.to_s.downcase.to_sym
|
70
|
+
options.delivery = options.delivery.to_s.downcase.to_sym
|
71
|
+
|
72
|
+
appliance_definition_file = args.shift or raise('Appliance definition file is required. Run boxgrinder-build -h for more info')
|
73
|
+
|
74
|
+
raise("Appliance definition file '#{appliance_definition_file}' could not be found") unless File.exists?( appliance_definition_file )
|
75
|
+
raise "Not known platform: #{options.platform}. Available platforms: #{PlatformPluginManager.instance.plugins.keys.join(', ')}." if PlatformPluginManager.instance.plugins[options.platform].nil? and options.platform != :none
|
76
|
+
raise "Not known delivery type: #{options.delivery}. Available types: #{DeliveryPluginManager.instance.types.keys.join(', ')}." if DeliveryPluginManager.instance.types.keys.include?(options.delivery).nil? and options.delivery != :none
|
77
|
+
|
78
|
+
Appliance.new( appliance_definition_file, :options => options, :log => log ).create
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -19,34 +19,101 @@
|
|
19
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
20
|
|
21
21
|
require 'rake/tasklib'
|
22
|
-
|
23
|
-
require 'boxgrinder-
|
24
|
-
require 'boxgrinder-
|
25
|
-
require 'boxgrinder-
|
26
|
-
require 'boxgrinder-
|
27
|
-
require 'boxgrinder-build/helpers/release-helper'
|
28
|
-
require 'boxgrinder-build/validators/appliance-dependency-validator'
|
22
|
+
require 'boxgrinder-core/models/appliance-config'
|
23
|
+
require 'boxgrinder-core/models/config'
|
24
|
+
require 'boxgrinder-core/helpers/appliance-helper'
|
25
|
+
require 'boxgrinder-core/helpers/appliance-config-helper'
|
26
|
+
require 'boxgrinder-core/validators/appliance-config-validator'
|
29
27
|
|
30
28
|
module BoxGrinder
|
31
29
|
class Appliance < Rake::TaskLib
|
32
30
|
|
33
|
-
def initialize(
|
34
|
-
@config =
|
35
|
-
@
|
31
|
+
def initialize( appliance_definition_file, options = {} )
|
32
|
+
@config = Config.new
|
33
|
+
@appliance_definition_file = appliance_definition_file
|
36
34
|
@log = options[:log] || Logger.new(STDOUT)
|
35
|
+
@options = options[:options]
|
36
|
+
end
|
37
|
+
|
38
|
+
def create
|
39
|
+
appliance_configs, appliance_config = ApplianceHelper.new( :log => @log ).read_definitions( @appliance_definition_file )
|
40
|
+
appliance_config_helper = ApplianceConfigHelper.new( appliance_configs )
|
41
|
+
|
42
|
+
@appliance_config = appliance_config_helper.merge(appliance_config.clone.init_arch).initialize_paths
|
43
|
+
|
44
|
+
ApplianceConfigValidator.new( @appliance_config, :os_plugins => OperatingSystemPluginManager.instance.plugins ).validate
|
45
|
+
|
46
|
+
if @options.force
|
47
|
+
@log.info "Removing previous builds for #{@appliance_config.name} appliance..."
|
48
|
+
FileUtils.rm_rf( @appliance_config.path.dir.build )
|
49
|
+
@log.debug "Previous builds removed."
|
50
|
+
end
|
51
|
+
|
52
|
+
base_deliverables = execute_os_plugin
|
53
|
+
platform_deliverables = execute_platform_plugin( base_deliverables )
|
54
|
+
|
55
|
+
execute_delivery_plugin( platform_deliverables )
|
56
|
+
end
|
57
|
+
|
58
|
+
def execute_os_plugin
|
59
|
+
os_plugin = OperatingSystemPluginManager.instance.plugins[@appliance_config.os.name.to_sym]
|
60
|
+
os_plugin.init( @config, @appliance_config, :log => @log )
|
61
|
+
|
62
|
+
if deliverables_exists( os_plugin.deliverables )
|
63
|
+
@log.info "Deliverables for #{os_plugin.info[:name]} operating system plugin exists, skipping."
|
64
|
+
return os_plugin.deliverables
|
65
|
+
end
|
66
|
+
|
67
|
+
@log.debug "Executing operating system plugin for #{@appliance_config.os.name}..."
|
68
|
+
os_plugin.execute
|
69
|
+
@log.debug "Operating system plugin executed."
|
70
|
+
|
71
|
+
os_plugin.deliverables
|
72
|
+
end
|
73
|
+
|
74
|
+
def execute_platform_plugin( deliverables )
|
75
|
+
if @options.platform == :none
|
76
|
+
@log.debug "No platform selected, skipping platform conversion."
|
77
|
+
return deliverables
|
78
|
+
end
|
79
|
+
|
80
|
+
platform_plugin = PlatformPluginManager.instance.plugins[@options.platform]
|
81
|
+
platform_plugin.init( @config, @appliance_config, :log => @log )
|
82
|
+
|
83
|
+
if deliverables_exists( platform_plugin.deliverables )
|
84
|
+
@log.info "Deliverables for #{platform_plugin.info[:name]} platform plugin exists, skipping."
|
85
|
+
return platform_plugin.deliverables
|
86
|
+
end
|
87
|
+
|
88
|
+
@log.debug "Executing platform plugin for #{@options.platform}..."
|
89
|
+
platform_plugin.execute( deliverables[:disk] )
|
90
|
+
@log.debug "Platform plugin executed."
|
91
|
+
|
92
|
+
platform_plugin.deliverables
|
93
|
+
end
|
94
|
+
|
95
|
+
def execute_delivery_plugin( deliverables )
|
96
|
+
if @options.delivery == :none
|
97
|
+
@log.debug "No delivery method selected, skipping delivering."
|
98
|
+
return deliverables
|
99
|
+
end
|
37
100
|
|
38
|
-
|
101
|
+
delivery_plugin = DeliveryPluginManager.instance.types[@options.delivery]
|
102
|
+
delivery_plugin.init( @config, @appliance_config, :log => @log )
|
103
|
+
delivery_plugin.execute( deliverables, @options.delivery )
|
39
104
|
end
|
40
105
|
|
41
|
-
|
42
|
-
|
43
|
-
|
106
|
+
# TODO: move this to plugin (os,platform,delivery)
|
107
|
+
def deliverables_exists( deliverables )
|
108
|
+
return false unless File.exists?(deliverables[:disk])
|
44
109
|
|
45
|
-
|
46
|
-
|
47
|
-
|
110
|
+
[:metadata, :other].each do |deliverable_type|
|
111
|
+
deliverables[deliverable_type].each_value do |file|
|
112
|
+
return false unless File.exists?(file)
|
113
|
+
end
|
114
|
+
end
|
48
115
|
|
49
|
-
|
116
|
+
true
|
50
117
|
end
|
51
118
|
end
|
52
119
|
end
|
@@ -39,9 +39,9 @@ module BoxGrinder
|
|
39
39
|
@guestfs_helper = GuestFSHelper.new( @disk, :log => @log )
|
40
40
|
@guestfs = @guestfs_helper.guestfs
|
41
41
|
|
42
|
-
yield
|
42
|
+
yield @guestfs, @guestfs_helper
|
43
43
|
|
44
|
-
@
|
44
|
+
@guestfs_helper.clean_close
|
45
45
|
end
|
46
46
|
|
47
47
|
def validate_options( options )
|
@@ -26,6 +26,8 @@ module BoxGrinder
|
|
26
26
|
@raw_disk = raw_disk
|
27
27
|
@log = options[:log] || Logger.new(STDOUT)
|
28
28
|
|
29
|
+
@partitions = {}
|
30
|
+
|
29
31
|
launch
|
30
32
|
end
|
31
33
|
|
@@ -53,26 +55,27 @@ module BoxGrinder
|
|
53
55
|
|
54
56
|
@log.debug "Launching guestfs..."
|
55
57
|
@guestfs.launch
|
56
|
-
|
57
|
-
@guestfs.
|
58
|
+
|
59
|
+
mount_partition( @guestfs.list_partitions.first, '/' ) if @guestfs.list_partitions.size == 1
|
60
|
+
mount_partition( @guestfs.list_devices.first, '/' ) if @guestfs.list_partitions.size == 0
|
61
|
+
|
58
62
|
@log.debug "Guestfs launched."
|
63
|
+
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
else
|
63
|
-
partition_to_mount = "/dev/sda"
|
64
|
-
end
|
65
|
+
def clean_close
|
66
|
+
@log.debug "Closing guestfs..."
|
65
67
|
|
66
|
-
@
|
67
|
-
@guestfs.
|
68
|
-
@
|
68
|
+
@guestfs.sync
|
69
|
+
@guestfs.umount_all
|
70
|
+
@guestfs.close
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
@guestfs.upload( "/etc/resolv.conf", "/etc/resolv.conf" )
|
73
|
-
@log.debug "'/etc/resolv.conf' uploaded."
|
72
|
+
@log.debug "Guestfs closed."
|
73
|
+
end
|
74
74
|
|
75
|
-
|
75
|
+
def mount_partition( part, mount_point )
|
76
|
+
@log.debug "Mounting #{part} partition to #{mount_point}..."
|
77
|
+
@guestfs.mount_options( "", part, mount_point )
|
78
|
+
@log.debug "Partition mounted."
|
76
79
|
end
|
77
80
|
|
78
81
|
# TODO this is shitty, I know... https://bugzilla.redhat.com/show_bug.cgi?id=507188
|
@@ -0,0 +1,65 @@
|
|
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
|
+
module BoxGrinder
|
22
|
+
class PackageHelper
|
23
|
+
def initialize(config, appliance_config, options = {})
|
24
|
+
@config = config
|
25
|
+
@appliance_config = appliance_config
|
26
|
+
|
27
|
+
@log = options[:log] || Logger.new(STDOUT)
|
28
|
+
@exec_helper = options[:exec_helper] || ExecHelper.new({:log => @log})
|
29
|
+
end
|
30
|
+
|
31
|
+
def package(deliverables, type = :tar)
|
32
|
+
files = []
|
33
|
+
files << File.basename(deliverables[:disk])
|
34
|
+
|
35
|
+
[:metadata, :other].each do |deliverable_type|
|
36
|
+
deliverables[deliverable_type].each_value do |file|
|
37
|
+
files << File.basename(file)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
deliverable_platform = deliverables[:platform].nil? ? "" : deliverables[:platform]
|
42
|
+
package_path = "#{@appliance_config.path.dir.packages}/#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.hardware.arch}-#{deliverable_platform}.tgz"
|
43
|
+
|
44
|
+
if File.exists?(package_path)
|
45
|
+
@log.info "Package of #{type} type for #{@appliance_config.name} appliance and #{deliverable_platform} platform already exists, skipping."
|
46
|
+
return package_path
|
47
|
+
end
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(File.dirname(package_path))
|
50
|
+
|
51
|
+
@log.info "Packaging #{@appliance_config.name} appliance for #{deliverable_platform} platform to #{type}..."
|
52
|
+
|
53
|
+
case type
|
54
|
+
when :tar
|
55
|
+
@exec_helper.execute "tar -C #{File.dirname(deliverables[:disk])} -cvzf '#{package_path}' #{files.join(' ')}"
|
56
|
+
else
|
57
|
+
raise "Only tar format is currently supported."
|
58
|
+
end
|
59
|
+
|
60
|
+
@log.info "Appliance #{@appliance_config.name} packaged."
|
61
|
+
|
62
|
+
package_path
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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/managers/operating-system-plugin-manager'
|
22
|
+
require 'boxgrinder-build/managers/platform-plugin-manager'
|
23
|
+
require 'boxgrinder-build/managers/delivery-plugin-manager'
|
24
|
+
|
25
|
+
module BoxGrinder
|
26
|
+
class PluginHelper
|
27
|
+
def initialize( options = {} )
|
28
|
+
@log = options[:log] || Logger.new(STDOUT)
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_plugins
|
32
|
+
Dir["#{File.dirname( __FILE__ )}/../plugins/**/*-plugin.rb"].each { |file| require "boxgrinder-build/plugins/#{file.scan(/\/plugins\/(.*)\.rb$/).to_s}" }
|
33
|
+
|
34
|
+
@os_plugins = OperatingSystemPluginManager.instance.initialize_plugins( :log => @log ).plugins
|
35
|
+
@platform_plugins = PlatformPluginManager.instance.initialize_plugins( :log => @log ).plugins
|
36
|
+
@delivery_plugins = DeliveryPluginManager.instance.initialize_plugins( :log => @log ).plugins
|
37
|
+
|
38
|
+
print_plugins( 'os' ) { @os_plugins }
|
39
|
+
print_plugins( 'platform' ) { @platform_plugins }
|
40
|
+
print_plugins( 'delivery' ) { @delivery_plugins }
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def print_plugins( type )
|
46
|
+
@log.debug "Loading #{type} plugins..."
|
47
|
+
|
48
|
+
plugins = yield
|
49
|
+
|
50
|
+
@log.debug "We have #{plugins.size} #{type} plugin(s) registered"
|
51
|
+
|
52
|
+
plugins.each_value do |plugin|
|
53
|
+
@log.debug "- plugin for #{plugin.info[:full_name]}."
|
54
|
+
end
|
55
|
+
|
56
|
+
@log.debug "Plugins loaded."
|
57
|
+
end
|
58
|
+
|
59
|
+
def deliverables_exists?( deliverables )
|
60
|
+
return false unless File.exists?(deliverables[:disk])
|
61
|
+
|
62
|
+
[:metadata, :other].each do |deliverable_type|
|
63
|
+
deliverables[deliverable_type].each_value do |file|
|
64
|
+
return false unless File.exists?(file)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
def deliverables_array( deliverables )
|
72
|
+
files = []
|
73
|
+
|
74
|
+
files << deliverables[:disk]
|
75
|
+
|
76
|
+
[:metadata, :other].each do |deliverable_type|
|
77
|
+
deliverables[deliverable_type].each_value do |file|
|
78
|
+
file << file
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
files
|
83
|
+
end
|
84
|
+
|
85
|
+
attr_reader :os_plugins
|
86
|
+
attr_reader :platform_plugins
|
87
|
+
attr_reader :delivery_plugins
|
88
|
+
end
|
89
|
+
end
|
@@ -18,12 +18,45 @@
|
|
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 'singleton'
|
22
|
+
|
21
23
|
module BoxGrinder
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
class BasePluginManager
|
25
|
+
include Singleton
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@plugin_classes = []
|
29
|
+
@plugins = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def <<(plugin_class)
|
33
|
+
@plugin_classes << plugin_class
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize_plugins( options = {} )
|
37
|
+
log = options[:log] || Logger.new(STDOUT)
|
38
|
+
|
39
|
+
@plugin_classes.each do |plugin_class|
|
40
|
+
begin
|
41
|
+
plugin = plugin_class.new
|
42
|
+
rescue => e
|
43
|
+
raise "Error while initializing #{plugin_class} plugin.", e
|
44
|
+
end
|
45
|
+
|
46
|
+
next unless plugin.respond_to?(:info)
|
47
|
+
|
48
|
+
plugin.instance_variable_set( :@log, log )
|
49
|
+
|
50
|
+
if @plugins[plugin.info[:name]].nil?
|
51
|
+
@plugins[plugin.info[:name]] = plugin
|
52
|
+
else
|
53
|
+
raise "We already have registered plugin for #{plugin.info[:name]}."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :plugins
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
# JBoss, Home of Professional Open Source
|
4
2
|
# Copyright 2009, Red Hat Middleware LLC, and individual contributors
|
5
3
|
# by the @authors tag. See the copyright.txt in the distribution for a
|
@@ -20,23 +18,22 @@
|
|
20
18
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
21
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
22
20
|
|
23
|
-
require '
|
24
|
-
|
25
|
-
gem 'boxgrinder-core', '>= 0.0.4'
|
26
|
-
gem 'aws-s3', '>= 0.6.2'
|
27
|
-
gem 'amazon-ec2', '>= 0.9.6'
|
28
|
-
gem 'net-sftp', '>= 2.0.4'
|
29
|
-
gem 'net-ssh', '>= 2.0.20'
|
30
|
-
gem 'rake', '>= 0.8.7'
|
21
|
+
require 'boxgrinder-build/managers/base-plugin-manager'
|
31
22
|
|
32
|
-
|
33
|
-
|
23
|
+
module BoxGrinder
|
24
|
+
class DeliveryPluginManager < BasePluginManager
|
25
|
+
def types
|
26
|
+
t = {}
|
34
27
|
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
@plugins.each_value do |plugin|
|
29
|
+
plugin.info[:type].each do |type|
|
30
|
+
t[type] = plugin
|
31
|
+
end
|
38
32
|
|
39
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
t
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
38
|
+
end
|
39
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
# JBoss, Home of Professional Open Source
|
4
2
|
# Copyright 2009, Red Hat Middleware LLC, and individual contributors
|
5
3
|
# by the @authors tag. See the copyright.txt in the distribution for a
|
@@ -20,4 +18,9 @@
|
|
20
18
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
21
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
22
20
|
|
23
|
-
require 'boxgrinder-build'
|
21
|
+
require 'boxgrinder-build/managers/base-plugin-manager'
|
22
|
+
|
23
|
+
module BoxGrinder
|
24
|
+
class PlatformPluginManager < BasePluginManager
|
25
|
+
end
|
26
|
+
end
|