system-builder 0.0.7 → 0.0.9
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/Manifest.txt +3 -0
- data/lib/system_builder/configurator.rb +10 -3
- data/lib/system_builder/disk_squashfs_image.rb +7 -42
- data/lib/system_builder/init_ram_fs_configurator.rb +63 -0
- data/lib/system_builder/iso_squashfs_image.rb +53 -0
- data/lib/system_builder/mount_boot.sh +41 -0
- data/lib/system_builder.rb +3 -1
- data/system-builder.gemspec +3 -3
- metadata +6 -3
data/Manifest.txt
CHANGED
@@ -20,8 +20,11 @@ lib/system_builder/configurator.rb
|
|
20
20
|
lib/system_builder/core_ext.rb
|
21
21
|
lib/system_builder/disk_image.rb
|
22
22
|
lib/system_builder/disk_squashfs_image.rb
|
23
|
+
lib/system_builder/init_ram_fs_configurator.rb
|
23
24
|
lib/system_builder/iso_image.rb
|
25
|
+
lib/system_builder/iso_squashfs_image.rb
|
24
26
|
lib/system_builder/live_image.rb
|
27
|
+
lib/system_builder/mount_boot.sh
|
25
28
|
lib/system_builder/task.rb
|
26
29
|
script/console
|
27
30
|
script/destroy
|
@@ -14,10 +14,11 @@ module SystemBuilder
|
|
14
14
|
|
15
15
|
class PuppetConfigurator
|
16
16
|
|
17
|
-
attr_reader :manifest
|
17
|
+
attr_reader :manifest, :config
|
18
18
|
|
19
|
-
def initialize(
|
20
|
-
@manifest = manifest
|
19
|
+
def initialize(options = {})
|
20
|
+
@manifest = (options.delete(:manifest) or ".")
|
21
|
+
@config = options.dup
|
21
22
|
end
|
22
23
|
|
23
24
|
def puppet_directories
|
@@ -42,6 +43,12 @@ module SystemBuilder
|
|
42
43
|
|
43
44
|
chroot.image.rsync context_dir, puppet_directories, :exclude => "*~", :delete => true
|
44
45
|
|
46
|
+
chroot.image.open("#{context_dir}/manifests/config.pp") do |f|
|
47
|
+
config.each do |key, value|
|
48
|
+
f.puts "$#{key}=\"#{value}\""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
45
52
|
chroot.image.mkdir "#{context_dir}/config"
|
46
53
|
chroot.image.open("#{context_dir}/config/fileserver.conf") do |f|
|
47
54
|
%w{files plugins}.each do |mount_point|
|
@@ -11,46 +11,7 @@ class SystemBuilder::DiskSquashfsImage
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
|
-
boot.configurators << SystemBuilder::
|
15
|
-
puts "* install initramfs-tools"
|
16
|
-
chroot.apt_install %w{initramfs-tools syslinux}
|
17
|
-
|
18
|
-
script = "/usr/share/initramfs-tools/scripts/local-top/mount_boot"
|
19
|
-
unless chroot.image.exists?(script)
|
20
|
-
chroot.image.open(script) do |f|
|
21
|
-
f.puts <<EOF
|
22
|
-
#!/bin/sh -x
|
23
|
-
case ${1:-} in
|
24
|
-
prereqs) echo ""; exit 0;;
|
25
|
-
esac
|
26
|
-
modprobe loop
|
27
|
-
mkdir /boot
|
28
|
-
mount -r -t ext3 LABEL=#{fs_label} /boot
|
29
|
-
exit 0
|
30
|
-
EOF
|
31
|
-
end
|
32
|
-
chroot.sudo "chmod +x #{script}"
|
33
|
-
|
34
|
-
chroot.image.mkdir "/usr/share/initramfs-tools/scripts/local-bottom"
|
35
|
-
chroot.image.open("/usr/share/initramfs-tools/scripts/local-bottom/umount_boot") do |f|
|
36
|
-
f.puts <<EOF
|
37
|
-
#!/bin/sh -x
|
38
|
-
case ${1:-} in
|
39
|
-
prereqs) echo ""; exit 0;;
|
40
|
-
esac
|
41
|
-
mount -n -o move /boot /root/boot
|
42
|
-
exit 0
|
43
|
-
EOF
|
44
|
-
end
|
45
|
-
chroot.sudo "chmod +x /usr/share/initramfs-tools/scripts/local-bottom/umount_boot"
|
46
|
-
|
47
|
-
chroot.image.open("/etc/initramfs-tools/modules") do |f|
|
48
|
-
f.puts "squashfs"
|
49
|
-
end
|
50
|
-
chroot.sudo "/usr/sbin/update-initramfs -u"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
14
|
+
boot.configurators << SystemBuilder::InitRamFsConfigurator.new
|
54
15
|
boot.create
|
55
16
|
|
56
17
|
file_creation = (not File.exists?(file))
|
@@ -101,8 +62,11 @@ EOF
|
|
101
62
|
end
|
102
63
|
|
103
64
|
def compress_root_fs
|
65
|
+
FileUtils::sudo "mksquashfs #{boot.root}/ build/filesystem.squashfs -noappend -e /boot"
|
66
|
+
FileUtils::sudo "chown #{ENV['USER']}:#{ENV['USER']} build/filesystem.squashfs && chmod +r build/filesystem.squashfs"
|
67
|
+
|
104
68
|
mount_boot_fs do |mount_dir|
|
105
|
-
FileUtils::sudo "
|
69
|
+
FileUtils::sudo "cp build/filesystem.squashfs #{mount_dir}/filesystem.squashfs"
|
106
70
|
end
|
107
71
|
FileUtils.touch file
|
108
72
|
end
|
@@ -127,7 +91,7 @@ EOF
|
|
127
91
|
f.puts "LABEL linux"
|
128
92
|
f.puts "SAY Now booting #{version} from syslinux ..."
|
129
93
|
f.puts "KERNEL /vmlinuz"
|
130
|
-
f.puts "APPEND ro initrd=/initrd.img boot=local root=/boot/filesystem.squashfs rootflags=loop rootfstype=squashfs
|
94
|
+
f.puts "APPEND ro initrd=/initrd.img boot=local root=/boot/filesystem.squashfs rootflags=loop rootfstype=squashfs"
|
131
95
|
end
|
132
96
|
end
|
133
97
|
end
|
@@ -162,4 +126,5 @@ EOF
|
|
162
126
|
linux_partition_info = `/sbin/sfdisk -l #{file}`.scan(%r{#{file}.*Linux}).first
|
163
127
|
linux_partition_info.split[5].to_i
|
164
128
|
end
|
129
|
+
|
165
130
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class SystemBuilder::InitRamFsConfigurator
|
2
|
+
|
3
|
+
def configure(chroot)
|
4
|
+
puts "* install initramfs-tools"
|
5
|
+
chroot.apt_install %w{initramfs-tools syslinux}
|
6
|
+
|
7
|
+
install_script(chroot, "local-top/mount_boot") do |f|
|
8
|
+
f.puts "modprobe loop"
|
9
|
+
f.puts "/lib/initrd/mount_boot"
|
10
|
+
# f.puts "PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1"
|
11
|
+
end
|
12
|
+
|
13
|
+
install_script(chroot, "local-bottom/move_boot") do |f|
|
14
|
+
f.puts "mount -n -o move /boot /root/boot"
|
15
|
+
end
|
16
|
+
|
17
|
+
install_hook(chroot, "mount_boot") do |f|
|
18
|
+
f.puts "mkdir -p $DESTDIR/lib/initrd/"
|
19
|
+
f.puts "install -m 755 /usr/local/share/initramfs-tools/mount_boot $DESTDIR/lib/initrd/"
|
20
|
+
end
|
21
|
+
|
22
|
+
chroot.image.open("/etc/initramfs-tools/modules") do |f|
|
23
|
+
f.puts "squashfs"
|
24
|
+
end
|
25
|
+
|
26
|
+
chroot.image.mkdir "/usr/local/share/initramfs-tools"
|
27
|
+
chroot.image.open("/usr/local/share/initramfs-tools/mount_boot") do |f|
|
28
|
+
f.puts File.read("#{File.dirname(__FILE__)}/mount_boot.sh")
|
29
|
+
end
|
30
|
+
|
31
|
+
chroot.sudo "/usr/sbin/update-initramfs -u"
|
32
|
+
end
|
33
|
+
|
34
|
+
@@script_header = <<EOF
|
35
|
+
#!/bin/sh -x
|
36
|
+
if [ "$1" == "prereqs" ]; then
|
37
|
+
echo ""; exit 0;
|
38
|
+
fi
|
39
|
+
EOF
|
40
|
+
|
41
|
+
def install_script(chroot, name, &block)
|
42
|
+
install_file(chroot, :script, name, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def install_hook(chroot, name, &block)
|
46
|
+
install_file(chroot, :hook, name) do |f|
|
47
|
+
f.puts ". /usr/share/initramfs-tools/hook-functions"
|
48
|
+
yield f
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_file(chroot, type, name, &block)
|
53
|
+
file = "/usr/share/initramfs-tools/#{type}s/#{name}"
|
54
|
+
chroot.image.mkdir File.dirname(file)
|
55
|
+
chroot.image.open(file) do |f|
|
56
|
+
f.puts @@script_header
|
57
|
+
yield f
|
58
|
+
f.puts "exit 0"
|
59
|
+
end
|
60
|
+
chroot.sudo "chmod +x #{file}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
class SystemBuilder::IsoSquashfsImage
|
4
|
+
|
5
|
+
attr_accessor :boot
|
6
|
+
attr_reader :file
|
7
|
+
|
8
|
+
def initialize(file)
|
9
|
+
@file = file
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
boot.configurators << SystemBuilder::InitRamFsConfigurator.new
|
14
|
+
boot.create
|
15
|
+
|
16
|
+
compress_root_fs
|
17
|
+
install_isolinux_files
|
18
|
+
make_iso_fs
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def compress_root_fs
|
24
|
+
FileUtils::sudo "mksquashfs #{boot.root}/ build/filesystem.squashfs -noappend -e /boot"
|
25
|
+
end
|
26
|
+
|
27
|
+
def install_isolinux_files(options = {})
|
28
|
+
version = (options[:version] or Time.now.strftime("%Y%m%d%H%M"))
|
29
|
+
|
30
|
+
boot.image do |image|
|
31
|
+
image.mkdir "/boot/isolinux"
|
32
|
+
|
33
|
+
image.open("/boot/isolinux/isolinux.cfg") do |f|
|
34
|
+
f.puts "default linux"
|
35
|
+
f.puts "label linux"
|
36
|
+
f.puts "kernel /vmlinuz"
|
37
|
+
f.puts "append ro initrd=/initrd.img boot=local root=/boot/filesystem.squashfs rootflags=loop rootfstype=squashfs"
|
38
|
+
end
|
39
|
+
|
40
|
+
image.install "/boot/isolinux", "/usr/lib/syslinux/isolinux.bin"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def readlink_boot_file(boot_file)
|
45
|
+
File.basename(%x{readlink #{boot.root}/#{boot_file}}.strip)
|
46
|
+
end
|
47
|
+
|
48
|
+
def make_iso_fs
|
49
|
+
FileUtils::sudo "mkisofs -quiet -R -o #{file} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -graft-points vmlinuz=#{boot.root}/boot/#{readlink_boot_file('vmlinuz')} initrd.img=#{boot.root}/boot/#{readlink_boot_file('initrd.img')} filesystem.squashfs=build/filesystem.squashfs #{boot.root}/boot"
|
50
|
+
FileUtils::sudo "chown $USER #{file}"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/bin/sh -x
|
2
|
+
|
3
|
+
get_fstype() {
|
4
|
+
# udev >=146-1 no longer provides vol_id:
|
5
|
+
if [ -x /lib/udev/vol_id ]
|
6
|
+
then
|
7
|
+
/lib/udev/vol_id -t ${1} 2>/dev/null
|
8
|
+
else
|
9
|
+
eval $(blkid -o udev "${1}")
|
10
|
+
if [ -n "$ID_FS_TYPE" ]
|
11
|
+
then
|
12
|
+
echo "${ID_FS_TYPE}"
|
13
|
+
fi
|
14
|
+
fi
|
15
|
+
}
|
16
|
+
|
17
|
+
list_devices() {
|
18
|
+
# list partitions first
|
19
|
+
(ls /dev/hd*[1-9] /dev/sd*[1-9] ; ls /dev/hd[a-z] /dev/sd[a-z]) 2> /dev/null
|
20
|
+
}
|
21
|
+
|
22
|
+
mkdir /boot
|
23
|
+
|
24
|
+
for device in `list_devices`; do
|
25
|
+
fs_type=`get_fstype ${device}`
|
26
|
+
echo "check if $device ($fs_type) is the boot image"
|
27
|
+
|
28
|
+
case $fs_type in
|
29
|
+
ext3|iso9660)
|
30
|
+
mount -r -t $fs_type $device /boot
|
31
|
+
if [ -f "/boot/config.pp" ]; then
|
32
|
+
exit 0
|
33
|
+
else
|
34
|
+
umount /boot
|
35
|
+
fi
|
36
|
+
;;
|
37
|
+
esac
|
38
|
+
done
|
39
|
+
|
40
|
+
echo "no image found"
|
41
|
+
exit 1
|
data/lib/system_builder.rb
CHANGED
@@ -2,7 +2,7 @@ $:.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.
|
5
|
+
VERSION = '0.0.9'
|
6
6
|
|
7
7
|
@@configurations = {}
|
8
8
|
|
@@ -22,6 +22,8 @@ require 'system_builder/core_ext'
|
|
22
22
|
require 'system_builder/disk_image'
|
23
23
|
require 'system_builder/iso_image'
|
24
24
|
require 'system_builder/live_image'
|
25
|
+
require 'system_builder/init_ram_fs_configurator'
|
25
26
|
require 'system_builder/disk_squashfs_image'
|
27
|
+
require 'system_builder/iso_squashfs_image'
|
26
28
|
require 'system_builder/boot'
|
27
29
|
require 'system_builder/configurator'
|
data/system-builder.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{system-builder}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Alban Peignier"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-05-09}
|
10
10
|
s.default_executable = %q{system-builder}
|
11
11
|
s.description = %q{FIX (describe your package)}
|
12
12
|
s.email = ["alban@tryphon.eu"]
|
13
13
|
s.executables = ["system-builder"]
|
14
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/iso_image.rb", "lib/system_builder/live_image.rb", "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"]
|
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
16
|
s.homepage = %q{http://projects.tryphon.eu/system-builder}
|
17
17
|
s.rdoc_options = ["--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alban Peignier
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-09 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -79,8 +79,11 @@ files:
|
|
79
79
|
- lib/system_builder/core_ext.rb
|
80
80
|
- lib/system_builder/disk_image.rb
|
81
81
|
- lib/system_builder/disk_squashfs_image.rb
|
82
|
+
- lib/system_builder/init_ram_fs_configurator.rb
|
82
83
|
- lib/system_builder/iso_image.rb
|
84
|
+
- lib/system_builder/iso_squashfs_image.rb
|
83
85
|
- lib/system_builder/live_image.rb
|
86
|
+
- lib/system_builder/mount_boot.sh
|
84
87
|
- lib/system_builder/task.rb
|
85
88
|
- script/console
|
86
89
|
- script/destroy
|