boxgrinder-build 0.2.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/bin/boxgrinder-build +81 -0
  2. data/docs/examples/appliances/appliances.appl +5 -0
  3. data/docs/examples/appliances/minimal.appl +9 -0
  4. data/docs/examples/appliances/mix.appl +8 -0
  5. data/docs/examples/appliances/packages.appl +13 -0
  6. data/lib/boxgrinder-build/appliance.rb +85 -18
  7. data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +2 -2
  8. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +18 -15
  9. data/lib/boxgrinder-build/helpers/package-helper.rb +65 -0
  10. data/lib/boxgrinder-build/helpers/plugin-helper.rb +89 -0
  11. data/lib/boxgrinder-build/{defaults.rb → managers/base-plugin-manager.rb} +41 -8
  12. data/lib/{boxgrinder-build.rb → boxgrinder-build/managers/delivery-plugin-manager.rb} +15 -18
  13. data/lib/boxgrinder-build/managers/operating-system-plugin-manager.rb +6 -0
  14. data/{bin/boxgrinder → lib/boxgrinder-build/managers/platform-plugin-manager.rb} +6 -3
  15. data/lib/boxgrinder-build/plugins/base-plugin.rb +98 -0
  16. data/lib/boxgrinder-build/plugins/delivery/base/base-delivery-plugin.rb +43 -0
  17. data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +57 -0
  18. data/lib/boxgrinder-build/{helpers → plugins/delivery/s3}/aws-helper.rb +0 -0
  19. data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +133 -0
  20. data/lib/boxgrinder-build/{helpers/ssh-helper.rb → plugins/delivery/sftp/sftp-plugin.rb} +61 -42
  21. data/lib/boxgrinder-build/{appliance-kickstart.rb → plugins/os/base/kickstart.rb} +45 -55
  22. data/lib/boxgrinder-build/{images/raw-image.rb → plugins/os/base/rpm-based-os-plugin.rb} +63 -60
  23. data/lib/boxgrinder-build/{erb → plugins/os/base/src}/appliance.ks.erb +2 -5
  24. data/{src → lib/boxgrinder-build/plugins/os/base/src}/base.repo +0 -0
  25. data/{src → lib/boxgrinder-build/plugins/os/base/src}/motd.init +0 -0
  26. data/lib/boxgrinder-build/{validators/appliance-dependency-validator.rb → plugins/os/base/validators/rpm-dependency-validator.rb} +1 -1
  27. data/lib/boxgrinder-build/{models/ssh-config.rb → plugins/os/base-operating-system-plugin.rb} +10 -17
  28. data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +72 -0
  29. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +66 -0
  30. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +38 -0
  31. data/lib/boxgrinder-build/plugins/platform/base-platform-plugin.rb +37 -0
  32. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +283 -0
  33. data/{src → lib/boxgrinder-build/plugins/platform/ec2/src}/f12/yum.conf +0 -0
  34. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/f12-i386-boxgrinder.repo +0 -0
  35. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/f12-x86_64-boxgrinder.repo +0 -0
  36. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/fstab_32bit +0 -0
  37. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/fstab_64bit +0 -0
  38. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/ifcfg-eth0 +0 -0
  39. data/{src/ec2 → lib/boxgrinder-build/plugins/platform/ec2/src}/rc_local +1 -4
  40. data/{src/README.vmware → lib/boxgrinder-build/plugins/platform/vmware/src/README} +10 -10
  41. data/{src → lib/boxgrinder-build/plugins/platform/vmware/src}/base.vmdk +1 -1
  42. data/{src → lib/boxgrinder-build/plugins/platform/vmware/src}/base.vmx +0 -0
  43. data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +181 -0
  44. data/lib/boxgrinder-build/validators/config-validator.rb +0 -19
  45. metadata +73 -44
  46. data/docs/examples/appliances/appliances-appliance/appliances-appliance.appl +0 -6
  47. data/docs/examples/appliances/appliances-appliance/appliances-appliance.pp +0 -16
  48. data/docs/examples/appliances/minimal-appliance/minimal-appliance.appl +0 -2
  49. data/docs/examples/appliances/minimal-appliance/minimal-appliance.pp +0 -16
  50. data/docs/examples/appliances/mix-appliance/mix-appliance.appl +0 -9
  51. data/docs/examples/appliances/mix-appliance/mix-appliance.pp +0 -16
  52. data/docs/examples/appliances/packages-appliance/packages-appliance.appl +0 -6
  53. data/docs/examples/appliances/packages-appliance/packages-appliance.pp +0 -16
  54. data/extras/sign-rpms +0 -12
  55. data/lib/boxgrinder-build/boxgrinder.rb +0 -93
  56. data/lib/boxgrinder-build/helpers/release-helper.rb +0 -136
  57. data/lib/boxgrinder-build/images/ec2-image.rb +0 -317
  58. data/lib/boxgrinder-build/images/vmware-image.rb +0 -214
  59. data/lib/boxgrinder-build/validators/appliance-definition-validator.rb +0 -89
  60. data/lib/progressbar/progressbar.rb +0 -236
  61. data/src/oddthesis/RPM-GPG-KEY-oddthesis +0 -30
  62. data/src/oddthesis/oddthesis.repo +0 -23
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 3
7
8
  - 2
