boxgrinder-build 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ v0.9.2
2
+
3
+ * [BGBUILD-148] Add support for building CentOS/RHEL images on Fedora
4
+ * [BGBUILD-204] Fedora 15 appliance networking start on boot failed
5
+ * [BGBUILD-208] Kickstart files not working with 0.9.1
6
+ * [BGBUILD-205] Error while converting to EC2 when guest OS is CentOS/RHEL 5
7
+ * [BGBUILD-213] CloudSigma support
8
+ * [BGBUILD-209] Wrong /etc/mtab on Fedora 15 appliances causes errors
9
+ * [BGBUILD-203] Vmware vmdk disk size is wrong when installing via kickstart files
10
+ * [BGBUILD-207] Guestfs dies on Fedora 15 with 'KVM not supported for this target' message
11
+ * [BGBUILD-83] Enable libguestfs log callback to redirect guestfs output to logger
12
+
1
13
  v0.9.1
2
14
 
3
15
  * [BGBUILD-188] Use libuestfs instead mounting partitions manually for EC2 appliances
@@ -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.1"
5
+ s.version = "0.9.2"
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-04-27}
9
+ s.date = %q{2011-05-17}
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/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"]
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/helpers/qemu.wrapper", "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/helpers/qemu.wrapper", "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"]
@@ -22,67 +22,6 @@ require 'guestfs'
22
22
  require 'rbconfig'
23
23
  require 'resolv'
24
24
 
25
- module BoxGrinder
26
- class SilencerProxy
27
- def initialize(o, destination)
28
- @o = o
29
- @destination = destination
30
- end
31
-
32
- def method_missing(m, *args, &block)
33
- begin
34
- redirect_streams(@destination) do
35
- @o.send(m, *args, &block)
36
- end
37
- rescue
38
- raise
39
- end
40
- end
41
-
42
- def respond_to?(m)
43
- @o.respond_to?(m)
44
- end
45
-
46
- def redirect_streams(destination)
47
- old_stdout_stream = STDOUT.dup
48
- old_stderr_stream = STDERR.dup
49
-
50
- STDOUT.reopen(destination)
51
- STDERR.reopen(destination)
52
-
53
- STDOUT.sync = true
54
- STDERR.sync = true
55
-
56
- yield
57
- ensure
58
- STDOUT.reopen(old_stdout_stream)
59
- STDERR.reopen(old_stderr_stream)
60
- end
61
- end
62
- end
63
-
64
- module Guestfs
65
- class Guestfs
66
- alias_method :sh_original, :sh
67
-
68
- def sh(command)
69
- begin
70
- output = sh_original(command)
71
- puts output
72
- rescue => e
73
- puts "Error occurred while executing above command, aborting."
74
- raise e
75
- end
76
-
77
- output
78
- end
79
-
80
- def redirect(destination)
81
- BoxGrinder::SilencerProxy.new(self, destination)
82
- end
83
- end
84
- end
85
-
86
25
  module BoxGrinder
87
26
  class GuestFSHelper
88
27
  def initialize(disks, appliance_config, config, options = {})
@@ -103,7 +42,7 @@ module BoxGrinder
103
42
  ec2 = false
104
43
  end
105
44
 
106
- if `cat /proc/cpuinfo | grep flags | grep vmx | wc -l`.chomp.strip.to_i > 0 and !ec2
45
+ if `egrep '^flags.*(vmx|svm)' /proc/cpuinfo | wc -l`.chomp.strip.to_i > 0 and !ec2
107
46
  @log.trace "HW acceleration available."
108
47
  return true
109
48
  end
@@ -113,67 +52,96 @@ module BoxGrinder
113
52
  false
114
53
  end
115
54
 
116
- def customize(options = {})
117
- read_pipe, write_pipe = IO.pipe
55
+ # https://issues.jboss.org/browse/BGBUILD-83
56
+ def log_callback
57
+ log = Proc.new do |event, event_handle, buf, array|
58
+ buf.chomp!
59
+
60
+ if event == 64
61
+ @log.trace "GFS: #{buf}"
62
+ else
63
+ @log.debug "GFS: #{buf}"
64
+ end
65
+ end
66
+
67
+ # Guestfs::EVENT_APPLIANCE => 16
68
+ # Guestfs::EVENT_LIBRARY => 32
69
+ # Guestfs::EVENT_TRACE => 64
70
+
71
+ # Referencing int instead of constants make it easier to test
72
+ @guestfs.set_event_callback(log, 16 | 32 | 64)
73
+
74
+ yield if block_given?
75
+ end
76
+
77
+ # If log callback aren't available we will fail to this, which sucks...
78
+ def log_hack
79
+ read_stderr, write_stderr = IO.pipe
118
80
 
