boxgrinder-ubuntu-plugin 0.1

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Sergio Rubio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # boxgrinder-ubuntu-plugin
2
+
3
+ This Boxgrinder OS plugin adds Ubuntu support to boxgrinder.
4
+
5
+ The plugin requires Ubuntu-specific tools to create the appliance so it will only work with Ubuntu as the host OS.
6
+
7
+ Boxgrinder can be easily installed in Ubuntu via rubygems.
8
+
9
+ ## Pre-requisites
10
+
11
+ **Install libguestfs binary packages**
12
+
13
+ Install libguestfs deps first:
14
+
15
+ $ sudo apt-get install libsys-virt-perl ubuntu-vm-builder libvirt-bin \
16
+ rubygems libvirt-dev libxslt-dev libxml2-dev gcc make \
17
+ ruby-dev qemu-kvm augeas-lenses btrfs-tools cryptsetup \
18
+ diff jfsutils libaugeas0 libhivex0 libntfs10 ntfsprogs \
19
+ reiserfsprogs scrub xfsprogs zerofree zfs-fuse
20
+
21
+
22
+ Grab libguestfs binary packages from:
23
+
24
+ http://libguestfs.org/download/binaries/
25
+
26
+ For **Ubuntu Natty**, download them and install them issuing the following commands:
27
+
28
+ $ wget -r -l1 -H -t1 -nd -N -np -A.deb http://libguestfs.org/download/binaries/ubuntu1104-packages/
29
+
30
+ Remove not required packages:
31
+
32
+ $ rm *ocaml*deb libguestfs-doc* libguestfs0-dbg*
33
+
34
+ Install libguestfs packages:
35
+
36
+ $ dpkg -i guestmount* libguestfs* python-guestfs*
37
+
38
+ **Install guestfs rubygem**
39
+
40
+ There are no binary packages for the libguestfs ruby bindings ATM. Grab the gem from here:
41
+
42
+ $ wget http://rbel.frameos.org/tmp/guestfs-1.14.2.gem
43
+
44
+ $ sudo gem install --no-ri --no-rdoc guestfs-1.14.2.gem
45
+
46
+
47
+ **Install Boxgrinder and the Ubuntu plugin**
48
+
49
+ $ sudo gem install --no-ri --no-rdoc boxgrinder-build boxgrinder-ubuntu-plugin
50
+
51
+ ## Usage
52
+
53
+ boxgrinder-build -l boxgrinder-ubuntu-plugin ubuntu.appl
54
+
55
+ There's a sample appliance definition at:
56
+
57
+ https://github.com/rubiojr/boxgrinder-appliances/tree/master/ubuntu-natty
58
+
59
+ ## Copyright
60
+
61
+ Copyright (c) 2011 Sergio Rubio. See LICENSE.txt for
62
+ further details.
63
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
9
+ gem.version = '0.1'
10
+ gem.name = "boxgrinder-ubuntu-plugin"
11
+ gem.homepage = "http://github.com/rubiojr/boxgrinder-ubuntu-plugin"
12
+ gem.license = "MIT"
13
+ gem.summary = %Q{Ubuntu OS boxgrinder plugin}
14
+ gem.description = %Q{Ubuntu OS boxgrinder plugin}
15
+ gem.email = "rubiojr@frameos.org"
16
+ gem.authors = ["Sergio Rubio"]
17
+ # dependencies defined in Gemfile
18
+ end
19
+ Jeweler::RubygemsDotOrgTasks.new
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ task :default => :build
29
+
30
+ require 'rdoc/task'
31
+ Rake::RDocTask.new do |rdoc|
32
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
+
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "boxgrinder-ubuntu-plugin #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
@@ -0,0 +1,90 @@
1
+ require 'boxgrinder-core/models/appliance-config'
2
+ require 'boxgrinder-build/plugins/base-plugin'
3
+ require 'boxgrinder-core/errors'
4
+
5
+ module BoxGrinder
6
+ class UbuntuPlugin < BasePlugin
7
+ def after_init
8
+ register_deliverable(
9
+ :disk => "#{@appliance_config.name}-sda.raw"
10
+ )
11
+ register_supported_os('ubuntu', ["natty"])
12
+ end
13
+
14
+ def execute(appliance_definition_file)
15
+ execute_vmbuilder
16
+ end
17
+
18
+ def validate
19
+ set_default_config_value('format', 'raw')
20
+ end
21
+
22
+ def create_files_map
23
+ if @appliance_config.files and not @appliance_config.files.empty?
24
+ @log.debug "Creting temporal file list #{@dir.tmp + '/filelist'}"
25
+ file_lies = File.open(@dir.tmp + "/filelist", 'w') do |fl|
26
+ @appliance_config.files.each do |dir, files|
27
+ files.each do |f|
28
+ fl.puts "#{f} #{dir}/#{f}"
29
+ end
30
+ end
31
+ end
32
+ true
33
+ else
34
+ false
35
+ end
36
+ end
37
+
38
+ def create_partitions_file
39
+ pcount = 1
40
+ plist = File.open(@dir.tmp + "/partitions", 'w') do |pl|
41
+ @log.debug "Creting partition map #{@dir.tmp + '/partitions'}"
42
+ @appliance_config.hardware.partitions.each do |mpoint, values|
43
+ pl.puts "#{mpoint} #{values['size'].to_i * 1024}"
44
+ end
45
+ end
46
+ @dir.tmp + "/partitions"
47
+ end
48
+
49
+ def execute_vmbuilder
50
+ arch = @appliance_config.hardware.arch
51
+ arch = 'amd64' if arch == 'x86_64'
52
+ pkgs = @appliance_config.packages.map { |p| "--addpkg #{p}" }
53
+ extra_args = []
54
+ if create_files_map
55
+ extra_args << "--copy #{@dir.tmp + '/filelist'}"
56
+ end
57
+ extra_args << '--quiet'
58
+ extra_args << "--part #{create_partitions_file}"
59
+ extra_args << "--rootpass #{@appliance_config.os.password}"
60
+ begin
61
+ @exec_helper.execute "vmbuilder kvm ubuntu #{extra_args.join(' ')} --suite #{@appliance_config.os.version} #{pkgs.join(" ")} --arch #{arch} -t '#{@dir.tmp}' -d '#{@dir.base}/out' --mem #{@appliance_config.hardware.memory} --cpus #{@appliance_config.hardware.cpus}"
62
+ #
63
+ # Move resulting disk image to the plugin output dir
64
+ #
65
+ dsource = Dir["#{@dir.base}/out/*.qcow2"].first
66
+ ddest = "#{@dir.base}/tmp/#{@appliance_config.name}-sda.raw"
67
+ @log.debug "Moving qcow2 disk image from #{dsource} to #{ddest}"
68
+ # Convert to RAW
69
+ @exec_helper.execute "qemu-img convert #{dsource} -O raw #{ddest}"
70
+ rescue => e
71
+ ensure
72
+ #
73
+ # Cleanup
74
+ #
75
+ # Set env var BOXGRINDER_DEBUG_NOCLEAN if you down't want to clean
76
+ # tmp/out dirs (useful for debugging)
77
+ #
78
+ if not ENV["BOXGRINDER_DEBUG_NOCLEAN"]
79
+ @log.debug "Cleaning tmp/work directories"
80
+ FileUtils.rm_rf "#{@dir.tmp}" if File.exist? "#{@dir.tmp}"
81
+ FileUtils.rm_rf "#{@dir.base}/out" if File.exist? "#{@dir.base}/out"
82
+ end
83
+ end
84
+ end
85
+
86
+ end
87
+ end
88
+
89
+ plugin :class => BoxGrinder::UbuntuPlugin, :type => :os, :name => :ubuntu, :full_name => "Ubuntu", :versions => ["lucid", "maveric", "natty", "oneiric"]
90
+
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boxgrinder-ubuntu-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sergio Rubio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Ubuntu OS boxgrinder plugin
15
+ email: rubiojr@frameos.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ files:
22
+ - .document
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/boxgrinder-ubuntu-plugin.rb
27
+ homepage: http://github.com/rubiojr/boxgrinder-ubuntu-plugin
28
+ licenses:
29
+ - MIT
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.8.10
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Ubuntu OS boxgrinder plugin
52
+ test_files: []