boxgrinder-build 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/README.md +32 -34
- data/Rakefile +7 -1
- data/bin/boxgrinder-build +10 -17
- data/boxgrinder-build.gemspec +7 -4
- data/lib/boxgrinder-build/appliance.rb +13 -16
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +84 -40
- data/lib/boxgrinder-build/helpers/image-helper.rb +54 -85
- data/lib/boxgrinder-build/helpers/linux-helper.rb +29 -9
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +1 -0
- data/lib/boxgrinder-build/plugins/base-plugin.rb +3 -2
- data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +13 -42
- data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +209 -0
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +8 -4
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +0 -7
- data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +4 -1
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +52 -9
- data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +6 -2
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +4 -44
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +1 -1
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +1 -1
- data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +2 -2
- data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +24 -13
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +2 -2
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +0 -1
- data/rubygem-boxgrinder-build.spec +23 -1
- data/spec/appliance-spec.rb +5 -79
- data/spec/helpers/augeas-helper-spec.rb +1 -0
- data/spec/helpers/guestfs-helper-spec.rb +79 -62
- data/spec/helpers/image-helper-spec.rb +88 -129
- data/spec/helpers/linux-helper-spec.rb +22 -5
- data/spec/helpers/package-helper-spec.rb +1 -0
- data/spec/helpers/plugin-helper-spec.rb +1 -0
- data/spec/managers/plugin-manager-spec.rb +3 -2
- data/spec/plugins/base-plugin-spec.rb +1 -1
- data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +21 -13
- data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +320 -0
- data/spec/plugins/delivery/local/local-plugin-spec.rb +1 -0
- data/spec/plugins/delivery/s3/s3-plugin-spec.rb +1 -0
- data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +1 -0
- data/spec/plugins/os/centos/centos-plugin-spec.rb +1 -0
- data/spec/plugins/os/fedora/fedora-plugin-spec.rb +13 -1
- data/spec/plugins/os/rhel/rhel-plugin-spec.rb +1 -15
- data/spec/plugins/os/rpm-based/kickstart-spec.rb +1 -0
- data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +75 -15
- data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +1 -0
- data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +10 -43
- data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +89 -10
- data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +3 -2
- metadata +21 -7
- data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +0 -45
- data/spec/helpers/appliance-customize-helper-spec.rb +0 -74
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
v0.9.1
|
2
|
+
|
3
|
+
* [BGBUILD-188] Use libuestfs instead mounting partitions manually for EC2 appliances
|
4
|
+
* [BGBUILD-97] some filesystems dont get unmounted on BG interruption
|
5
|
+
* [BGBUILD-155] Images built on Centos5.x (el5) for VirtualBox kernel panic (/dev/root missing)
|
6
|
+
* [BGBUILD-190] Allow to specify kernel variant (PAE or not) for Fedora OS
|
7
|
+
* [BGBUILD-196] GuestFS fails mounting partitions where more then 3 partitions are present
|
8
|
+
* [BGBUILD-200] /sbin/e2label: Filesystem has unsupported feature(s) while trying to open /dev/sda1
|
9
|
+
* [BGBUILD-194] Add support for ElasticHosts cloud
|
10
|
+
* [BGBUILD-202] Unable to get valid context for ec2-user after login on AMI
|
11
|
+
|
1
12
|
v0.9.0
|
2
13
|
|
3
14
|
* [BGBUILD-174] Move plugins to boxgrinder-build gem
|
data/README.md
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
# BoxGrinder
|
2
2
|
|
3
|
-
BoxGrinder is a set of projects that help you grind out appliances for multiple virtualization and Cloud providers.
|
3
|
+
BoxGrinder is a set of projects that help you grind out appliances for multiple virtualization and Cloud providers.
|
4
4
|
|
5
|
-
Visit us at [boxgrinder.org](http://www.boxgrinder.org)
|
5
|
+
Visit us at [boxgrinder.org](http://www.boxgrinder.org), or join #boxgrinder on irc.freenode.net
|
6
6
|
|
7
7
|
## BoxGrinder Build
|
8
8
|
|
9
|
-
BoxGrinder Build is a command line tool to help you build appliances. With an appliance definition and just a single command, BoxGrinder can create your appliance, target it to a platform and deliver it.
|
9
|
+
BoxGrinder Build is a command line tool to help you build appliances. With an appliance definition and just a single command, BoxGrinder can create your appliance, target it to a platform and deliver it.
|
10
10
|
|
11
|
-
### Boxgrinder Build Meta Appliance:
|
11
|
+
### Boxgrinder Build Meta Appliance: BoxGrinder the Easy Way
|
12
12
|
|
13
|
-
The
|
13
|
+
The BoxGrinder Meta appliance is pre-configured with an optimal environment prepared to use BoxGrinder right from launch. Just [download the latest appliance](http://boxgrinder.org/download/boxgrinder-build-meta-appliance/) from boxgrinder.org in your desired format, launch it, and you're ready to grind out images!
|
14
14
|
|
15
15
|
It is a great way to use or test BoxGrinder in a virtual environment without affecting your local system.
|
16
16
|
|
17
|
-
Visit the [
|
17
|
+
Visit the [BoxGrinder Meta appliance usage article](http://boxgrinder.org/tutorials/boxgrinder-build-meta-appliance/) to learn more.
|
18
18
|
|
19
19
|
### Supported OSes
|
20
20
|
|
21
21
|
At present the project officially supports the following OSes in x86_64 and i386 variants:
|
22
22
|
|
23
|
-
* Fedora (13, 14)
|
23
|
+
* Fedora (13, 14, 15)
|
24
24
|
* RHEL (5.x, 6.x) and CentOS (5.x)
|
25
25
|
|
26
26
|
### Requirements
|
27
27
|
|
28
|
-
* Acquiring and installing BoxGrinder is very simple, with RPMs ensuring the correct dependencies are pulled and installed. However, depending upon your OS of choice, the prerequisites for installing BoxGrinder vary slightly.
|
28
|
+
* Acquiring and installing BoxGrinder is very simple, with RPMs ensuring the correct dependencies are pulled and installed. However, depending upon your OS of choice, the prerequisites for installing BoxGrinder vary slightly.
|
29
29
|
* Administrative level permissions (root or equivalent)
|
30
30
|
|
31
31
|
#### Fedora
|
@@ -42,35 +42,35 @@ For detailed instructions, see: [Preparing your environment](http://boxgrinder.o
|
|
42
42
|
|
43
43
|
Once the prerequisites are satisfied, install BoxGrinder via a package manager, for instance in YUM;
|
44
44
|
|
45
|
-
* `sudo yum install
|
46
|
-
|
47
|
-
You may only wish to install a subset of the available plugins, see the [BoxGrinder plugins list](http://boxgrinder.org/tutorials/#Plugin_list) to find out which are available. You can, of course, [write your own](http://boxgrinder.org/tutorials/how-to-write-a-plugin-for-boxgrinder-build/) plugins!
|
45
|
+
* `sudo yum install rubygem-boxgrinder-build` to install BoxGrinder Build.
|
48
46
|
|
49
47
|
### Removing
|
50
48
|
|
51
49
|
You should remove BoxGrinder through your system package manager, for instance with YUM:
|
52
50
|
|
53
|
-
* `sudo yum remove
|
51
|
+
* `sudo yum remove rubygem-boxgrinder*`
|
54
52
|
|
55
53
|
### Usage
|
56
54
|
|
57
|
-
BoxGrinder.org's [quick-start](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/) tutorial is the best place to learn the fundamentals of BoxGrinder Build, enabling you to rapidly leverage the feature-set on offer.
|
55
|
+
BoxGrinder.org's [quick-start](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/) tutorial is the best place to learn the fundamentals of BoxGrinder Build, enabling you to rapidly leverage the feature-set on offer.
|
58
56
|
|
59
|
-
The following sections provide a basic overview of functionality.
|
57
|
+
The following sections provide a basic overview of functionality.
|
60
58
|
|
61
59
|
### Plugins
|
62
60
|
|
63
|
-
Most of the features of BoxGrinder Build are provided through plugins, with three primary variants (Operating System, Platform and Delivery), each catering for a phase of the build process.
|
61
|
+
Most of the features of BoxGrinder Build are provided through plugins, with three primary variants (Operating System, Platform and Delivery), each catering for a phase of the build process. Furthermore, the flexible and extensible structure of BoxGrinder Build enables users to seamlessly add new features and functionality.
|
62
|
+
|
63
|
+
As of version 0.9.0 BoxGrinder Build is distributed with [standard plugins](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Plugin_introduction) installed by default.
|
64
64
|
|
65
65
|
* Operating System - provide support to run and build for a given OS
|
66
66
|
* Platform - ability to produce appliances for a specific platform, such as Amazon's EC2 or VirtualBox VM
|
67
67
|
* Delivery - send the completed appliance, for instance by SFTP or bundled as an AMI and uploaded to S3.
|
68
68
|
|
69
|
-
Learn more: [BoxGrinder Build](http://boxgrinder.org/build/)
|
69
|
+
Learn more: [BoxGrinder Build](http://boxgrinder.org/build/), [BoxGrinder Plugins](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/)
|
70
70
|
|
71
71
|
#### Plugin Configuration
|
72
72
|
|
73
|
-
Many plugins allow, or mandate, some degree of configuration before they are executed. These properties are aggregated into a single per-user configuration file, at `~/.boxgrinder/config`. The user should consult the documentation of a given plugin to determine what fields it should be configured with, and which fields (if any), are requisite.
|
73
|
+
Many plugins allow, or mandate, some degree of configuration before they are executed. These properties are aggregated into a single per-user configuration file, at `~/.boxgrinder/config`. The user should consult the documentation of a given plugin to determine what fields it should be configured with, and which fields (if any), are requisite.
|
74
74
|
|
75
75
|
plugins:
|
76
76
|
sftp:
|
@@ -80,7 +80,7 @@ Many plugins allow, or mandate, some degree of configuration before they are exe
|
|
80
80
|
|
81
81
|
* In this example, the SFTP plugin's fields are [all mandatory](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#SFTP_Delivery_Plugin).
|
82
82
|
|
83
|
-
Learn more: [BoxGrinder Plugins](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Plugin_configuration)
|
83
|
+
Learn more: [BoxGrinder Plugins](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Plugin_configuration)
|
84
84
|
|
85
85
|
#### Defining Appliances
|
86
86
|
|
@@ -97,40 +97,38 @@ Appliances are defined in YAML, the following "JEOS" definition can be used by B
|
|
97
97
|
size: 2
|
98
98
|
packages:
|
99
99
|
- @core
|
100
|
-
|
101
|
-
* With this simple definition, BoxGrinder will produce a Fedora 14 appliance with the Core [group of packages](http://yum.baseurl.org/wiki/YumGroups). You can easily add packages, repositories, and harness a plethora of powerful features in a concise, declarative manner.
|
102
|
-
* For an introduction to Appliance Definitions, see: [Quick-start, building your first appliance](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/build-your-first-appliance)
|
100
|
+
|
101
|
+
* With this simple definition, BoxGrinder will produce a Fedora 14 appliance with the Core [group of packages](http://yum.baseurl.org/wiki/YumGroups). You can easily add packages, repositories, and harness a plethora of powerful features in a concise, declarative manner.
|
102
|
+
* For an introduction to Appliance Definitions, see: [Quick-start, building your first appliance](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/build-your-first-appliance)
|
103
103
|
* For fuller explanations of all parameters BoxGrinder offers, see: [Appliance definition parameters](http://boxgrinder.org/tutorials/appliance-definition/)
|
104
|
-
|
104
|
+
|
105
105
|
#### Building Appliances
|
106
|
-
The BoxGrinder Build CLI is a simple interface through which you can instruct BoxGrinder to build your appliances. You can view a brief manual
|
106
|
+
The BoxGrinder Build CLI is a simple interface through which you can instruct BoxGrinder to build your appliances. You can view a brief manual by using `boxgrinder-build --help`, and version information through `boxgrinder-build --version`
|
107
107
|
|
108
|
-
|
108
|
+
BoxGrinder Build is run with a mandatory appliance definition, along with optional platform and delivery plugin specifiers. BoxGrinder resolves the packages and associated dependencies in the appliance definition, and installs them into the new image it generates based upon the operating system and versions specified.
|
109
109
|
|
110
|
-
|
110
|
+
boxgrinder-build [appliance definition file] [options]
|
111
111
|
|
112
|
-
boxgrinder build [appliance definition file] [options]
|
113
|
-
|
114
112
|
* The two most common options are `[-p|--platform=]` and `[-d|--delivery=]`. Neither is mandatory, if platform is omitted then only the raw KVM image is created. You can can later return and target a build to different platforms, and BoxGrinder will always reuse the intermediary data where it is available. If you wish to force a rebuild, you can use the `[-f|--force]` flag.
|
115
113
|
* It is possible to manually provide key-value pairs for platform and delivery plugin configuration on the command line. These will override any pre-existing plugin parameters set in the BoxGrinder config file.
|
116
|
-
* Shell commands can be executed in `post` sections of the appliance definition files, which is useful for basic configuration. However, it is advisable that more complex configuration and installation of custom software is performed properly through RPM files. This is often best achieved through local repositories, which can be configured as [_ephemeral_](http://boxgrinder.org/tutorials/appliance-definition/) in order to avoid the repository being installed into the resultant image's package manager.
|
117
|
-
|
118
|
-
See: [BoxGrinder Build Usage Instructions](http://boxgrinder.org/tutorials/boxgrinder-build-usage-instructions/), [How to use local repositories](http://boxgrinder.org/tutorials/how-to-use-local-repository)
|
114
|
+
* Shell commands can be executed in `post` sections of the appliance definition files, which is useful for basic configuration. However, it is advisable that more complex configuration and installation of custom software is performed properly through RPM files. This is often best achieved through local repositories, which can be configured as [_ephemeral_](http://boxgrinder.org/tutorials/appliance-definition/) in order to avoid the repository being installed into the resultant image's package manager.
|
115
|
+
|
116
|
+
See: [BoxGrinder Build Usage Instructions](http://boxgrinder.org/tutorials/boxgrinder-build-usage-instructions/), [How to use local repositories](http://boxgrinder.org/tutorials/how-to-use-local-repository)
|
119
117
|
|
120
118
|
##### Examples
|
121
119
|
|
122
|
-
boxgrinder
|
120
|
+
boxgrinder-build fedora-14.appl -p vmware -d sftp
|
123
121
|
|
124
122
|
Build an image based upon _fedora-14.appl_, and produce an image targeted at the _vmware_ platform. Once complete, deliver by _sftp_. Note that each of these plugins must be configured in `~/.boxgrinder/conf` or by providing the key-value pairs as command-line arguments.
|
125
123
|
|
126
124
|
-----------------------
|
127
125
|
|
128
|
-
boxgrinder
|
126
|
+
boxgrinder-build fedora-14.appl -p virtualbox -d local
|
129
127
|
|
130
128
|
Assuming that BoxGrinder had succeeded in building the prior image, the RAW file is again used as an intermediary without needing to be rebuild. An image targeted at VirtualBox is then produced, and delivered to a local file, as determined in _conf_.
|
131
129
|
|
132
130
|
-----------------------
|
133
131
|
|
134
132
|
setarch i386 boxgrinder build fedora-14.appl
|
135
|
-
|
136
|
-
Build an i386 appliance (on an x86_64 machine).
|
133
|
+
|
134
|
+
Build an i386 appliance (on an x86_64 machine).
|
data/Rakefile
CHANGED
@@ -17,7 +17,12 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'rubygems'
|
20
|
-
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'rake/dsl'
|
23
|
+
rescue LoadError
|
24
|
+
end
|
25
|
+
|
21
26
|
require 'echoe'
|
22
27
|
|
23
28
|
Echoe.new("boxgrinder-build") do |p|
|
@@ -31,6 +36,7 @@ Echoe.new("boxgrinder-build") do |p|
|
|
31
36
|
'aws', # S3
|
32
37
|
'amazon-ec2', # EBS and S3
|
33
38
|
'net-sftp', 'net-ssh', 'progressbar', # SFTP
|
39
|
+
'rest-client' # ElasticHosts
|
34
40
|
]
|
35
41
|
end
|
36
42
|
|
data/bin/boxgrinder-build
CHANGED
@@ -32,15 +32,10 @@ end
|
|
32
32
|
options = OpenCascade.new(
|
33
33
|
:platform => :none,
|
34
34
|
:delivery => :none,
|
35
|
-
:force => false,
|
36
35
|
:os_config => {},
|
37
36
|
:platform_config => {},
|
38
37
|
:delivery_config => {},
|
39
|
-
:additional_plugins => []
|
40
|
-
:debug => false,
|
41
|
-
:trace => false,
|
42
|
-
:backtrace => false,
|
43
|
-
:log_level => :info
|
38
|
+
:additional_plugins => []
|
44
39
|
)
|
45
40
|
|
46
41
|
def validate_hash_option(options, name, value)
|
@@ -130,8 +125,8 @@ EOB
|
|
130
125
|
opts.separator ""
|
131
126
|
opts.separator "Logging options:"
|
132
127
|
|
133
|
-
opts.on("--debug", "Prints debug information while building. Default: false.") {
|
134
|
-
opts.on("--trace", "Prints trace information while building. Default: false.") {
|
128
|
+
opts.on("--debug", "Prints debug information while building. Default: false.") { options[:log_level] = :debug }
|
129
|
+
opts.on("--trace", "Prints trace information while building. Default: false.") { options[:log_level] = :trace }
|
135
130
|
opts.on("-b", "--backtrace", "Prints full backtrace if errors occur whilst building. Default: true if console log is set to debug or trace, otherwise false.") { |v| options[:backtrace] = v }
|
136
131
|
|
137
132
|
opts.separator ""
|
@@ -175,20 +170,18 @@ begin
|
|
175
170
|
abort
|
176
171
|
end
|
177
172
|
|
178
|
-
|
179
|
-
|
180
|
-
options.backtrace = :true if [:debug, :trace].include?(options.log_level)
|
181
|
-
|
182
|
-
log = BoxGrinder::LogHelper.new(:level => options.log_level)
|
173
|
+
config = BoxGrinder::Config.new(options)
|
174
|
+
log = BoxGrinder::LogHelper.new(:level => config.log_level)
|
183
175
|
|
184
176
|
begin
|
185
|
-
BoxGrinder::Appliance.new(appliance_definition_file,
|
177
|
+
BoxGrinder::Appliance.new(appliance_definition_file, config, :log => log).create
|
186
178
|
rescue Exception => e
|
179
|
+
msg = "#{e.class}: #{e.message}#$/#{e.backtrace.join($/)}"
|
187
180
|
if options.backtrace
|
188
|
-
log.fatal
|
181
|
+
log.fatal msg
|
189
182
|
else # demote backtrace to debug so that it is in file log only
|
190
|
-
log.fatal "#{e.message}. See the log file for detailed information."
|
191
|
-
log.debug
|
183
|
+
log.fatal "#{e.class}: #{e.message}. See the log file for detailed information."
|
184
|
+
log.debug msg
|
192
185
|
end
|
193
186
|
end
|
194
187
|
rescue => e
|
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.9.
|
5
|
+
s.version = "0.9.1"
|
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{2011-
|
9
|
+
s.date = %q{2011-04-27}
|
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
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "bin/boxgrinder-build", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/
|
15
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.md", "Rakefile", "bin/boxgrinder-build", "boxgrinder-build.gemspec", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "bin/boxgrinder-build", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.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", "lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb", "lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb", "lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem", "lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb", "lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb", "lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb", "lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb", "lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb", "lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb", "lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo", "lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init", "lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit", "lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0", "lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst", "lib/boxgrinder-build/plugins/platform/ec2/src/rc_local", "lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb", "lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise", "lib/boxgrinder-build/plugins/platform/vmware/src/README-personal", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx", "lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb"]
|
15
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.md", "Rakefile", "bin/boxgrinder-build", "boxgrinder-build.gemspec", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.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", "lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb", "lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb", "lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem", "lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb", "lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb", "lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb", "lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb", "lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb", "lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb", "lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo", "lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init", "lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit", "lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0", "lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst", "lib/boxgrinder-build/plugins/platform/ec2/src/rc_local", "lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb", "lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise", "lib/boxgrinder-build/plugins/platform/vmware/src/README-personal", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx", "lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-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/plugins/delivery/ebs/ebs-plugin-spec.rb", "spec/plugins/delivery/ebs/ebs.yaml", "spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb", "spec/plugins/delivery/local/local-plugin-spec.rb", "spec/plugins/delivery/s3/s3-plugin-spec.rb", "spec/plugins/delivery/sftp/sftp-plugin-spec.rb", "spec/plugins/os/centos/centos-plugin-spec.rb", "spec/plugins/os/fedora/fedora-plugin-spec.rb", "spec/plugins/os/rhel/rhel-plugin-spec.rb", "spec/plugins/os/rpm-based/kickstart-spec.rb", "spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb", "spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb", "spec/plugins/os/rpm-based/src/jeos-f13-plain.ks", "spec/plugins/os/rpm-based/src/jeos-f13-without-version.ks", "spec/plugins/os/rpm-based/src/jeos-f13.ks", "spec/plugins/platform/ec2/ec2-plugin-spec.rb", "spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb", "spec/plugins/platform/vmware/vmware-plugin-spec.rb"]
|
16
16
|
s.homepage = %q{http://boxgrinder.org/}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README.md"]
|
18
18
|
s.require_paths = ["lib"]
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_runtime_dependency(%q<net-sftp>, [">= 0"])
|
32
32
|
s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
|
33
33
|
s.add_runtime_dependency(%q<progressbar>, [">= 0"])
|
34
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
34
35
|
else
|
35
36
|
s.add_dependency(%q<boxgrinder-core>, ["~> 0.3.0"])
|
36
37
|
s.add_dependency(%q<aws>, [">= 0"])
|
@@ -38,6 +39,7 @@ Gem::Specification.new do |s|
|
|
38
39
|
s.add_dependency(%q<net-sftp>, [">= 0"])
|
39
40
|
s.add_dependency(%q<net-ssh>, [">= 0"])
|
40
41
|
s.add_dependency(%q<progressbar>, [">= 0"])
|
42
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
41
43
|
end
|
42
44
|
else
|
43
45
|
s.add_dependency(%q<boxgrinder-core>, ["~> 0.3.0"])
|
@@ -46,5 +48,6 @@ Gem::Specification.new do |s|
|
|
46
48
|
s.add_dependency(%q<net-sftp>, [">= 0"])
|
47
49
|
s.add_dependency(%q<net-ssh>, [">= 0"])
|
48
50
|
s.add_dependency(%q<progressbar>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
49
52
|
end
|
50
53
|
end
|
@@ -25,7 +25,6 @@ require 'boxgrinder-core/helpers/appliance-definition-helper'
|
|
25
25
|
require 'boxgrinder-core/helpers/appliance-config-helper'
|
26
26
|
require 'boxgrinder-build/helpers/plugin-helper'
|
27
27
|
require 'boxgrinder-build/managers/plugin-manager'
|
28
|
-
require 'boxgrinder-core/validators/appliance-config-validator'
|
29
28
|
|
30
29
|
module BoxGrinder
|
31
30
|
class Appliance
|
@@ -36,32 +35,30 @@ module BoxGrinder
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def read_definition
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#
|
38
|
+
# first try to read as appliance definition file
|
39
|
+
appliance_helper = ApplianceDefinitionHelper.new(:log => @log)
|
40
|
+
appliance_helper.read_definitions(@appliance_definition)
|
41
|
+
|
42
|
+
appliance_configs = appliance_helper.appliance_configs
|
43
|
+
appliance_config = appliance_configs.first
|
44
|
+
|
45
|
+
if appliance_config.nil?
|
46
|
+
# Still nothing? Then try to read OS plugin specific format...
|
48
47
|
PluginManager.instance.plugins[:os].each_value do |info|
|
49
48
|
plugin = info[:class].new
|
50
49
|
appliance_config = plugin.read_file(@appliance_definition) if plugin.respond_to?(:read_file)
|
51
50
|
break unless appliance_config.nil?
|
52
51
|
end
|
53
52
|
appliance_configs = [appliance_config]
|
54
|
-
end
|
55
53
|
|
56
|
-
|
54
|
+
raise ValidationError, "Couldn't read appliance definition file: #{File.basename(@appliance_definition)}." if appliance_config.nil?
|
55
|
+
end
|
57
56
|
|
58
57
|
appliance_config_helper = ApplianceConfigHelper.new(appliance_configs)
|
59
58
|
@appliance_config = appliance_config_helper.merge(appliance_config.clone.init_arch).initialize_paths
|
60
59
|
end
|
61
60
|
|
62
61
|
def validate_definition
|
63
|
-
ApplianceConfigValidator.new(@appliance_config).validate
|
64
|
-
|
65
62
|
raise "No operating system plugins installed. Install one or more operating system plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins for more info." if PluginManager.instance.plugins[:os].empty?
|
66
63
|
|
67
64
|
os_plugin = PluginManager.instance.plugins[:os][@appliance_config.os.name.to_sym]
|
@@ -84,7 +81,7 @@ module BoxGrinder
|
|
84
81
|
|
85
82
|
def create
|
86
83
|
@log.debug "Launching new BoxGrinder build..."
|
87
|
-
@log.trace "Used configuration: #{@config.to_yaml.gsub(/(\S*(key|account|cert|username|host)\S*).*:(.*)/, '\1' + ": <REDACTED>")}"
|
84
|
+
@log.trace "Used configuration: #{@config.to_yaml.gsub(/(\S*(key|account|cert|username|host|password)\S*).*:(.*)/, '\1' + ": <REDACTED>")}"
|
88
85
|
|
89
86
|
PluginHelper.new(@config, :log => @log).load_plugins
|
90
87
|
read_definition
|
@@ -101,7 +98,7 @@ module BoxGrinder
|
|
101
98
|
|
102
99
|
if os_plugin.deliverables_exists?
|
103
100
|
@log.info "Deliverables for #{os_plugin_info[:name]} operating system plugin exists, skipping."
|
104
|
-
return {:deliverables => os_plugin.deliverables}
|
101
|
+
return {:deliverables => os_plugin.deliverables, :plugin_info => os_plugin_info}
|
105
102
|
end
|
106
103
|
|
107
104
|
@log.debug "Executing operating system plugin for #{@appliance_config.os.name}..."
|
@@ -39,6 +39,10 @@ module BoxGrinder
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def respond_to?(m)
|
43
|
+
@o.respond_to?(m)
|
44
|
+
end
|
45
|
+
|
42
46
|
def redirect_streams(destination)
|
43
47
|
old_stdout_stream = STDOUT.dup
|
44
48
|
old_stderr_stream = STDERR.dup
|
@@ -81,11 +85,11 @@ end
|
|
81
85
|
|
82
86
|
module BoxGrinder
|
83
87
|
class GuestFSHelper
|
84
|
-
def initialize(
|
85
|
-
@
|
88
|
+
def initialize(disks, appliance_config, config, options = {})
|
89
|
+
@disks = disks
|
90
|
+
@appliance_config = appliance_config
|
91
|
+
@config = config
|
86
92
|
@log = options[:log] || LogHelper.new
|
87
|
-
|
88
|
-
@partitions = {}
|
89
93
|
end
|
90
94
|
|
91
95
|
attr_reader :guestfs
|
@@ -134,10 +138,21 @@ module BoxGrinder
|
|
134
138
|
end
|
135
139
|
|
136
140
|
def execute(pipe = nil, options = {})
|
137
|
-
options = {
|
141
|
+
options = {
|
142
|
+
:ide_disk => false,
|
143
|
+
:mount_prefix => '',
|
144
|
+
:automount => true,
|
145
|
+
:load_selinux_policy => true
|
146
|
+
}.merge(options)
|
138
147
|
|
139
148
|
@log.debug "Preparing guestfs..."
|
140
149
|
|
150
|
+
@log.trace "Setting libguestfs temporary directory to '#{@config.dir.tmp}'..."
|
151
|
+
|
152
|
+
FileUtils.mkdir_p(@config.dir.tmp)
|
153
|
+
|
154
|
+
ENV['TMPDIR'] = @config.dir.tmp
|
155
|
+
|
141
156
|
@guestfs = pipe.nil? ? Guestfs::create : Guestfs::create.redirect(pipe)
|
142
157
|
|
143
158
|
# https://bugzilla.redhat.com/show_bug.cgi?id=502058
|
@@ -161,13 +176,15 @@ module BoxGrinder
|
|
161
176
|
end
|
162
177
|
end
|
163
178
|
|
164
|
-
@
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
179
|
+
@disks.each do |disk|
|
180
|
+
@log.trace "Adding drive '#{disk}'..."
|
181
|
+
if options[:ide_disk]
|
182
|
+
@guestfs.add_drive_with_if(disk, 'ide')
|
183
|
+
else
|
184
|
+
@guestfs.add_drive(disk)
|
185
|
+
end
|
186
|
+
@log.trace "Drive added."
|
169
187
|
end
|
170
|
-
@log.trace "Drive added."
|
171
188
|
|
172
189
|
if @guestfs.respond_to?('set_network')
|
173
190
|
@log.debug "Enabling networking for GuestFS..."
|
@@ -177,16 +194,17 @@ module BoxGrinder
|
|
177
194
|
@log.debug "Launching guestfs..."
|
178
195
|
@guestfs.launch
|
179
196
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
mount_partition(
|
197
|
+
if options[:automount]
|
198
|
+
device = @guestfs.list_devices.first
|
199
|
+
|
200
|
+
if @guestfs.list_partitions.size == 0
|
201
|
+
mount_partition(device, '/', options[:mount_prefix])
|
185
202
|
else
|
186
|
-
mount_partitions
|
187
|
-
|
203
|
+
mount_partitions(device, options[:mount_prefix])
|
204
|
+
end
|
188
205
|
|
189
|
-
|
206
|
+
load_selinux_policy if options[:load_selinux_policy]
|
207
|
+
end
|
190
208
|
|
191
209
|
@log.trace "Guestfs launched."
|
192
210
|
|
@@ -204,10 +222,14 @@ module BoxGrinder
|
|
204
222
|
|
205
223
|
selinux = @guestfs.aug_get("/files/etc/sysconfig/selinux/SELINUX")
|
206
224
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
225
|
+
begin
|
226
|
+
@guestfs.sh("/usr/sbin/load_policy") if !selinux.nil? and !selinux.eql?('disabled')
|
227
|
+
@log.trace "SElinux policy loaded."
|
228
|
+
rescue
|
229
|
+
@log.warn "Loading SELinux policy failed. SELinux may be not fully initialized."
|
230
|
+
ensure
|
231
|
+
@guestfs.aug_close
|
232
|
+
end
|
211
233
|
end
|
212
234
|
|
213
235
|
def clean_close
|
@@ -220,34 +242,56 @@ module BoxGrinder
|
|
220
242
|
@log.trace "Guestfs closed."
|
221
243
|
end
|
222
244
|
|
223
|
-
def mount_partition(part, mount_point)
|
245
|
+
def mount_partition(part, mount_point, mount_prefix = '')
|
224
246
|
@log.trace "Mounting #{part} partition to #{mount_point}..."
|
225
|
-
@guestfs.mount_options("", part, mount_point)
|
247
|
+
@guestfs.mount_options("", part, "#{mount_prefix}#{mount_point}")
|
226
248
|
@log.trace "Partition mounted."
|
227
249
|
end
|
228
250
|
|
229
|
-
|
230
|
-
|
251
|
+
# This mount partitions. We assume that the first partition is a root partition.
|
252
|
+
#
|
253
|
+
def mount_partitions(device, mount_prefix = '')
|
254
|
+
@log.trace "Mounting partitions..."
|
231
255
|
|
232
|
-
|
233
|
-
mount_partition(partition, '/')
|
256
|
+
partitions = mountable_partitions(device)
|
234
257
|
|
235
|
-
|
236
|
-
if @guestfs.exists('/sbin/e2label') != 0
|
237
|
-
root_partition = partition
|
238
|
-
break
|
239
|
-
end
|
240
|
-
@guestfs.umount(partition)
|
241
|
-
end
|
258
|
+
mount_points = LinuxHelper.new(:log => @log).partition_mount_points(@appliance_config.hardware.partitions)
|
242
259
|
|
243
|
-
|
260
|
+
partitions.each_index do |i|
|
261
|
+
mount_partition(partitions[i], mount_points[i], mount_prefix)
|
244
262
|
|
245
|
-
|
246
|
-
|
247
|
-
|
263
|
+
# By the way - update the labels so we don't have to muck again with partitions
|
264
|
+
# this will be done for every mount, but shouldn't hurt too much.
|
265
|
+
@guestfs.set_e2label(partitions[i], Zlib.crc32(mount_points[i]).to_s(16))
|
248
266
|
end
|
249
267
|
end
|
250
268
|
|
269
|
+
def mountable_partitions(device)
|
270
|
+
partitions = @guestfs.list_partitions.reject { |i| !(i =~ /^#{device}/) }
|
271
|
+
|
272
|
+
# we need to remove extended partition
|
273
|
+
# extended partition is always #3
|
274
|
+
partitions.delete_at(3) if partitions.size > 4
|
275
|
+
|
276
|
+
partitions
|
277
|
+
end
|
278
|
+
|
279
|
+
def umount_partition(part)
|
280
|
+
@log.trace "Unmounting partition #{part}..."
|
281
|
+
@guestfs.umount(part)
|
282
|
+
@log.trace "Partition unmounted."
|
283
|
+
end
|
284
|
+
|
285
|
+
# Unmounts partitions in reverse order.
|
286
|
+
#
|
287
|
+
def umount_partitions(device)
|
288
|
+
partitions = @guestfs.list_partitions.reject { |i| !(i =~ /^#{device}/) }
|
289
|
+
|
290
|
+
@log.trace "Unmounting partitions..."
|
291
|
+
partitions.reverse.each { |part| umount_partition(part) }
|
292
|
+
@log.trace "All partitions unmounted."
|
293
|
+
end
|
294
|
+
|
251
295
|
def sh(cmd, options = {})
|
252
296
|
arch = options[:arch] || `uname -m`.chomp.strip
|
253
297
|
|