119
81
  fork do
120
- read_pipe.each do |o|
121
- if o.chomp.strip.eql?("<EOF>")
122
- exit
123
- else
124
- @log.trace "GFS: #{o.chomp.strip}"
125
- end
82
+ write_stderr.close
83
+
84
+ read_stderr.each do |l|
85
+ @log.trace "GFS: #{l.chomp.strip}"
126
86
  end
87
+
88
+ read_stderr.close
127
89
  end
128
90
 
129
- helper = execute(write_pipe, options)
91
+ old_stderr = STDERR.clone
130
92
 
131
- yield @guestfs, helper
93
+ STDERR.reopen(write_stderr)
94
+ STDERR.sync = true
132
95
 
133
- clean_close
96
+ begin
97
+ # Execute all tasks
98
+ yield if block_given?
99
+ ensure
100
+ STDERR.reopen(old_stderr)
101
+ end
134
102
 
135
- write_pipe.puts "<EOF>"
103
+ write_stderr.close
104
+ read_stderr.close
136
105
 
137
106
  Process.wait
138
107
  end
139
108
 
140
- def execute(pipe = nil, options = {})
141
- options = {
142
- :ide_disk => false,
143
- :mount_prefix => '',
144
- :automount => true,
145
- :load_selinux_policy => true
146
- }.merge(options)
147
-
109
+ def initialize_guestfs(options = {})
148
110
  @log.debug "Preparing guestfs..."
149
-
150
111
  @log.trace "Setting libguestfs temporary directory to '#{@config.dir.tmp}'..."
151
112
 
152
113
  FileUtils.mkdir_p(@config.dir.tmp)
153
-
154
114
  ENV['TMPDIR'] = @config.dir.tmp
155
115
 
156
- @guestfs = pipe.nil? ? Guestfs::create : Guestfs::create.redirect(pipe)
116
+ @guestfs = Guestfs::create
157
117
 
158
- # https://bugzilla.redhat.com/show_bug.cgi?id=502058
159
- @guestfs.set_append("noapic")
118
+ if @guestfs.respond_to?(:set_event_callback)
119
+ @log.trace "We have event callbacks available!"
120
+ log_callback { prepare_guestfs(options) { yield } }
121
+ else
122
+ @log.trace "We don't have event callbacks available :( Falling back to proxy."
123
+ log_hack { prepare_guestfs(options) { yield } }
124
+ end
125
+ end
160
126
 
127
+ def prepare_guestfs(options = {})
161
128
  @log.trace "Setting debug + trace..."
162
129
  @guestfs.set_verbose(1)
163
130
  @guestfs.set_trace(1)
164
131
 
132
+ # https://bugzilla.redhat.com/show_bug.cgi?id=502058
133
+ @guestfs.set_append("noapic")
134
+
165
135
  @log.trace "Enabling SElinux support in guestfs..."
166
136
  @guestfs.set_selinux(1)
167
137
 
168
138
  unless hw_virtualization_available?
169
139
  # This wrapper is required especially for EC2 where running qemu-kvm crashes libguestfs
170
- qemu_wrapper = (RbConfig::CONFIG['host_cpu'].eql?('x86_64') ? "/usr/bin/qemu-system-x86_64" : "/usr/bin/qemu")
140
+ qemu_wrapper = "#{File.dirname(__FILE__)}/qemu.wrapper"
171
141
 
172
- if File.exists?(qemu_wrapper)
173
- @log.trace "Setting QEMU wrapper to #{qemu_wrapper}..."
174
- @guestfs.set_qemu(qemu_wrapper)
175
- @log.trace "QEMU wrapper set."
176
- end
142
+ @log.trace "Setting QEMU wrapper to #{qemu_wrapper}..."
143
+ @guestfs.set_qemu(qemu_wrapper)
144
+ @log.trace "QEMU wrapper set."
177
145
  end
178
146
 
179
147
  @disks.each do |disk|
@@ -191,6 +159,27 @@ module BoxGrinder
191
159
  @guestfs.set_network(1)
192
160
  end
193
161
 
162
+ yield
163
+ end
164
+
165
+ def customize(options = {})
166
+ initialize_guestfs(options) do
167
+ helper = execute(options)
168
+
169
+ yield @guestfs, helper
170
+
171
+ clean_close
172
+ end
173
+ end
174
+
175
+ def execute(options = {})
176
+ options = {
177
+ :ide_disk => false,
178
+ :mount_prefix => '',
179
+ :automount => true,
180
+ :load_selinux_policy => true
181
+ }.merge(options)
182
+
194
183
  @log.debug "Launching guestfs..."
195
184
  @guestfs.launch
