Merge lp:~kees/vmbuilder/use-ext4 into lp:vmbuilder/trunk

Proposed by Kees Cook
Status: Merged
Merged at revision: not available
Proposed branch: lp:~kees/vmbuilder/use-ext4
Merge into: lp:vmbuilder/trunk
Diff against target: 156 lines (+55/-13)
5 files modified
AUTHORS (+1/-0)
VMBuilder/disk.py (+17/-12)
VMBuilder/plugins/ubuntu/distro.py (+4/-1)
VMBuilder/plugins/ubuntu/karmic.py (+7/-0)
VMBuilder/plugins/ubuntu/lucid.py (+26/-0)
To merge this branch: bzr merge lp:~kees/vmbuilder/use-ext4
Reviewer Review Type Date Requested Status
VMBuilder Pending
Review via email: mp+15969@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Kees Cook (kees) wrote :

Switches default fs to ext4 for karmic and later.

lp:~kees/vmbuilder/use-ext4 updated
360. By Kees Cook

add Lucid guest support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2008-09-29 12:28:03 +0000
3+++ AUTHORS 2010-01-04 19:54:14 +0000
4@@ -2,3 +2,4 @@
5
6 Other contributors:
7 * Nicolas Barcet <nicolas.barcet@ubuntu.com>
8+ * Kees Cook <kees.cook@canonical.com>
9
10=== modified file 'VMBuilder/disk.py'
11--- VMBuilder/disk.py 2009-10-23 07:17:47 +0000
12+++ VMBuilder/disk.py 2010-01-04 19:54:14 +0000
13@@ -32,6 +32,7 @@
14 TYPE_EXT3 = 1
15 TYPE_XFS = 2
16 TYPE_SWAP = 3
17+TYPE_EXT4 = 4
18
19 class Disk(object):
20 def __init__(self, vm, size='5G', preallocated=False, filename=None):
21@@ -217,7 +218,7 @@
22 @rtype: string
23 @return: the filesystem type of the partition suitable for passing to parted
24 """
25- return { TYPE_EXT2: 'ext2', TYPE_EXT3: 'ext2', TYPE_XFS: 'ext2', TYPE_SWAP: 'linux-swap(new)' }[self.type]
26+ return { TYPE_EXT2: 'ext2', TYPE_EXT3: 'ext2', TYPE_EXT4: 'ext2', TYPE_XFS: 'ext2', TYPE_SWAP: 'linux-swap(new)' }[self.type]
27
28 def create(self, disk):
29 """Adds partition to the disk image (does not mkfs or anything like that)"""
30@@ -254,13 +255,7 @@
31 self.device = device
32 self.dummy = dummy
33
34- try:
35- if int(type) == type:
36- self.type = type
37- else:
38- self.type = str_to_type(type)
39- except ValueError, e:
40- self.type = str_to_type(type)
41+ self.set_type(type)
42
43 self.mntpnt = mntpnt
44
45@@ -299,13 +294,13 @@
46 def mkfs_fstype(self):
47 if self.vm.suite in ['dapper', 'edgy', 'feisty', 'gutsy']:
48 logging.debug('%s: 128 bit inode' % self.vm.suite)
49- return { TYPE_EXT2: ['mkfs.ext2', '-F'], TYPE_EXT3: ['mkfs.ext3', '-I 128', '-F'], TYPE_XFS: ['mkfs.xfs'], TYPE_SWAP: ['mkswap'] }[self.type]
50+ return { TYPE_EXT2: ['mkfs.ext2', '-F'], TYPE_EXT3: ['mkfs.ext3', '-I 128', '-F'], TYPE_EXT4: ['mkfs.ext4', '-I 128', '-F'], TYPE_XFS: ['mkfs.xfs'], TYPE_SWAP: ['mkswap'] }[self.type]
51 else:
52 logging.debug('%s: 256 bit inode' % self.vm.suite)
53- return { TYPE_EXT2: ['mkfs.ext2', '-F'], TYPE_EXT3: ['mkfs.ext3', '-F'], TYPE_XFS: ['mkfs.xfs'], TYPE_SWAP: ['mkswap'] }[self.type]
54+ return { TYPE_EXT2: ['mkfs.ext2', '-F'], TYPE_EXT3: ['mkfs.ext3', '-F'], TYPE_EXT4: ['mkfs.ext4', '-F'], TYPE_XFS: ['mkfs.xfs'], TYPE_SWAP: ['mkswap'] }[self.type]
55
56 def fstab_fstype(self):
57- return { TYPE_EXT2: 'ext2', TYPE_EXT3: 'ext3', TYPE_XFS: 'xfs', TYPE_SWAP: 'swap' }[self.type]
58+ return { TYPE_EXT2: 'ext2', TYPE_EXT3: 'ext3', TYPE_EXT4: 'ext4', TYPE_XFS: 'xfs', TYPE_SWAP: 'swap' }[self.type]
59
60 def fstab_options(self):
61 return 'defaults'
62@@ -344,7 +339,16 @@
63 def get_index(self):
64 """Index of the disk (starting from 0)"""
65 return self.vm.filesystems.index(self)
66-
67+
68+ def set_type(self, type):
69+ try:
70+ if int(type) == type:
71+ self.type = type
72+ else:
73+ self.type = str_to_type(type)
74+ except ValueError, e:
75+ self.type = str_to_type(type)
76+
77 def parse_size(size_str):
78 """Takes a size like qemu-img would accept it and returns the size in MB"""
79 try:
80@@ -366,6 +370,7 @@
81
82 str_to_type_map = { 'ext2': TYPE_EXT2,
83 'ext3': TYPE_EXT3,
84+ 'ext4': TYPE_EXT4,
85 'xfs': TYPE_XFS,
86 'swap': TYPE_SWAP,
87 'linux-swap': TYPE_SWAP }
88
89=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
90--- VMBuilder/plugins/ubuntu/distro.py 2009-10-05 11:06:37 +0000
91+++ VMBuilder/plugins/ubuntu/distro.py 2010-01-04 19:54:14 +0000
92@@ -29,7 +29,7 @@
93 class Ubuntu(Distro):
94 name = 'Ubuntu'
95 arg = 'ubuntu'
96- suites = ['dapper', 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic']
97+ suites = ['dapper', 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid']
98
99 # Maps host arch to valid guest archs
100 valid_archs = { 'amd64' : ['amd64', 'i386', 'lpia' ],
101@@ -143,6 +143,9 @@
102 self.get_ec2_ramdisk()
103 self.apply_ec2_settings()
104
105+ if getattr(self.suite, 'set_filesystem_types', False):
106+ self.suite.set_filesystem_types()
107+
108 def install(self, destdir):
109 self.destdir = destdir
110 self.suite.install(destdir)
111
112=== modified file 'VMBuilder/plugins/ubuntu/karmic.py'
113--- VMBuilder/plugins/ubuntu/karmic.py 2009-09-25 19:14:04 +0000
114+++ VMBuilder/plugins/ubuntu/karmic.py 2010-01-04 19:54:14 +0000
115@@ -29,3 +29,10 @@
116
117 def pre_install(self):
118 self.vm.install_file('/etc/hosts', contents='')
119+
120+ def set_filesystem_types(self):
121+ # Default for Karmic and later is ext4
122+ for disk in self.vm.disks:
123+ for partition in disk.partitions:
124+ if partition.parted_fstype() == "ext2":
125+ partition.set_type('ext4')
126
127=== added file 'VMBuilder/plugins/ubuntu/lucid.py'
128--- VMBuilder/plugins/ubuntu/lucid.py 1970-01-01 00:00:00 +0000
129+++ VMBuilder/plugins/ubuntu/lucid.py 2010-01-04 19:54:14 +0000
130@@ -0,0 +1,26 @@
131+#
132+# Uncomplicated VM Builder
133+# Copyright (C) 2007-2009 Canonical Ltd.
134+#
135+# See AUTHORS for list of contributors
136+#
137+# This program is free software: you can redistribute it and/or modify
138+# it under the terms of the GNU General Public License version 3, as
139+# published by the Free Software Foundation.
140+#
141+# This program is distributed in the hope that it will be useful,
142+# but WITHOUT ANY WARRANTY; without even the implied warranty of
143+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+# GNU General Public License for more details.
145+#
146+# You should have received a copy of the GNU General Public License
147+# along with this program. If not, see <http://www.gnu.org/licenses/>.
148+#
149+import suite
150+import logging
151+import VMBuilder.disk as disk
152+from VMBuilder.util import run_cmd
153+from VMBuilder.plugins.ubuntu.karmic import Karmic
154+
155+class Lucid(Karmic):
156+ pass

Subscribers

People subscribed via source and target branches