1
from VMBuilder.util import run_cmd
7
def __init__(self, builder):
10
def install(self, destdir):
11
self.destdir = destdir
13
logging.debug("debootstrapping")
16
logging.debug("Installing fstab")
19
logging.debug("Installing kernel")
22
logging.debug("Installing grub")
25
logging.debug("Creating device.map")
26
self.install_device_map()
28
logging.debug("Installing menu.list")
29
self.install_menu_lst()
31
logging.debug("Unmounting volatile lrm filesystems")
32
self.unmount_volatile()
34
def unmount_volatile(self):
35
for mntpnt in glob.glob('%s/lib/modules/*/volatile' % self.destdir):
36
logging.debug("Unmounting %s" % mntpnt)
37
run_cmd('umount', mntpnt)
39
def install_menu_lst(self):
40
run_cmd('chroot', self.destdir, 'update-grub', '-y')
41
self.mangle_grub_menu_lst()
42
run_cmd('chroot', self.destdir, 'update-grub')
44
def mangle_grub_menu_lst(self):
45
bootdev = 'UUID=%s' % (VMBuilder.bootpart().uuid, )
46
run_cmd('sed', '-ie', 's/\/dev\/hda1/%s/g' % bootdev, '%s/boot/grub/menu.lst' % self.destdir)
48
def install_fstab(self):
49
fp = open('%s/etc/fstab' % self.destdir, 'w')
50
fp.write(self.fstab())
53
def install_device_map(self):
54
fp = open('%s/boot/grub/device.map' % self.destdir, 'a')
55
fp.write(self.device_map())
59
raise NotImplemented('Suite needs to implement device_map method')
61
def debootstrap(self):
62
cmd = ['debootstrap', self.builder.options.suite, self.destdir]
63
if hasattr(self.builder.options, 'mirror'):
64
cmd += [self.builder.options.mirror]
67
def install_kernel(self):
68
kernel_name = self.kernel_name()
69
run_cmd('chroot', self.destdir, 'apt-get', '--force-yes', '-y', 'install', kernel_name, 'grub')
71
def install_grub(self):
72
run_cmd('chroot', self.destdir, 'apt-get', '--force-yes', '-y', 'install', 'grub')
73
run_cmd('cp', '-a', '%s%s' % (self.destdir, self.grubdir()), '%s/boot/grub' % self.destdir)
76
if self.builder.options.arch == 'amd64':
77
return '/usr/lib/grub/x86_64-pc'
79
return '/usr/lib/grub/i386-pc'
81
def kernel_name(self):
82
raise NotImplemented('Suite needs to implement kernel_name method')
85
retval = '''# /etc/fstab: static file system information.
87
# <file system> <mount point> <type> <options> <dump> <pass>
88
proc /proc proc defaults 0 0
90
parts = self.builder.get_ordered_partitions()
92
retval += "UUID=%-40s %15s %7s %15s %d %d\n" % (part.uuid, part.mntpnt, part.fstab_fstype(), part.fstab_options(), 0, 0)