196
185
 
@@ -245,6 +234,9 @@ module BoxGrinder
245
234
  def mount_partition(part, mount_point, mount_prefix = '')
246
235
  @log.trace "Mounting #{part} partition to #{mount_point}..."
247
236
  @guestfs.mount_options("", part, "#{mount_prefix}#{mount_point}")
237
+ # By the way - update the labels so we don't have to muck again with partitions
238
+ # this will be done for every mount, but shouldn't hurt too much.
239
+ @guestfs.set_e2label(part, Zlib.crc32(mount_point).to_s(16))
248
240
  @log.trace "Partition mounted."
249
241
  end
250
242
 
@@ -254,16 +246,8 @@ module BoxGrinder
254
246
  @log.trace "Mounting partitions..."
255
247
 
256
248
  partitions = mountable_partitions(device)
257
-
258
249
  mount_points = LinuxHelper.new(:log => @log).partition_mount_points(@appliance_config.hardware.partitions)
259
-
260
- partitions.each_index do |i|
261
- mount_partition(partitions[i], mount_points[i], mount_prefix)
262
-
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))
266
- end
250
+ partitions.each_index { |i| mount_partition(partitions[i], mount_points[i], mount_prefix) }
267
251
  end
268
252
 
269
253
  def mountable_partitions(device)
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+
3
+ if [ "`echo "$@" | grep "kvm" | wc -l`" -eq "1" ]; then
4
+ args=( "$@" "-no-kvm" )
5
+ else
6
+ args=( "$@" )
7
+ fi
8
+
9
+ if [ "`uname -r | grep x86_64 | wc -l`" -eq "1" ]; then
10
+ bin=/usr/bin/qemu-system-x86_64
11
+ else
12
+ bin=/usr/bin/qemu
13
+ fi
14
+
15
+ exec $bin "${args[@]}"
@@ -116,7 +116,8 @@ module BoxGrinder
116
116
  while !f.eof?
117
117
  f.seek(part * @step, File::SEEK_SET)
118
118
 
119
- data = compress(f.read(@step))
119
+ data = f.read(@step)
120
+ data = compress(data) unless is_cloudsigma?
120
121
  upload_chunk(data, part)
121
122
 
122
123
  part += 1
@@ -148,10 +149,12 @@ module BoxGrinder
148
149
  begin
149
150
  @log.info "Uploading part #{part+1}..."
150
151
 
152
+ headers = {:content_type => "application/octet-stream"}
153
+ headers['Content-Encoding'] = 'gzip' unless is_cloudsigma?
154
+
151
155
  RestClient.post url,
152
156
  data,
153
- :content_type => "application/octet-stream",
154
- 'Content-Encoding' => 'gzip'
157
+ headers
155
158
 
156
159
  @log.info "Part #{part+1} uploaded."
157
160
  rescue => e
@@ -41,13 +41,14 @@ module BoxGrinder
41
41
 
42
42
  def read_kickstart(file)
43
43
  appliance_config = ApplianceConfig.new
44
-
45
44
  appliance_config.name = File.basename(file, '.ks')
46
45
 
47
46
  name = nil
48
47
  version = nil
49
48
 
