Sha256: 6220baa06a18a4e90231b0fbe5ca8bee37b0ec5ec137bbdb8c51d76c1013b698

Contents?: true

Size: 1.67 KB

Versions: 14

Compression:

Stored size: 1.67 KB

Contents

class SystemBuilder::InitRamFsConfigurator 

  def configure(chroot)
    puts "* install initramfs-tools"
    chroot.apt_install %w{initramfs-tools syslinux}

    install_script(chroot, "local-top/mount_boot") do |f|
      f.puts "modprobe loop"
      f.puts "/lib/initrd/mount_boot"
      # f.puts "PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1"
    end

    install_script(chroot, "local-bottom/move_boot") do |f|
      f.puts "mount -n -o move /boot /root/boot"
    end

    install_hook(chroot, "mount_boot") do |f|
      f.puts "mkdir -p $DESTDIR/lib/initrd/"
      f.puts "install -m 755 /usr/local/share/initramfs-tools/mount_boot $DESTDIR/lib/initrd/"
    end

    chroot.image.open("/etc/initramfs-tools/modules") do |f|
      f.puts "squashfs"
    end

    chroot.image.mkdir "/usr/local/share/initramfs-tools"
    chroot.image.open("/usr/local/share/initramfs-tools/mount_boot") do |f|
      f.puts File.read("#{File.dirname(__FILE__)}/mount_boot.sh")
    end

    chroot.sudo "/usr/sbin/update-initramfs -u"
  end

  @@script_header = <<EOF
#!/bin/sh -x
if [ "$1" == "prereqs" ]; then
  echo ""; exit 0;
fi
EOF

  def install_script(chroot, name, &block)
    install_file(chroot, :script, name, &block)
  end

  def install_hook(chroot, name, &block)
    install_file(chroot, :hook, name) do |f|
      f.puts ". /usr/share/initramfs-tools/hook-functions"
      yield f
    end
  end

  def install_file(chroot, type, name, &block)
    file = "/usr/share/initramfs-tools/#{type}s/#{name}"
    chroot.image.mkdir File.dirname(file)
    chroot.image.open(file) do |f|
      f.puts @@script_header
      yield f
      f.puts "exit 0"
    end
    chroot.sudo "chmod +x #{file}"
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
system-builder-0.0.23 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.22 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.21 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.20 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.19 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.18 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.17 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.16 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.15 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.14 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.13 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.12 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.10 lib/system_builder/init_ram_fs_configurator.rb
system-builder-0.0.9 lib/system_builder/init_ram_fs_configurator.rb