system-builder 0.0.3 → 0.0.4

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/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.0.4 2009-10-10
2
+
3
+ * Replace grub by syslinux
4
+ * Disable invoke-rc.d during configuration
5
+
1
6
  === 0.0.2 2009-09-02
2
7
 
3
8
  * 1 major enhancement:
@@ -26,8 +26,10 @@ class SystemBuilder::DebianBoot
26
26
  apt_configurator,
27
27
  kernel_configurator,
28
28
  fstab_configurator,
29
- timezone_configurator ]
30
- @cleaners = [ apt_cleaner ]
29
+ timezone_configurator,
30
+ policyrc_configurator
31
+ ]
32
+ @cleaners = [ apt_cleaner, policyrc_cleaner ]
31
33
  end
32
34
 
33
35
  def create
@@ -44,6 +46,7 @@ class SystemBuilder::DebianBoot
44
46
  end
45
47
 
46
48
  def configure
49
+ puts "* #{configurators.size} configurators to run :"
47
50
  unless @configurators.empty?
48
51
  chroot do |chroot|
49
52
  @configurators.each do |configurator|
@@ -65,15 +68,17 @@ class SystemBuilder::DebianBoot
65
68
 
66
69
  def kernel_configurator
67
70
  SystemBuilder::ProcConfigurator.new do |chroot|
71
+ puts "* install kernel"
68
72
  chroot.image.open("/etc/kernel-img.conf") do |f|
69
73
  f.puts "do_initrd = yes"
70
74
  end
71
- chroot.apt_install %w{linux-image-2.6-686 grub}
75
+ chroot.apt_install %w{linux-image-2.6-686}
72
76
  end
73
77
  end
74
78
 
75
79
  def fstab_configurator
76
80
  SystemBuilder::ProcConfigurator.new do |chroot|
81
+ puts "* create fstab"
77
82
  chroot.image.open("/etc/fstab") do |f|
78
83
  %w{/tmp /var/run /var/log /var/lock /var/tmp}.each do |directory|
79
84
  f.puts "tmpfs #{directory} tmpfs defaults,noatime 0 0"
@@ -84,6 +89,7 @@ class SystemBuilder::DebianBoot
84
89
 
85
90
  def timezone_configurator
86
91
  SystemBuilder::ProcConfigurator.new do |chroot|
92
+ puts "* define timezone"
87
93
  # Use same timezone than build machine
88
94
  chroot.image.install "/etc/", "/etc/timezone", "/etc/localtime"
89
95
  end
@@ -92,14 +98,35 @@ class SystemBuilder::DebianBoot
92
98
  def apt_configurator
93
99
  # TODO see if this step is really needed
94
100
  SystemBuilder::ProcConfigurator.new do |chroot|
101
+ puts "* install apt keys"
95
102
  chroot.image.install "/etc/apt", "/etc/apt/trusted.gpg"
96
103
  chroot.sudo "apt-get update"
97
104
  end
98
105
  end
99
106
 
107
+ def policyrc_configurator
108
+ SystemBuilder::ProcConfigurator.new do |chroot|
109
+ puts "* disable rc services"
110
+ chroot.image.open("/usr/sbin/policy-rc.d") do |f|
111
+ f.puts "exit 101"
112
+ end
113
+ chroot.sh "chmod +x /usr/sbin/policy-rc.d"
114
+ end
115
+ end
116
+
100
117
  def apt_cleaner
101
118
  Proc.new do |chroot|
119
+ puts "* clean apt caches"
102
120
  chroot.sudo "apt-get clean"
121
+ puts "* autoremove packages"
122
+ chroot.sudo "apt-get autoremove --yes"
123
+ end
124
+ end
125
+
126
+ def policyrc_cleaner
127
+ Proc.new do |chroot|
128
+ puts "* enable rc services"
129
+ chroot.sh "rm /usr/sbin/policy-rc.d"
103
130
  end
104
131
  end
105
132
 
@@ -112,10 +139,6 @@ class SystemBuilder::DebianBoot
112
139
  end
113
140
  end
114
141
 
115
- def configure(&block)
116
- @configurators << SystemBuilder::ProcConfigurator.new(block)
117
- end
118
-
119
142
  def debbootstrap_options