50
- File.read(file).each do |line|
49
+ kickstart = File.read(file)
50
+
51
+ kickstart.each do |line|
51
52
  n = line.scan(/^# bg_os_name: (.*)/).flatten.first
52
53
  v = line.scan(/^# bg_os_version: (.*)/).flatten.first
53
54
 
@@ -61,6 +62,29 @@ module BoxGrinder
61
62
  appliance_config.os.name = name
62
63
  appliance_config.os.version = version
63
64
 
65
+ partitions = {}
66
+
67
+ kickstart.each do |line|
68
+ # Parse also the partition scheme
69
+ if line =~ /^part ([\/\w]+)/
70
+ root = $1
71
+ partitions[root] = {}
72
+
73
+ # size
74
+ partitions[root]['size'] = $1.to_f / 1024 if line =~ /--size[=\s]*(\d+)/
75
+ # fs type
76
+ partitions[root]['type'] = $1 if line =~ /--fstype[=\s]*(\w+)/
77
+ # fs options
78
+ partitions[root]['options'] = $1 if line =~ /--fsoptions[=\s]*([,\w]+)/
79
+
80
+ raise "Partition size not specified for #{root} partition in #{file}" if partitions[root]['size'].nil?
81
+ end
82
+ end
83
+
84
+ raise "No partitions specified in your kickstart file #{file}" if partitions.empty?
85
+
86
+ appliance_config.hardware.partitions = partitions
87
+
64
88
  appliance_config
65
89
  end
66
90
 
@@ -69,10 +93,9 @@ module BoxGrinder
69
93
  kickstart_file = appliance_definition_file
70
94
  else
71
95
  kickstart_file = Kickstart.new(@config, @appliance_config, repos, @dir, :log => @log).create
96
+ RPMDependencyValidator.new(@config, @appliance_config, @dir, kickstart_file, @options).resolve_packages
72
97
  end
73
98
 
74
- RPMDependencyValidator.new(@config, @appliance_config, @dir, kickstart_file, @options).resolve_packages
75
-
76
99
  @log.info "Building #{@appliance_config.name} appliance..."
77
100
 
78
101
  execute_appliance_creator(kickstart_file)
@@ -94,6 +117,13 @@ module BoxGrinder
94
117
  set_motd(guestfs)
95
118
  install_repos(guestfs)
96
119
 
120
+ if @appliance_config.os.name == 'fedora' and @appliance_config.os.version == '15'
121
+ disable_biosdevname(guestfs)
122
+ change_runlevel(guestfs)
123
+ disable_netfs(guestfs)
124
+ link_mtab(guestfs)
125
+ end
126
+
97
127
  guestfs.sh("chkconfig firstboot off") if guestfs.exists('/etc/init.d/firstboot') != 0
98
128
 
99
129
  @log.info "Executing post operations after build..."
@@ -110,6 +140,9 @@ module BoxGrinder
110
140
  yield guestfs, guestfs_helper if block_given?
111
141
 
112
142
  @log.info "Post operations executed."
143
+
144
+ # https://issues.jboss.org/browse/BGBUILD-148
145
+ recreate_rpm_database(guestfs, guestfs_helper) if @config.os.name != @appliance_config.os.name or @config.os.version != @appliance_config.os.version
113
146
  end
114
147
 
115
148
  @log.info "Base image for #{@appliance_config.name} appliance was built successfully."
@@ -124,6 +157,49 @@ module BoxGrinder
124
157
  end
125
158
  end
126
159
 
160
+ # https://issues.jboss.org/browse/BGBUILD-204
161
+ def disable_biosdevname(guestfs)
162
+ @log.debug "Disabling biosdevname for Fedora 15..."
163
+ guestfs.sh('sed -i "s/kernel\(.*\)/kernel\1 biosdevname=0/g" /boot/grub/grub.conf')
164
+ @log.debug "Biosdevname disabled."
165
+ end
166
+
167
+ # https://issues.jboss.org/browse/BGBUILD-204
168
+ def change_runlevel(guestfs)
169
+ @log.debug "Changing runlevel to multi-user non-graphical..."
170
+ guestfs.rm("/etc/systemd/system/default.target")
171
+ guestfs.ln_sf("/lib/systemd/system/multi-user.target", "/etc/systemd/system/default.target")
172
+ @log.debug "Runlevel changed."
173
+ end
174
+
175
+ # https://issues.jboss.org/browse/BGBUILD-204
176
+ def disable_netfs(guestfs)
177
+ @log.debug "Disabling network filesystem mounting..."
178
+ guestfs.sh("chkconfig netfs off")
179
+ @log.debug "Network filesystem mounting disabled."
180
+ end
181
+
182
+ # https://issues.jboss.org/browse/BGBUILD-209
183
+ def link_mtab(guestfs)
184
+ @log.debug "Linking /etc/mtab to /proc/self/mounts for Fedora 15..."
185
+ guestfs.ln_sf("/proc/self/mounts", "/etc/mtab")
186
+ @log.debug "/etc/mtab linked."
187
+ end
188
+
189
+ # https://issues.jboss.org/browse/BGBUILD-148
190
+ def recreate_rpm_database(guestfs, guestfs_helper)
191
+ @log.debug "Recreating RPM database..."
192
+
193
+ guestfs.download("/var/lib/rpm/Packages", "#{@dir.tmp}/Packages")
194
+ @exec_helper.execute("/usr/lib/rpm/rpmdb_dump #{@dir.tmp}/Packages > #{@dir.tmp}/Packages.dump")
195
+ guestfs.upload("#{@dir.tmp}/Packages.dump", "/tmp/Packages.dump")
196
+ guestfs.sh("rm -rf /var/lib/rpm/*")
197
+ guestfs_helper.sh("cd /var/lib/rpm/ && cat /tmp/Packages.dump | /usr/lib/rpm/rpmdb_load Packages")
198
+ guestfs_helper.sh("rpm --rebuilddb")
199
+
200
+ @log.debug "RPM database recreated..."
201
+ end
202
+
127
203
  def cleanup_after_appliance_creator(pid)
128
204
  @log.debug "Sending TERM signal to process '#{pid}'..."
129
205
  Process.kill("TERM", pid)