8
- - 0
9
- version: 0.2.0
9
+ version: 0.3.2
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-03-31 00:00:00 +02:00
17
+ date: 2010-05-10 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
- - 4
31
- version: 0.0.4
30
+ - 6
31
+ version: 0.0.6
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
@@ -101,67 +101,96 @@ dependencies:
101
101
  version: 0.8.7
102
102
  type: :runtime
103
103
  version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
105
+ name: progressbar
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
113
+ - 9
114
+ - 0
115
+ version: 0.9.0
116
+ type: :runtime
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: commander
120
+ prerelease: false
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 4
127
+ - 0
128
+ - 3
129
+ version: 4.0.3
130
+ type: :runtime
131
+ version_requirements: *id008
104
132
  description:
105
133
  email: info@boxgrinder.org
106
134
  executables:
107
- - boxgrinder
135
+ - boxgrinder-build
108
136
  extensions: []
109
137
 
110
138
  extra_rdoc_files: []
111
139
 
112
140
  files:
113
- - lib/progressbar/progressbar.rb
114
- - lib/boxgrinder-build.rb
115
- - lib/boxgrinder-build/models/ssh-config.rb
116
- - lib/boxgrinder-build/defaults.rb
117
- - lib/boxgrinder-build/appliance-kickstart.rb
118
- - lib/boxgrinder-build/validators/appliance-dependency-validator.rb
141
+ - lib/boxgrinder-build/plugins/base-plugin.rb
142
+ - lib/boxgrinder-build/plugins/delivery/s3/aws-helper.rb
143
+ - lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb
144
+ - lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
145
+ - lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb
146
+ - lib/boxgrinder-build/plugins/delivery/base/base-delivery-plugin.rb
147
+ - lib/boxgrinder-build/plugins/platform/base-platform-plugin.rb
148
+ - lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb
149
+ - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx
150
+ - lib/boxgrinder-build/plugins/platform/vmware/src/README
151
+ - lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk
152
+ - lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb
153
+ - lib/boxgrinder-build/plugins/platform/ec2/src/f12/yum.conf
154
+ - lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit
155
+ - lib/boxgrinder-build/plugins/platform/ec2/src/f12-i386-boxgrinder.repo
156
+ - lib/boxgrinder-build/plugins/platform/ec2/src/rc_local
157
+ - lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0
158
+ - lib/boxgrinder-build/plugins/platform/ec2/src/f12-x86_64-boxgrinder.repo
159
+ - lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit
160
+ - lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb
161
+ - lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb
162
+ - lib/boxgrinder-build/plugins/os/base-operating-system-plugin.rb
163
+ - lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb
164
+ - lib/boxgrinder-build/plugins/os/base/rpm-based-os-plugin.rb
165
+ - lib/boxgrinder-build/plugins/os/base/src/motd.init
166
+ - lib/boxgrinder-build/plugins/os/base/src/appliance.ks.erb
167
+ - lib/boxgrinder-build/plugins/os/base/src/base.repo
168
+ - lib/boxgrinder-build/plugins/os/base/validators/rpm-dependency-validator.rb
169
+ - lib/boxgrinder-build/plugins/os/base/kickstart.rb
170
+ - lib/boxgrinder-build/managers/base-plugin-manager.rb
171
+ - lib/boxgrinder-build/managers/platform-plugin-manager.rb
172
+ - lib/boxgrinder-build/managers/delivery-plugin-manager.rb
173
+ - lib/boxgrinder-build/managers/operating-system-plugin-manager.rb
119
174
  - lib/boxgrinder-build/validators/appliance-validator.rb
120
175
  - lib/boxgrinder-build/validators/appliance-config-parameter-validator.rb
121
176
  - lib/boxgrinder-build/validators/ssh-validator.rb
122
177
  - lib/boxgrinder-build/validators/validator.rb
123
178
  - lib/boxgrinder-build/validators/config-validator.rb
124
- - lib/boxgrinder-build/validators/appliance-definition-validator.rb
125
179
  - lib/boxgrinder-build/validators/aws-validator.rb
126
180
  - lib/boxgrinder-build/appliance.rb
127
- - lib/boxgrinder-build/helpers/aws-helper.rb
181
+ - lib/boxgrinder-build/helpers/plugin-helper.rb
128
182
  - lib/boxgrinder-build/helpers/guestfs-helper.rb
129
- - lib/boxgrinder-build/helpers/ssh-helper.rb
130
183
  - lib/boxgrinder-build/helpers/rake-helper.rb
131
- - lib/boxgrinder-build/helpers/release-helper.rb
184
+ - lib/boxgrinder-build/helpers/package-helper.rb
132
185
  - lib/boxgrinder-build/helpers/appliance-customize-helper.rb
133
- - lib/boxgrinder-build/images/ec2-image.rb
134
- - lib/boxgrinder-build/images/raw-image.rb
135
- - lib/boxgrinder-build/images/vmware-image.rb
136
- - lib/boxgrinder-build/boxgrinder.rb
137
- - lib/boxgrinder-build/erb/appliance.ks.erb
138
- - src/motd.init
139
- - src/f12/yum.conf
140
- - src/base.vmx
141
- - src/oddthesis/oddthesis.repo
142
- - src/oddthesis/RPM-GPG-KEY-oddthesis
143
- - src/README.vmware
144
- - src/base.vmdk
145
- - src/base.repo
146
- - src/ec2/fstab_64bit
147
- - src/ec2/f12-i386-boxgrinder.repo
148
- - src/ec2/rc_local
149
- - src/ec2/ifcfg-eth0
150
- - src/ec2/f12-x86_64-boxgrinder.repo
151
- - src/ec2/fstab_32bit
152
186
  - docs/node-info/pom.xml
153
187
  - docs/node-info/src/main/webapp/WEB-INF/web.xml
154
188
  - docs/node-info/src/main/webapp/META-INF/MANIFEST.MF
155
189
  - docs/node-info/src/main/webapp/index.jsp
156
- - docs/examples/appliances/packages-appliance/packages-appliance.appl
157
- - docs/examples/appliances/packages-appliance/packages-appliance.pp
158
- - docs/examples/appliances/mix-appliance/mix-appliance.appl
159
- - docs/examples/appliances/mix-appliance/mix-appliance.pp
160
- - docs/examples/appliances/minimal-appliance/minimal-appliance.appl
161
- - docs/examples/appliances/minimal-appliance/minimal-appliance.pp
162
- - docs/examples/appliances/appliances-appliance/appliances-appliance.pp
163
- - docs/examples/appliances/appliances-appliance/appliances-appliance.appl
164
- - extras/sign-rpms
190
+ - docs/examples/appliances/appliances.appl
191
+ - docs/examples/appliances/minimal.appl
192
+ - docs/examples/appliances/mix.appl
193
+ - docs/examples/appliances/packages.appl
165
194
  - README
166
195
  - LICENSE
167
196
  has_rdoc: true
