Package VMBuilder :: Package plugins :: Package ubuntu :: Module edgy
[frames] | no frames]

Source Code for Module VMBuilder.plugins.ubuntu.edgy

 1  # 
 2  #    Uncomplicated VM Builder 
 3  #    Copyright (C) 2007-2009 Canonical Ltd. 
 4  #     
 5  #    See AUTHORS for list of contributors 
 6  # 
 7  #    This program is free software: you can redistribute it and/or modify 
 8  #    it under the terms of the GNU General Public License version 3, as 
 9  #    published by the Free Software Foundation. 
10  # 
11  #    This program is distributed in the hope that it will be useful, 
12  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  #    GNU General Public License for more details. 
15  # 
16  #    You should have received a copy of the GNU General Public License 
17  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
18  # 
19  import shutil 
20  import os 
21  import VMBuilder.disk as disk 
22  from   VMBuilder.util import run_cmd 
23  from   VMBuilder.plugins.ubuntu.dapper import Dapper 
24   
25 -class Edgy(Dapper):
26 valid_flavours = { 'i386' : ['386', '686', '686-smp', 'generic', 'k7', 'k7-smp', 'server', 'server-bigiron'], 27 'amd64' : ['amd64-generic', 'amd64-k8', 'amd64-k8-smp', 'amd64-server', 'amd64-xeon', 'server']} 28 default_flavour = { 'i386' : 'server', 'amd64' : 'server' } 29 disk_prefix = 'sd' 30
31 - def mangle_grub_menu_lst(self, disks):
32 bootdev = disk.bootpart(disks) 33 run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s\\2/g' % bootdev.fs.uuid, 34 '%s/boot/grub/menu.lst' % self.context.chroot_dir) 35 run_cmd('sed', '-ie', 's/^# groot.*/# groot %s/g' % bootdev.get_grub_id(), 36 '%s/boot/grub/menu.lst' % self.context.chroot_dir) 37 run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % 38 self.context.chroot_dir)
39
40 - def fstab(self):
41 retval = '''# /etc/fstab: static file system information. 42 # 43 # <file system> <mount point> <type> <options> <dump> <pass> 44 proc /proc proc defaults 0 0 45 ''' 46 parts = disk.get_ordered_partitions(self.context.disks) 47 for part in parts: 48 retval += "UUID=%-40s %15s %7s %15s %d %d\n" % (part.fs.uuid, part.fs.mntpnt, part.fs.fstab_fstype(), part.fs.fstab_options(), 0, 0) 49 return retval
50
51 - def copy_settings(self):
52 if os.path.exists('/etc/default/locale'): 53 self.copy_to_target('/etc/default/locale', '/etc/default/locale') 54 csdir = '%s/etc/console-setup' % self.destdir 55 have_cs = os.path.isdir(csdir) 56 if have_cs: 57 shutil.rmtree(csdir) 58 self.copy_to_target('/etc/console-setup', '/etc/console-setup') 59 self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup') 60 self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'tzdata') 61 self.run_in_target('locale-gen', 'en_US') 62 if self.context.lang: 63 self.run_in_target('locale-gen', self.context.lang) 64 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.context.lang }) 65 self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales') 66 if have_cs: 67 self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'console-setup')
68
69 - def set_timezone(self):
70 timezone = self.context.get_setting('timezone') 71 if timezone: 72 self.install_from_template('/etc/timezone', 'timezone', { 'timezone' : timezone }) 73 self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'tzdata')
74
76 super(Edgy, self).prevent_daemons_starting() 77 initctl = '%s/sbin/initctl' % (self.context.chroot_dir,) 78 os.rename(initctl, '%s.REAL' % (initctl,)) 79 self.install_from_template('/sbin/initctl', 'initctl-stub', mode=0755)
80
82 super(Edgy, self).unprevent_daemons_starting() 83 initctl = '%s/sbin/initctl' % (self.context.chroot_dir,) 84 os.rename('%s.REAL' % (initctl,), initctl)
85