system-builder 0.0.18 → 0.0.19
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/.gitignore +2 -0
- data/Rakefile +2 -24
- data/bin/box +129 -21
- data/lib/system_builder/version.rb +3 -0
- data/lib/system_builder.rb +1 -1
- data/system-builder.gemspec +15 -32
- metadata +28 -52
data/.gitignore
ADDED
data/Rakefile
CHANGED
@@ -1,26 +1,4 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem 'hoe', '>= 2.1.0'
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/system_builder'
|
6
|
-
|
7
|
-
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
Hoe.plugin :cucumberfeatures
|
10
|
-
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
Hoe.spec 'system-builder' do
|
14
|
-
self.version = SystemBuilder::VERSION
|
15
|
-
self.developer 'Alban Peignier', 'alban@tryphon.eu'
|
16
|
-
self.rubyforge_name = self.name # TODO this is default value
|
17
|
-
self.url = "http://projects.tryphon.eu/system-builder"
|
18
|
-
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'newgem/tasks'
|
22
1
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
2
|
|
24
|
-
|
25
|
-
|
26
|
-
# task :default => [:spec, :features]
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
data/bin/box
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
+
@options = {}
|
5
6
|
OptionParser.new do |opts|
|
6
7
|
opts.banner = <<-BANNER.gsub(/^ /,'')
|
7
8
|
Box : manage box
|
@@ -12,41 +13,148 @@ OptionParser.new do |opts|
|
|
12
13
|
BANNER
|
13
14
|
opts.separator ""
|
14
15
|
opts.on("-r", "--root=disk|iso", String,
|
15
|
-
"The support used to boot") { |arg| @root = arg }
|
16
|
+
"The support used to boot") { |arg| @options[:root] = arg }
|
17
|
+
opts.on("-t", "--target=<disk device>", String,
|
18
|
+
"The target to clone an image") { |arg| @options[:target] = arg }
|
19
|
+
opts.on("-i", "--image=<disk image>", String,
|
20
|
+
"The box image to be cloned") { |arg| @options[:image] = arg }
|
21
|
+
opts.on("-h", "--host=<host>", String,
|
22
|
+
"The host to be upgraded") { |arg| @options[:host] = arg }
|
16
23
|
opts.on("-h", "--help",
|
17
24
|
"Show this help message.") { puts opts; exit }
|
18
25
|
opts.parse!(ARGV)
|
19
26
|
|
20
27
|
@command = ARGV.shift
|
21
|
-
|
22
|
-
unless @command
|
28
|
+
|
29
|
+
unless %w{boot clone upgrade}.include? @command
|
23
30
|
puts opts; exit
|
24
31
|
end
|
25
32
|
end
|
26
33
|
|
27
|
-
|
34
|
+
class BoxCommand
|
28
35
|
|
29
|
-
|
36
|
+
def boot(options = {})
|
37
|
+
qemu_options = []
|
30
38
|
|
31
|
-
|
32
|
-
when "iso"
|
33
|
-
qemu_options << "-cdrom dist/iso"
|
34
|
-
qemu_options << "--boot order=d"
|
35
|
-
else
|
36
|
-
qemu_disks << "dist/disk"
|
37
|
-
end
|
39
|
+
qemu_disks = []
|
38
40
|
|
39
|
-
|
41
|
+
case options[:root]
|
42
|
+
when "iso"
|
43
|
+
qemu_options << "-cdrom dist/iso"
|
44
|
+
qemu_options << "--boot order=d"
|
45
|
+
else
|
46
|
+
qemu_disks << "dist/disk"
|
47
|
+
end
|
40
48
|
|
41
|
-
qemu_disks.
|
42
|
-
|
43
|
-
|
49
|
+
qemu_disks.push *Dir["dist/storage*"]
|
50
|
+
|
51
|
+
qemu_disks.each_with_index do |disk, index|
|
52
|
+
qemu_options << "-drive file=#{disk},if=ide,index=#{index+1},media=disk"
|
53
|
+
end
|
54
|
+
|
55
|
+
qemu_options << "-net nic -net vde,sock=/var/run/vde2/tap0.ctl"
|
56
|
+
|
57
|
+
ENV['QEMU_AUDIO_DRV']='alsa'
|
58
|
+
|
59
|
+
qemu_command = "qemu -enable-kvm -m 512m -soundhw ac97 #{qemu_options.join(' ')}"
|
60
|
+
|
61
|
+
puts "Run #{qemu_command}"
|
62
|
+
system qemu_command
|
63
|
+
end
|
64
|
+
|
65
|
+
def clone(options = {})
|
66
|
+
target = (options[:target] or "/dev/sdb")
|
67
|
+
disk_image = (options[:image] or "dist/disk")
|
68
|
+
partition = "#{target}1"
|
69
|
+
|
70
|
+
if disk_image =~ /([a-z]+box)-(\d+-\d+)/
|
71
|
+
# like pigebox-20101014-1155
|
72
|
+
name = $1
|
73
|
+
release = $2
|
74
|
+
disk_image = "dist/#{name}-#{release}.disk"
|
75
|
+
sh "ssh dev.dbx.tryphon.priv cat /var/lib/buildbot/dist/#{name}/#{name}-#{release}.disk.gz | gunzip -c > #{disk_image}" unless File.exist?(disk_image)
|
76
|
+
end
|
77
|
+
|
78
|
+
raise "Can't find #{disk_image}" unless File.exists?(disk_image)
|
79
|
+
|
80
|
+
if partition_mount = mounts.assoc(partition)
|
81
|
+
partition_mount_point = partition_mount[1]
|
82
|
+
else
|
83
|
+
partition_mount_point = "/media/boot"
|
84
|
+
#sudo "mkdir #{partition_mount_point}" unless File.exist? partition_mount_point
|
85
|
+
#sudo "mount #{partition} #{partition_mount_point}"
|
86
|
+
end
|
87
|
+
|
88
|
+
#unless File.exists? "#{partition_mount_point}/config.pp"
|
89
|
+
$stdout.write "Confirm you want install box image (#{disk_image}) in #{target} [y/N] :"
|
90
|
+
$stdout.flush
|
91
|
+
exit 1 unless $stdin.read(1).downcase == 'y'
|
92
|
+
#end
|
93
|
+
|
94
|
+
if mounts.assoc(partition)
|
95
|
+
puts "Unmount #{target}"
|
96
|
+
exit 1 unless system "sudo umount #{partition}"
|
97
|
+
end
|
44
98
|
|
45
|
-
|
99
|
+
puts "Install filesystem"
|
100
|
+
sh "echo ',,L,*' | sudo /sbin/sfdisk -f -uS #{target}"
|
101
|
+
sudo "mke2fs -j -L boot #{partition}"
|
46
102
|
|
47
|
-
|
103
|
+
puts "Copy files"
|
104
|
+
sudo "mount #{partition} #{partition_mount_point}"
|
105
|
+
mount_disk_image_fs(disk_image) do |dir|
|
106
|
+
sudo "rsync -av #{dir}/ #{partition_mount_point}/"
|
107
|
+
end
|
108
|
+
sudo "umount #{partition_mount_point}"
|
48
109
|
|
49
|
-
|
110
|
+
puts "Install extlinux"
|
111
|
+
sudo "mount #{partition} build/root/boot"
|
112
|
+
sudo "mount proc build/root/proc -t proc"
|
113
|
+
sudo "mount -o bind /dev build/root/dev"
|
114
|
+
|
115
|
+
begin
|
116
|
+
sudo "chroot build/root /usr/bin/extlinux --install /boot"
|
117
|
+
ensure
|
118
|
+
sudo "umount build/root/proc"
|
119
|
+
sudo "umount build/root/boot"
|
120
|
+
sudo "umount build/root/dev"
|
121
|
+
end
|
122
|
+
|
123
|
+
sudo "dd if=build/root/usr/lib/syslinux/mbr.bin of=#{target}"
|
124
|
+
end
|
125
|
+
|
126
|
+
def sh(command)
|
127
|
+
puts "Run #{command}"
|
128
|
+
raise "command failed: '#{command}'" unless system command
|
129
|
+
end
|
130
|
+
|
131
|
+
def sudo(command)
|
132
|
+
sh "sudo #{command}"
|
133
|
+
end
|
134
|
+
|
135
|
+
def mounts
|
136
|
+
IO.readlines("/proc/mounts").map { |m| m.scan(/\S+/) }
|
137
|
+
end
|
138
|
+
|
139
|
+
def mount_disk_image_fs(disk_image)
|
140
|
+
mount_dir = "/tmp/mount_boot_fs"
|
141
|
+
sh "mkdir -p /tmp/mount_boot_fs"
|
142
|
+
begin
|
143
|
+
sudo "mount -o loop,offset=#{64*512} #{disk_image} #{mount_dir}"
|
144
|
+
yield mount_dir
|
145
|
+
ensure
|
146
|
+
sudo "umount #{mount_dir}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def upgrade(options = {})
|
151
|
+
host = options[:host]
|
152
|
+
raise "No specified host for upgrade, use --host" unless host
|
153
|
+
|
154
|
+
sh "scp dist/latest.yml dist/upgrade.tar #{host}:/tmp/"
|
155
|
+
sh "ssh #{host} box-upgrade /tmp/upgrade.tar /tmp/latest.yml"
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
50
159
|
|
51
|
-
|
52
|
-
system qemu_command
|
160
|
+
BoxCommand.new.send(@command, @options)
|
data/lib/system_builder.rb
CHANGED
@@ -2,7 +2,6 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module SystemBuilder
|
5
|
-
VERSION = '0.0.18'
|
6
5
|
|
7
6
|
@@configurations = {}
|
8
7
|
|
@@ -18,6 +17,7 @@ module SystemBuilder
|
|
18
17
|
|
19
18
|
end
|
20
19
|
|
20
|
+
require 'system_builder/version'
|
21
21
|
require 'system_builder/core_ext'
|
22
22
|
require 'system_builder/disk_image'
|
23
23
|
require 'system_builder/iso_image'
|
data/system-builder.gemspec
CHANGED
@@ -1,38 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "system_builder/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
+
s.name = "system-builder"
|
7
|
+
s.version = SystemBuilder::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Alban Peignier", "Florent Peyraud"]
|
10
|
+
s.email = ["alban@tryphon.eu", "florent@tryphon.eu"]
|
11
|
+
s.homepage = "http://projects.tryphon.eu/system-builder"
|
12
|
+
s.summary = %q{Build bootable images}
|
13
|
+
s.description = %q{}
|
6
14
|
|
7
|
-
s.
|
8
|
-
s.authors = ["Alban Peignier"]
|
9
|
-
s.date = %q{2010-05-09}
|
10
|
-
s.default_executable = %q{system-builder}
|
11
|
-
s.description = %q{FIX (describe your package)}
|
12
|
-
s.email = ["alban@tryphon.eu"]
|
13
|
-
s.executables = ["system-builder"]
|
14
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
|
15
|
-
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "bin/system-builder", "examples/Rakefile", "examples/config.rb", "examples/manifests/classes/test.pp", "examples/manifests/site.pp", "features/development.feature", "features/step_definitions/common_steps.rb", "features/support/common.rb", "features/support/env.rb", "features/support/matchers.rb", "lib/system_builder.rb", "lib/system_builder/boot.rb", "lib/system_builder/cli.rb", "lib/system_builder/configurator.rb", "lib/system_builder/core_ext.rb", "lib/system_builder/disk_image.rb", "lib/system_builder/disk_squashfs_image.rb", "lib/system_builder/init_ram_fs_configurator.rb", "lib/system_builder/iso_image.rb", "lib/system_builder/iso_squashfs_image.rb", "lib/system_builder/live_image.rb", "lib/system_builder/mount_boot.sh", "lib/system_builder/task.rb", "script/console", "script/destroy", "script/generate", "spec/spec.opts", "spec/spec_helper.rb", "spec/system_builder/boot_spec.rb", "spec/system_builder/cli_spec.rb", "system-builder.gemspec", "tasks/rspec.rake"]
|
16
|
-
s.homepage = %q{http://projects.tryphon.eu/system-builder}
|
17
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
s.rubyforge_project = %q{system-builder}
|
20
|
-
s.rubygems_version = %q{1.3.6}
|
21
|
-
s.summary = %q{FIX (describe your package)}
|
22
|
-
|
23
|
-
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version = 3
|
15
|
+
s.rubyforge_project = "system-builder"
|
26
16
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
32
|
-
s.add_dependency(%q<hoe>, [">= 2.6.0"])
|
33
|
-
end
|
34
|
-
else
|
35
|
-
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
36
|
-
s.add_dependency(%q<hoe>, [">= 2.6.0"])
|
37
|
-
end
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
38
21
|
end
|
metadata
CHANGED
@@ -1,68 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: system-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 57
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 19
|
10
|
+
version: 0.0.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alban Peignier
|
14
|
+
- Florent Peyraud
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
name: rubyforge
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 4
|
34
|
-
version: 2.0.4
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: hoe
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 19
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 6
|
49
|
-
- 2
|
50
|
-
version: 2.6.2
|
51
|
-
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
description: FIX (describe your package)
|
19
|
+
date: 2011-05-09 00:00:00 Z
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: ""
|
54
23
|
email:
|
55
24
|
- alban@tryphon.eu
|
25
|
+
- florent@tryphon.eu
|
56
26
|
executables:
|
57
27
|
- box
|
58
28
|
- system-builder
|
59
29
|
extensions: []
|
60
30
|
|
61
|
-
extra_rdoc_files:
|
62
|
-
|
63
|
-
- Manifest.txt
|
64
|
-
- PostInstall.txt
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
65
33
|
files:
|
34
|
+
- .gitignore
|
66
35
|
- History.txt
|
67
36
|
- Manifest.txt
|
68
37
|
- PostInstall.txt
|
@@ -95,6 +64,7 @@ files:
|
|
95
64
|
- lib/system_builder/live_image.rb
|
96
65
|
- lib/system_builder/mount_boot.sh
|
97
66
|
- lib/system_builder/task.rb
|
67
|
+
- lib/system_builder/version.rb
|
98
68
|
- script/console
|
99
69
|
- script/destroy
|
100
70
|
- script/generate
|
@@ -104,14 +74,12 @@ files:
|
|
104
74
|
- spec/system_builder/cli_spec.rb
|
105
75
|
- system-builder.gemspec
|
106
76
|
- tasks/rspec.rake
|
107
|
-
has_rdoc: true
|
108
77
|
homepage: http://projects.tryphon.eu/system-builder
|
109
78
|
licenses: []
|
110
79
|
|
111
80
|
post_install_message:
|
112
|
-
rdoc_options:
|
113
|
-
|
114
|
-
- README.rdoc
|
81
|
+
rdoc_options: []
|
82
|
+
|
115
83
|
require_paths:
|
116
84
|
- lib
|
117
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -135,9 +103,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
103
|
requirements: []
|
136
104
|
|
137
105
|
rubyforge_project: system-builder
|
138
|
-
rubygems_version: 1.
|
106
|
+
rubygems_version: 1.7.2
|
139
107
|
signing_key:
|
140
108
|
specification_version: 3
|
141
|
-
summary:
|
142
|
-
test_files:
|
143
|
-
|
109
|
+
summary: Build bootable images
|
110
|
+
test_files:
|
111
|
+
- features/development.feature
|
112
|
+
- features/step_definitions/common_steps.rb
|
113
|
+
- features/support/common.rb
|
114
|
+
- features/support/env.rb
|
115
|
+
- features/support/matchers.rb
|
116
|
+
- spec/spec.opts
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- spec/system_builder/boot_spec.rb
|
119
|
+
- spec/system_builder/cli_spec.rb
|