@@ -1,6 +0,0 @@
1
-
2
- summary: This is a appliance with multiple appliances
3
-
4
- appliances:
5
- - minimal-appliance
6
- - packages-appliance
@@ -1,16 +0,0 @@
1
- # Modules used by the appliance
2
- import "appliance_base"
3
- import "banners"
4
- import "firewall"
5
- import "ssh"
6
-
7
- # Information about our appliance
8
- $appliance_name = "<%= appliance_summary %>"
9
- $appliance_version = "<%= appliance_version %>"
10
-
11
- # Configuration
12
- appliance_base::setup{$appliance_name:}
13
- appliance_base::enable_updates{$appliance_name:}
14
- banners::all{$appliance_name:}
15
- firewall::setup{$appliance_name: status=>"disabled"}
16
- ssh::setup{$appliance_name:}
@@ -1,2 +0,0 @@
1
-
2
- summary: This is a appliance with minimal package set
@@ -1,16 +0,0 @@
1
- # Modules used by the appliance
2
- import "appliance_base"
3
- import "banners"
4
- import "firewall"
5
- import "ssh"
6
-
7
- # Information about our appliance
8
- $appliance_name = "<%= appliance_summary %>"
9
- $appliance_version = "<%= appliance_version %>"
10
-
11
- # Configuration
12
- appliance_base::setup{$appliance_name:}
13
- appliance_base::enable_updates{$appliance_name:}
14
- banners::all{$appliance_name:}
15
- firewall::setup{$appliance_name: status=>"disabled"}
16
- ssh::setup{$appliance_name:}
@@ -1,9 +0,0 @@
1
-
2
- summary: This is a appliance with additional packages and appliances
3
-
4
- appliances:
5
- - packages-appliance
6
-
7
- packages:
8
- - texlive-latex
9
- - subversion
@@ -1,16 +0,0 @@
1
- # Modules used by the appliance
2
- import "appliance_base"
3
- import "banners"
4
- import "firewall"
5
- import "ssh"
6
-
7
- # Information about our appliance
8
- $appliance_name = "<%= appliance_summary %>"
9
- $appliance_version = "<%= appliance_version %>"
10
-
11
- # Configuration
12
- appliance_base::setup{$appliance_name:}
13
- appliance_base::enable_updates{$appliance_name:}
14
- banners::all{$appliance_name:}
15
- firewall::setup{$appliance_name: status=>"disabled"}
16
- ssh::setup{$appliance_name:}
@@ -1,6 +0,0 @@
1
-
2
- summary: This is a appliance with additional packages
3
-
4
- packages:
5
- - mc
6
- - subversion
@@ -1,16 +0,0 @@
1
- # Modules used by the appliance
2
- import "appliance_base"
3
- import "banners"
4
- import "firewall"
5
- import "ssh"
6
-
7
- # Information about our appliance
8
- $appliance_name = "<%= appliance_summary %>"
9
- $appliance_version = "<%= appliance_version %>"
10
-
11
- # Configuration
12
- appliance_base::setup{$appliance_name:}
13
- appliance_base::enable_updates{$appliance_name:}
14
- banners::all{$appliance_name:}
15
- firewall::setup{$appliance_name: status=>"disabled"}
16
- ssh::setup{$appliance_name:}
data/extras/sign-rpms DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/expect -f
2
-
3
- set password [lindex $argv 0]
4
-
5
- foreach package [lrange $argv 1 end] {
6
- spawn -noecho rpm --resign $package
7
- expect -exact "Enter pass phrase: "
8
- send "$password\r"
9
- #expect -re "$package"
10
- }
11
-
12
- expect eof
@@ -1,93 +0,0 @@
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 'rake'
22
- require 'boxgrinder-core/defaults'
23
- require 'boxgrinder-core/models/config'
24
- require 'boxgrinder-core/models/appliance-config'
25
- require 'boxgrinder-core/helpers/appliance-config-helper'
26
- require 'boxgrinder-build/defaults'
27
- require 'boxgrinder-build/appliance'
28
- require 'boxgrinder-build/validators/validator'
29
- require 'boxgrinder-build/validators/appliance-config-parameter-validator'
30
- require 'boxgrinder-build/validators/appliance-definition-validator'
31
- require 'boxgrinder-build/helpers/rake-helper'
32
- require 'ostruct'
33
- require 'yaml'
34
-
35
- $stderr.reopen('/dev/null')
36
-
37
- module BoxGrinder
38
- class BoxGrinder
39
- def initialize( project_config = Hash.new )
40
- @log = LOG
41
- # validates parameters, this is a pre-validation
42
- ApplianceConfigParameterValidator.new.validate
43
-
44
- name = project_config[:name] || DEFAULT_PROJECT_CONFIG[:name]
45
- version = project_config[:version] || DEFAULT_PROJECT_CONFIG[:version]
46
- release = project_config[:release] || DEFAULT_PROJECT_CONFIG[:release]
47
-
48
- # dirs
49
-
50
- dir = OpenStruct.new
51
- dir.root = `pwd`.strip
52
- dir.base = "#{File.dirname( __FILE__ )}/../../"
53
- dir.build = project_config[:dir_build] || DEFAULT_PROJECT_CONFIG[:dir_build]
54
- dir.top = project_config[:dir_top] || "#{dir.build}/topdir"
55
- dir.src_cache = project_config[:dir_src_cache] || DEFAULT_PROJECT_CONFIG[:dir_src_cache]
56
- dir.rpms_cache = project_config[:dir_rpms_cache] || DEFAULT_PROJECT_CONFIG[:dir_rpms_cache]
57
- dir.specs = project_config[:dir_specs] || DEFAULT_PROJECT_CONFIG[:dir_specs]
58
- dir.appliances = project_config[:dir_appliances] || DEFAULT_PROJECT_CONFIG[:dir_appliances]
59
- dir.src = project_config[:dir_src] || DEFAULT_PROJECT_CONFIG[:dir_src]
60
- dir.kickstarts = project_config[:dir_kickstarts] || DEFAULT_PROJECT_CONFIG[:dir_kickstarts]
61
-
62
- config_file = ENV['BG_CONFIG_FILE'] || "#{ENV['HOME']}/.boxgrinder/config"
63
-
64
- @config = Config.new( name, version, release, dir, config_file )
65
-
66
- define_rules
67
- end
68
-
69
- def define_rules
70
- Validator.new( @config, :log => @log )
71
-
72
- Rake::Task[ 'validate:all' ].invoke
73
-
74
- directory @config.dir.build
75
-
76
- definitions = {}
77
-
78
- Dir[ "#{@config.dir.appliances}/**/*.appl", "#{@config.dir.base}/appliances/*.appl" ].each do |file|
79
- definition = YAML.load_file( file )
80
-
81
- ApplianceDefinitionValidator.new( definition ).validate
82
-
83
- definitions[definition['name']] = definition
84
- end
85
-
86
- for definition in definitions.values
87
- Appliance.new( @config, ApplianceConfigHelper.new( definitions ).merge( ApplianceConfig.new( definition ).init_arch ).initialize_paths, :log => @log )
88
- end
89
- end
90
-
91
- attr_reader :config
92
- end
93
- end
@@ -1,136 +0,0 @@
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 'rake/tasklib'
22
- require 'boxgrinder-core/validators/errors'
23
- require 'boxgrinder-build/validators/ssh-validator'
24
- require 'boxgrinder-build/models/ssh-config'
25
- require 'boxgrinder-build/helpers/ssh-helper'
26
-
27
- module BoxGrinder
28
- class ReleaseHelper < Rake::TaskLib
29
- def initialize( config, appliance_config, options = {} )
30
- @config = config
31
- @appliance_config = appliance_config
32
-
33
- @log = options[:log] || Logger.new(STDOUT)
34
- @exec_helper = options[:exec_helper] || ExecHelper.new( { :log => @log } )
35
-
36
- @package_build_commands = {
37
- :raw => {
38
- :tgz => "tar -C #{@appliance_config.path.dir.raw.build_full} -cvzf #{@appliance_config.path.file.package[:raw][:tgz]} #{@appliance_config.name}-sda.raw #{@appliance_config.name}.xml",
39
- :zip => "cd #{@appliance_config.path.dir.raw.build_full} && zip -r #{Dir.pwd}/#{@appliance_config.path.file.package[:raw][:zip]} ."
40
- },
41
- :vmware => {
42
- :tgz => "tar -C #{@appliance_config.path.dir.vmware.build} -cvzf '#{@appliance_config.path.file.package[:vmware][:tgz]}' README #{@appliance_config.name}-sda.raw personal/#{@appliance_config.name}.vmx personal/#{@appliance_config.name}.vmdk enterprise/#{@appliance_config.name}.vmx enterprise/#{@appliance_config.name}.vmdk",
43
- :zip => "cd #{@appliance_config.path.dir.vmware.build} && zip #{Dir.pwd}/#{@appliance_config.path.file.package[:vmware][:zip]} README #{@appliance_config.name}-sda.raw personal/#{@appliance_config.name}.vmx personal/#{@appliance_config.name}.vmdk enterprise/#{@appliance_config.name}.vmx enterprise/#{@appliance_config.name}.vmdk"
44
- }
45
- }
46
-
47
- @base_remote_file_path = "#{@config.version_with_release}/#{@appliance_config.hardware.arch}"
48
-
49
- define_tasks
50
- end
51
-
52
- def define_tasks
53
-
54
- directory @appliance_config.path.dir.packages
55
-
56
- [ :tgz, :zip ].each do |package_format|
57
- task "appliance:#{@appliance_config.name}:package:#{package_format}" => [ @appliance_config.path.file.package[:raw][package_format], @appliance_config.path.file.package[:vmware][package_format] ]
58
-
59
- [ :vmware, :raw ].each do |image_format|
60
- basename = File.basename( @appliance_config.path.file.package[image_format][package_format] )
61
- files_to_upload = { "#{@appliance_config.name}/#{@appliance_config.version}.#{@appliance_config.release}/#{@appliance_config.hardware.arch}/#{basename}" => @appliance_config.path.file.package[image_format][package_format] }
62
-
63
- desc "Create #{image_format.to_s.upcase} #{package_format.to_s.upcase} package for #{@appliance_config.simple_name} appliance"
64
- task "appliance:#{@appliance_config.name}:package:#{image_format}:#{package_format}" => [ @appliance_config.path.file.package[image_format][package_format] ]
65
-
66
- file @appliance_config.path.file.package[image_format][package_format] => [ @appliance_config.path.dir.packages, "appliance:#{@appliance_config.name}" ] do
67
- @log.info "Packaging #{@appliance_config.name} appliance #{image_format.to_s.upcase} image (#{@appliance_config.os.name} #{@appliance_config.os.version}, #{@appliance_config.hardware.arch} arch, #{package_format.to_s.upcase} format)..."
68
-
69
- Rake::Task[ "#{@appliance_config.path.dir.vmware.build}/README" ].invoke if image_format.eql?(:vmware)
70
-
71
- @exec_helper.execute @package_build_commands[image_format][package_format]
72
- @log.info "#{image_format.to_s.upcase} #{package_format.to_s.upcase} package created."
73
- end
74
-
75
- task "appliance:#{@appliance_config.name}:upload:#{image_format}:#{package_format}:ssh" => [ "appliance:#{@appliance_config.name}:package:#{image_format}:#{package_format}" ] do
76
- upload_via_ssh( files_to_upload )
77
- end
78
-
79
- task "appliance:#{@appliance_config.name}:upload:#{image_format}:#{package_format}:cloudfront" => [ "appliance:#{@appliance_config.name}:package:#{image_format}:#{package_format}" ] do
80
- upload_to_cloudfront( files_to_upload )
81
- end
82
- end
83
- end
84
-
85
- file "#{@appliance_config.path.dir.vmware.build}/README" => [ "appliance:#{@appliance_config.name}:vmware:personal", "appliance:#{@appliance_config.name}:vmware:enterprise" ] do
86
- readme = File.open( "#{@config.dir.base}/src/README.vmware" ).read
87
-
88
- readme.gsub!( /#APPLIANCE_NAME#/, @appliance_config.name )
89
- readme.gsub!( /#NAME#/, @config.name )
90
- readme.gsub!( /#VERSION#/, @config.version_with_release )
91
-
92
- File.open( "#{@appliance_config.path.dir.vmware.build}/README", "w") {|f| f.write( readme ) }
93
- end
94
-
95
- end
96
-
97
- def upload_via_ssh( files )
98
- @log.info "Uploading #{@appliance_config.name} appliance via SSH..."
99
-
100
- SSHValidator.new( @config ).validate
101
-
102
- ssh_config = SSHConfig.new( @config )
103
-
104
- ssh_helper = SSHHelper.new( ssh_config.options, { :log => @log } )
105
- ssh_helper.connect
106
- ssh_helper.upload_files( ssh_config.cfg['remote_release_path'], files )
107
- ssh_helper.disconnect
108
-
109
- @log.info "Appliance #{@appliance_config.simple_name} uploaded."
110
- end
111
-
112
- def upload_to_cloudfront( files )
113
- AWSHelper.new( @config, @appliance_config )
114
-
115
- bucket = @config.data['release']['cloudfront']['bucket_name']
116
-
117
- @log.info "Uploading #{@appliance_config.name} appliance to CloudFront bucket '#{bucket}'..."
118
-
119
- begin
120
- AWS::S3::Bucket.find( bucket )
121
- rescue AWS::S3::NoSuchBucket
122
- AWS::S3::Bucket.create( bucket )
123
- retry
124
- end
125
-
126
- for key in files.keys
127
- unless S3Object.exists?( key, bucket )
128
- AWS::S3::S3Object.store( key, open( files[key] ), bucket, :access => :public_read )
129
- end
130
- end
131
-
132
- @log.info "Appliance #{@appliance_config.simple_name} uploaded."
133
- end
134
- end
135
- end
136
-