120
143
  {
121
144
  :arch => architecture,
@@ -21,6 +21,8 @@ module SystemBuilder
21
21
  end
22
22
 
23
23
  def configure(chroot)
24
+ puts "* run puppet configuration"
25
+
24
26
  chroot.apt_install :puppet
25
27
  chroot.image.open("/etc/default/puppet") do |f|
26
28
  f.puts "START=no"
@@ -21,10 +21,10 @@ class SystemBuilder::DiskImage
21
21
  format_root_fs
22
22
  end
23
23
 
24
- install_grub_files :stage_files => %w{e2fs_stage1_5 stage?}
24
+ install_extlinux_files
25
25
 
26
26
  sync_root_fs
27
- install_grub if file_creation
27
+ install_extlinux
28
28
 
29
29
  self
30
30
  end
@@ -34,7 +34,8 @@ class SystemBuilder::DiskImage
34
34
  end
35
35
 
36
36
  def create_partition_table
37
- FileUtils::sh "echo '63,' | /sbin/sfdisk --no-reread -uS -H16 -S63 #{file}"
37
+ # Partition must be bootable for syslinux
38
+ FileUtils::sh "echo '63,,L,*' | /sbin/sfdisk --no-reread -uS -H16 -S63 #{file}"
38
39
  end
39
40
 
40
41
  def format_root_fs
@@ -47,31 +48,64 @@ class SystemBuilder::DiskImage
47
48
  end
48
49
  end
49
50
 
50
- def sync_root_fs
51
+ def mount_root_fs(&block)
52
+ # TODO use a smarter mount_dir
51
53
  mount_dir = "/tmp/mount_root_fs"
52
54
  FileUtils::mkdir_p mount_dir
53
-
55
+
54
56
  begin
55
57
  FileUtils::sudo "mount -o loop,offset=#{fs_offset} #{file} #{mount_dir}"
56
- FileUtils::sudo "rsync -av --delete #{boot.root}/ #{mount_dir}"
58
+ yield mount_dir
57
59
  ensure
58
60
  FileUtils::sudo "umount #{mount_dir}"
59
61
  end
62
+ end
60
63
 
64
+ def sync_root_fs
65
+ mount_root_fs do |mount_dir|
66
+ FileUtils::sudo "rsync -a --delete #{boot.root}/ #{mount_dir}"
67
+ end
61
68
  FileUtils.touch file
62
69
  end
63
70
 
71
+ def install_extlinux_files(options = {})
72
+ root = (options[:root] or "LABEL=#{fs_label}")
73
+ version = (options[:version] or Time.now.strftime("%Y%m%d%H%M"))
74
+
75
+ boot.image do |image|
76
+ image.mkdir "/boot/extlinux"
77
+
78
+ boot.image.open("/boot/extlinux/extlinux.conf") do |f|
79
+ f.puts "DEFAULT linux"
80
+ f.puts "LABEL linux"
81
+ f.puts "SAY Now booting #{version} from syslinux ..."
82
+ f.puts "KERNEL /vmlinuz"
83
+ f.puts "APPEND ro root=#{root} initrd=/initrd.img"
84
+ end
85
+ end
86
+ end
87
+
64
88
  def install_grub_files(options = {})
65
89
  stage_files = Array(options[:stage_files]).flatten
66
90
 
67
91
  boot.image do |image|
68
92
  image.mkdir "/boot/grub"
69
93
 
70
- install_grub_menu options
94
+ install_grub_menu options
71
95
  image.install "boot/grub", stage_files.collect { |f| '/usr/lib/grub/**/' + f }
72
96
  end
73
97
  end
74
98
 
99
+ def install_extlinux
100
+ # TODO install extlinux.sys only when needed
101
+ mount_root_fs do |mount_dir|
102
+ FileUtils::sudo "extlinux --install -H16 -S63 #{mount_dir}/boot/extlinux"
103
+ end
104
+ # TODO install mbr only when needed
105
+ # install MBR
106
+ FileUtils::sh "dd if=/usr/lib/syslinux/mbr.bin of=#{file} conv=notrunc"
107
+ end
108
+
75
109
  def install_grub
76
110
  IO.popen("sudo grub --device-map=/dev/null","w") { |grub|
77
111
  grub.puts "device (hd0) #{file}"
@@ -104,7 +138,7 @@ class SystemBuilder::DiskImage
104
138
 
105
139
  def fs_block_size
106
140
  linux_partition_info = `/sbin/sfdisk -l #{file}`.scan(%r{#{file}.*Linux}).first
107
- linux_partition_info.split[4].to_i
141
+ linux_partition_info.split[5].to_i
108
142
  end
109
143
 
110
144
  def fs_offset
@@ -38,9 +38,9 @@ class SystemBuilder::Task < Rake::TaskLib
38
38
  required_packages << "sudo"
39
39
  required_packages << "debootstrap"
40
40
  required_packages << "rsync"
41
- # installing grub isn't a good idea
42
- # required_packages << "grub"
43
-
41
+ required_packages << "extlinux"
42
+ required_packages << "syslinux-common"
43
+
44
44
  FileUtils.sudo "apt-get install #{required_packages.join(' ')}"
45
45
  end
46
46
  end
@@ -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.3'
5
+ VERSION = '0.0.4'
6
6
 
7
7
  @@configurations = {}
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: system-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alban Peignier
@@ -9,9 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-02 00:00:00 +01:00
12
+ date: 2010-01-10 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubyforge
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: gemcutter
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ version:
15
35
  - !ruby/object:Gem::Dependency
16
36
  name: hoe
17
37
  type: :development
@@ -20,7 +40,7 @@ dependencies:
20
40
  requirements:
21
41
  - - ">="
22
42
  - !ruby/object:Gem::Version
23
- version: 2.3.3
43
+ version: 2.5.0
24
44
  version:
25
45
  description: FIX (describe your package)
26
46
  email: