Merge lp:~bzed/vmbuilder/debian into lp:vmbuilder/trunk
- debian
- Merge into trunk
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~bzed/vmbuilder/debian | ||||
Merge into: | lp:vmbuilder/trunk | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~bzed/vmbuilder/debian | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Soren Hansen | Pending | ||
Review via email: mp+7084@code.launchpad.net |
Commit message
Description of the change
- 338. By Bernd Zeimetz
-
Additional verbosity for template usagefor debugging.
- 339. By Bernd Zeimetz
-
Debian doesn't have a lpia arch - it was left in one help output.
- 340. By Bernd Zeimetz
-
Another template fix for virtualbox.
- 341. By Bernd Zeimetz
-
Older suite need 128 bit inode for grub to recognize os - see r250 for details.
Fixing this for etch, too. - 342. By Bernd Zeimetz
-
Adding xen flavour for etch.
- 343. By Bernd Zeimetz
-
os_type must be Linux for virtualbox.
There doesn't seem to be a way to set it flavour on the commandline. - 344. By Bernd Zeimetz
-
Adding missing copyright.
- 345. By Bernd Zeimetz
-
Merging trunk changes.
Unmerged revisions
- 345. By Bernd Zeimetz
-
Merging trunk changes.
- 344. By Bernd Zeimetz
-
Adding missing copyright.
- 343. By Bernd Zeimetz
-
os_type must be Linux for virtualbox.
There doesn't seem to be a way to set it flavour on the commandline. - 342. By Bernd Zeimetz
-
Adding xen flavour for etch.
- 341. By Bernd Zeimetz
-
Older suite need 128 bit inode for grub to recognize os - see r250 for details.
Fixing this for etch, too. - 340. By Bernd Zeimetz
-
Another template fix for virtualbox.
- 339. By Bernd Zeimetz
-
Debian doesn't have a lpia arch - it was left in one help output.
- 338. By Bernd Zeimetz
-
Additional verbosity for template usagefor debugging.
- 337. By Bernd Zeimetz
-
Add missing import os.
- 336. By Bernd Zeimetz
-
More fixes for the virtualbox deploy skript template.
Preview Diff
1 | === modified file 'AUTHORS' |
2 | --- AUTHORS 2008-09-29 12:28:03 +0000 |
3 | +++ AUTHORS 2009-06-02 10:32:00 +0000 |
4 | @@ -2,3 +2,5 @@ |
5 | |
6 | Other contributors: |
7 | * Nicolas Barcet <nicolas.barcet@ubuntu.com> |
8 | + * Bernd Zeimetz <bzed@debian.org> |
9 | + |
10 | \ No newline at end of file |
11 | |
12 | === modified file 'VMBuilder/__init__.py' |
13 | --- VMBuilder/__init__.py 2008-08-29 22:14:45 +0000 |
14 | +++ VMBuilder/__init__.py 2009-06-04 12:22:50 +0000 |
15 | @@ -21,10 +21,9 @@ |
16 | # The publically exposed bits of VMBuilder |
17 | # |
18 | import logging |
19 | -import VMBuilder.plugins |
20 | +from VMBuilder.plugins import load_plugins, Plugin |
21 | from VMBuilder.distro import Distro |
22 | from VMBuilder.hypervisor import Hypervisor |
23 | -from VMBuilder.plugins import Plugin |
24 | from VMBuilder.frontend import Frontend |
25 | from VMBuilder.vm import VM |
26 | from VMBuilder.exception import VMBuilderException, VMBuilderUserError |
27 | @@ -66,4 +65,4 @@ |
28 | frontend.run() |
29 | |
30 | logging.debug('Loading plugins') |
31 | -VMBuilder.plugins.load_plugins() |
32 | +load_plugins() |
33 | |
34 | === modified file 'VMBuilder/frontend.py' |
35 | --- VMBuilder/frontend.py 2008-08-29 22:14:45 +0000 |
36 | +++ VMBuilder/frontend.py 2009-06-04 00:42:28 +0000 |
37 | @@ -18,22 +18,20 @@ |
38 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
39 | # |
40 | # Frontend interface and classes |
41 | - |
42 | -import VMBuilder |
43 | -import optparse |
44 | +from VMBuilder.exception import VMBuilderException |
45 | |
46 | class Frontend(object): |
47 | def __init__(self): |
48 | self.settings = [] |
49 | |
50 | - def setting_group(self, help=None): |
51 | - return self.SettingsGroup(help) |
52 | + def setting_group(self, setting_help=None): |
53 | + return self.SettingsGroup(setting_help) |
54 | |
55 | def add_setting_group(self, group): |
56 | self.settings.append(group) |
57 | |
58 | def add_setting(self, **kwargs): |
59 | - self.settings.append(Setting(**kwargs)) |
60 | + self.settings.append(self.Setting(**kwargs)) |
61 | |
62 | setting_types = ['store', 'store'] |
63 | class Setting(object): |
64 | @@ -42,8 +40,8 @@ |
65 | self.longarg = kwargs.get('shortarg', None) |
66 | self.default = kwargs.get('default', None) |
67 | self.help = kwargs.get('help', None) |
68 | - type = kwargs.get('type', 'store') |
69 | - if type not in setting_types: |
70 | + store_type = kwargs.get('type', 'store') |
71 | + if store_type not in Frontend.setting_types: |
72 | raise VMBuilderException("Invalid option type: %s" % type) |
73 | |
74 | class SettingsGroup(Setting): |
75 | |
76 | === modified file 'VMBuilder/hypervisor.py' |
77 | --- VMBuilder/hypervisor.py 2008-08-29 22:14:45 +0000 |
78 | +++ VMBuilder/hypervisor.py 2009-06-04 12:23:59 +0000 |
79 | @@ -19,12 +19,12 @@ |
80 | # |
81 | # Hypervisor super class |
82 | |
83 | -import VMBuilder.plugins |
84 | +from VMBuilder import Plugin |
85 | |
86 | STORAGE_DISK_IMAGE = 0 |
87 | STORAGE_FS_IMAGE = 1 |
88 | |
89 | -class Hypervisor(VMBuilder.plugins.Plugin): |
90 | +class Hypervisor(Plugin): |
91 | def finalize(self): |
92 | raise NotImplemented('Hypervisor subclasses need to implement the finalize method') |
93 | |
94 | |
95 | === modified file 'VMBuilder/plugins/__init__.py' |
96 | --- VMBuilder/plugins/__init__.py 2008-12-11 17:37:29 +0000 |
97 | +++ VMBuilder/plugins/__init__.py 2009-06-03 22:31:00 +0000 |
98 | @@ -20,6 +20,7 @@ |
99 | import os |
100 | import VMBuilder |
101 | from VMBuilder.util import run_cmd |
102 | +from VMBuilder.exception import VMBuilderException |
103 | |
104 | def load_plugins(): |
105 | for plugin in find_plugins(): |
106 | |
107 | === modified file 'VMBuilder/plugins/cli/__init__.py' |
108 | --- VMBuilder/plugins/cli/__init__.py 2009-05-04 13:08:30 +0000 |
109 | +++ VMBuilder/plugins/cli/__init__.py 2009-06-04 11:36:56 +0000 |
110 | @@ -1,5 +1,6 @@ |
111 | # Uncomplicated VM Builder |
112 | # Copyright (C) 2007-2008 Canonical Ltd. |
113 | +# Copyright (C) 2009 Bernd Zeimetz <bzed@debian.org> |
114 | # |
115 | # See AUTHORS for list of contributors |
116 | # |
117 | @@ -24,13 +25,12 @@ |
118 | import textwrap |
119 | import VMBuilder |
120 | from VMBuilder.disk import parse_size |
121 | -import VMBuilder.hypervisor |
122 | _ = gettext |
123 | |
124 | |
125 | class CLI(VMBuilder.Frontend): |
126 | arg = 'cli' |
127 | - |
128 | + |
129 | def run(self): |
130 | try: |
131 | next = False |
132 | @@ -52,7 +52,7 @@ |
133 | self.set_usage(vm) |
134 | |
135 | vm.optparser.disable_interspersed_args() |
136 | - (foo, args) = vm.optparser.parse_args() |
137 | + args = vm.optparser.parse_args()[1] |
138 | self.handle_args(vm, args) |
139 | vm.optparser.enable_interspersed_args() |
140 | |
141 | @@ -93,7 +93,7 @@ |
142 | vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/') |
143 | vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None) |
144 | if vm.optsize > 0: |
145 | - vm.add_filesystem(size='%dM' % optsize, type='ext3', mntpnt='/opt') |
146 | + vm.add_filesystem(size='%dM' % vm.optsize, type='ext3', mntpnt='/opt') |
147 | else: |
148 | if vm.raw: |
149 | disk = vm.add_disk(filename=vm.raw, preallocated=True) |
150 | @@ -161,22 +161,38 @@ |
151 | disk.add_part(offset, int(pair[1]), 'ext3', pair[0]) |
152 | offset += int(pair[1]) |
153 | |
154 | -class UVB(CLI): |
155 | - arg = 'ubuntu-vm-builder' |
156 | +class VB(CLI): |
157 | + arg = 'vb' |
158 | + suites = [] |
159 | + distro = '' |
160 | |
161 | def set_usage(self, vm): |
162 | vm.optparser.set_usage('%prog hypervisor suite [options]') |
163 | vm.optparser.arg_help = (('hypervisor', vm.hypervisor_help), ('suite', self.suite_help)) |
164 | |
165 | def suite_help(self): |
166 | - return 'Suite. Valid options: %s' % " ".join(VMBuilder.plugins.ubuntu.distro.Ubuntu.suites) |
167 | + return 'Suite. Valid options: %s' % " ".join(self.suites) |
168 | |
169 | def handle_args(self, vm, args): |
170 | if len(args) < 2: |
171 | vm.optparser.error("You need to specify at least the hypervisor type and the suite") |
172 | vm.set_hypervisor(args[0]) |
173 | - vm.set_distro('ubuntu') |
174 | + vm.set_distro(self.distro) |
175 | vm.suite = args[1] |
176 | |
177 | +class UVB(VB): |
178 | + arg = 'ubuntu-vm-builder' |
179 | + import VMBuilder.plugins.ubuntu as ubuntu |
180 | + suites = ubuntu.distro.Ubuntu.suites |
181 | + distro = 'ubuntu' |
182 | + |
183 | +class DVB(VB): |
184 | + arg = 'debian-vm-builder' |
185 | + import VMBuilder.plugins.debian as debian |
186 | + suites = debian.distro.Debian.suites |
187 | + distro = 'debian' |
188 | + |
189 | + |
190 | VMBuilder.register_frontend(CLI) |
191 | VMBuilder.register_frontend(UVB) |
192 | +VMBuilder.register_frontend(DVB) |
193 | |
194 | === added directory 'VMBuilder/plugins/debian' |
195 | === added file 'VMBuilder/plugins/debian/__init__.py' |
196 | --- VMBuilder/plugins/debian/__init__.py 1970-01-01 00:00:00 +0000 |
197 | +++ VMBuilder/plugins/debian/__init__.py 2009-06-02 12:04:26 +0000 |
198 | @@ -0,0 +1,21 @@ |
199 | +# |
200 | +# Uncomplicated VM Builder |
201 | +# Copyright (C) 2007-2008 Canonical Ltd. |
202 | +# Copyright (C) 2009 Bernd Zeimetz <bzed@debian.org> |
203 | +# |
204 | +# See AUTHORS for list of contributors |
205 | +# |
206 | +# This program is free software: you can redistribute it and/or modify |
207 | +# it under the terms of the GNU General Public License as published by |
208 | +# the Free Software Foundation, either version 3 of the License, or |
209 | +# (at your option) any later version. |
210 | +# |
211 | +# This program is distributed in the hope that it will be useful, |
212 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
213 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
214 | +# GNU General Public License for more details. |
215 | +# |
216 | +# You should have received a copy of the GNU General Public License |
217 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
218 | +# |
219 | +import distro |
220 | |
221 | === added file 'VMBuilder/plugins/debian/distro.py' |
222 | --- VMBuilder/plugins/debian/distro.py 1970-01-01 00:00:00 +0000 |
223 | +++ VMBuilder/plugins/debian/distro.py 2009-06-03 09:40:36 +0000 |
224 | @@ -0,0 +1,195 @@ |
225 | +# |
226 | +# Uncomplicated VM Builder |
227 | +# Copyright (C) 2007-2008 Canonical Ltd. |
228 | +# Copyright (C) 2009 Bernd Zeimetz <bzed@debian.org> |
229 | +# |
230 | +# See AUTHORS for list of contributors |
231 | +# |
232 | +# This program is free software: you can redistribute it and/or modify |
233 | +# it under the terms of the GNU General Public License as published by |
234 | +# the Free Software Foundation, either version 3 of the License, or |
235 | +# (at your option) any later version. |
236 | +# |
237 | +# This program is distributed in the hope that it will be useful, |
238 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
239 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
240 | +# GNU General Public License for more details. |
241 | +# |
242 | +# You should have received a copy of the GNU General Public License |
243 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
244 | +# |
245 | +import logging |
246 | +import os |
247 | +import socket |
248 | +import types |
249 | +import VMBuilder |
250 | +from VMBuilder import register_distro, Distro |
251 | +from VMBuilder.util import run_cmd |
252 | +from VMBuilder.exception import VMBuilderUserError, VMBuilderException |
253 | + |
254 | +class Debian(Distro): |
255 | + name = 'Debian' |
256 | + arg = 'debian' |
257 | + suites = ['etch'] |
258 | + |
259 | + # Maps host arch to valid guest archs |
260 | + # FIXME: Running a amd64 kernel with an i386 userspace allows us to run |
261 | + # amd64 guests |
262 | + |
263 | + valid_archs = { 'amd64' : ['amd64', 'i386' ], |
264 | + 'i386' : [ 'i386' ] } |
265 | + |
266 | + xen_kernel = '' |
267 | + |
268 | + def register_options(self): |
269 | + group = self.vm.setting_group('Package options') |
270 | + group.add_option('--addpkg', action='append', metavar='PKG', help='Install PKG into the guest (can be specfied multiple times).') |
271 | + group.add_option('--removepkg', action='append', metavar='PKG', help='Remove PKG from the guest (can be specfied multiple times)') |
272 | + self.vm.register_setting_group(group) |
273 | + |
274 | + group = self.vm.setting_group('General OS options') |
275 | + self.host_arch = run_cmd('dpkg', '--print-architecture').rstrip() |
276 | + group.add_option('-a', '--arch', default=self.host_arch, help='Specify the target architecture. Valid options: amd64 i386 lpia (defaults to host arch)') |
277 | + group.add_option('--hostname', default='debian', help='Set NAME as the hostname of the guest. Default: debian. Also uses this name as the VM name.') |
278 | + self.vm.register_setting_group(group) |
279 | + |
280 | + # FIXME: Add Debian ports |
281 | + group = self.vm.setting_group('Installation options') |
282 | + group.add_option('--suite', default='etch', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites)) |
283 | + group.add_option('--flavour', '--kernel-flavour', help='Kernel flavour to use. Default and valid options depend on architecture and suite') |
284 | + group.add_option('--variant', metavar='VARIANT', help='Passed to debootstrap --variant flag; use minbase, buildd, or fakechroot.') |
285 | + group.add_option('--iso', metavar='PATH', help='Use an iso image as the source for installation of file. Full path to the iso must be provided. If --mirror is also provided, it will be used in the final sources.list of the vm. This requires suite and kernel parameter to match what is available on the iso, obviously.') |
286 | + group.add_option('--mirror', metavar='URL', help='Use Debian mirror at URL instead of the default, which is http://ftp.debian.org for official arches.') |
287 | + group.add_option('--proxy', metavar='URL', help='Use proxy at URL for cached packages') |
288 | + group.add_option('--install-mirror', metavar='URL', help='Use Debian mirror at URL for the installation only. Apt\'s sources.list will still use default or URL set by --mirror') |
289 | + group.add_option('--security-mirror', metavar='URL', help='Use Debian security mirror at URL instead of the default, which is http://security.debian.org/debian-security/ for official arches.') |
290 | + group.add_option('--install-security-mirror', metavar='URL', help='Use the security mirror at URL for installation only. Apt\'s sources.list will still use default or URL set by --security-mirror') |
291 | + group.add_option('--components', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,contrib,non-free).') |
292 | + group.add_option('--lang', metavar='LANG', default=self.get_locale(), help='Set the locale to LANG [default: %default]') |
293 | + self.vm.register_setting_group(group) |
294 | + |
295 | + group = self.vm.setting_group('Settings for the initial user') |
296 | + group.add_option('--user', default='debian', help='Username of initial user [default: %default]') |
297 | + group.add_option('--name', default='Debian', help='Full name of initial user [default: %default]') |
298 | + group.add_option('--pass', default='debian', help='Password of initial user [default: %default]') |
299 | + group.add_option('--rootpass', help='Initial root password (WARNING: this has strong security implications).') |
300 | + self.vm.register_setting_group(group) |
301 | + |
302 | + group = self.vm.setting_group('Other options') |
303 | + group.add_option('--ssh-key', metavar='PATH', help='Add PATH to root\'s ~/.ssh/authorized_keys (WARNING: this has strong security implications).') |
304 | + group.add_option('--ssh-user-key', help='Add PATH to the user\'s ~/.ssh/authorized_keys.') |
305 | + self.vm.register_setting_group(group) |
306 | + |
307 | + def set_defaults(self): |
308 | + if not self.vm.mirror: |
309 | + #if self.vm.arch == 'lpia': |
310 | + # self.vm.mirror = 'http://ports.ubuntu.com/ubuntu-ports' |
311 | + #else: |
312 | + self.vm.mirror = 'http://ftp.debian.org/debian' |
313 | + |
314 | + if not self.vm.security_mirror: |
315 | + #if self.vm.arch == 'lpia': |
316 | + # self.vm.security_mirror = 'http://ports.ubuntu.com/ubuntu-ports' |
317 | + #else: |
318 | + self.vm.security_mirror = 'http://security.debian.org/debian-security' |
319 | + |
320 | + if not self.vm.components: |
321 | + self.vm.components = ['main'] |
322 | + else: |
323 | + self.vm.components = self.vm.components.split(',') |
324 | + |
325 | + def get_locale(self): |
326 | + return os.getenv('LANG') |
327 | + |
328 | + def preflight_check(self): |
329 | + """While not all of these are strictly checks, their failure would inevitably |
330 | + lead to failure, and since we can check them before we start setting up disk |
331 | + and whatnot, we might as well go ahead an do this now.""" |
332 | + |
333 | + if not self.vm.suite in self.suites: |
334 | + raise VMBuilderUserError('Invalid suite. Valid suites are: %s' % ' '.join(self.suites)) |
335 | + |
336 | + modname = 'VMBuilder.plugins.debian.%s' % (self.vm.suite, ) |
337 | + mod = __import__(modname, fromlist=[self.vm.suite]) |
338 | + self.suite = getattr(mod, self.vm.suite.capitalize())(self.vm) |
339 | + |
340 | + if self.vm.arch not in self.valid_archs[self.host_arch] or \ |
341 | + not self.suite.check_arch_validity(self.vm.arch): |
342 | + raise VMBuilderUserError('%s is not a valid architecture. Valid architectures are: %s' % (self.vm.arch, |
343 | + ' '.join(self.valid_archs[self.host_arch]))) |
344 | + |
345 | + if not self.vm.components: |
346 | + self.vm.components = ['main', 'restricted', 'universe'] |
347 | + else: |
348 | + if type(self.vm.components) is str: |
349 | + self.vm.components = self.vm.components.split(',') |
350 | + |
351 | + if self.vm.hypervisor.name == 'Xen': |
352 | + logging.info('Xen kernel default: linux-image-%s %s', self.suite.xen_kernel_flavour, self.xen_kernel_version()) |
353 | + |
354 | + self.vm.virtio_net = self.use_virtio_net() |
355 | + |
356 | + if self.vm.lang: |
357 | + try: |
358 | + run_cmd('locale-gen', '%s' % self.vm.lang) |
359 | + except VMBuilderException, e: |
360 | + msg = "locale-gen does not recognize your locale '%s'" % self.vm.lang |
361 | + raise VMBuilderUserError(msg) |
362 | + |
363 | + def install(self, destdir): |
364 | + self.destdir = destdir |
365 | + self.suite.install(destdir) |
366 | + |
367 | + def install_vmbuilder_log(self, logfile, rootdir): |
368 | + self.suite.install_vmbuilder_log(logfile, rootdir) |
369 | + |
370 | + def post_mount(self, fs): |
371 | + self.suite.post_mount(fs) |
372 | + |
373 | + def use_virtio_net(self): |
374 | + return self.suite.virtio_net |
375 | + |
376 | + def install_bootloader(self): |
377 | + devmapfile = '%s/device.map' % self.vm.workdir |
378 | + devmap = open(devmapfile, 'w') |
379 | + for (disk, id) in zip(self.vm.disks, range(len(self.vm.disks))): |
380 | + devmap.write("(hd%d) %s\n" % (id, disk.filename)) |
381 | + devmap.close() |
382 | + run_cmd('grub', '--device-map=%s' % devmapfile, '--batch', stdin='''root (hd0,0) |
383 | +setup (hd0) |
384 | +EOT''') |
385 | + |
386 | + def xen_kernel_version(self): |
387 | + if self.suite.xen_kernel_flavour: |
388 | + if not self.xen_kernel: |
389 | + rmad = run_cmd('rmadison', 'linux-image-%s' % self.suite.xen_kernel_flavour) |
390 | + version = ['0', '0','0', '0'] |
391 | + |
392 | + for line in rmad.splitlines(): |
393 | + sline = line.split('|') |
394 | + |
395 | + if sline[2].strip().startswith(self.vm.suite): |
396 | + vt = sline[1].strip().split('.') |
397 | + for i in range(4): |
398 | + if int(vt[i]) > int(version[i]): |
399 | + version = vt |
400 | + break |
401 | + |
402 | + if version[0] == '0': |
403 | + raise VMBuilderException('Something is wrong, no valid xen kernel for the suite %s found by rmadison' % self.vm.suite) |
404 | + |
405 | + self.xen_kernel = '%s.%s.%s-%s' % (version[0],version[1],version[2],version[3]) |
406 | + return self.xen_kernel |
407 | + else: |
408 | + raise VMBuilderUserError('There is no valid xen kernel for the suite selected.') |
409 | + |
410 | + def xen_kernel_path(self): |
411 | + path = '/boot/vmlinuz-%s-%s' % (self.xen_kernel_version(), self.suite.xen_kernel_flavour) |
412 | + return path |
413 | + |
414 | + def xen_ramdisk_path(self): |
415 | + path = '/boot/initrd.img-%s-%s' % (self.xen_kernel_version(), self.suite.xen_kernel_flavour) |
416 | + return path |
417 | + |
418 | + |
419 | +register_distro(Debian) |
420 | |
421 | === added file 'VMBuilder/plugins/debian/etch.py' |
422 | --- VMBuilder/plugins/debian/etch.py 1970-01-01 00:00:00 +0000 |
423 | +++ VMBuilder/plugins/debian/etch.py 2009-06-04 13:21:36 +0000 |
424 | @@ -0,0 +1,342 @@ |
425 | +# |
426 | +# Uncomplicated VM Builder |
427 | +# Copyright (C) 2007-2008 Canonical Ltd. |
428 | +# Copyright (C) 2009 Bernd Zeimetz <bzed@debian.org> |
429 | +# |
430 | +# See AUTHORS for list of contributors |
431 | +# |
432 | +# This program is free software: you can redistribute it and/or modify |
433 | +# it under the terms of the GNU General Public License as published by |
434 | +# the Free Software Foundation, either version 3 of the License, or |
435 | +# (at your option) any later version. |
436 | +# |
437 | +# This program is distributed in the hope that it will be useful, |
438 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
439 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
440 | +# GNU General Public License for more details. |
441 | +# |
442 | +# You should have received a copy of the GNU General Public License |
443 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
444 | +# |
445 | +import glob |
446 | +import logging |
447 | +import os |
448 | +import shutil |
449 | +import socket |
450 | +import tempfile |
451 | +import VMBuilder |
452 | +import VMBuilder.disk as disk |
453 | +import VMBuilder.suite as suite |
454 | +from VMBuilder.util import run_cmd |
455 | + |
456 | +class Etch(suite.Suite): |
457 | + updategrub = "/usr/sbin/update-grub" |
458 | + grubroot = "/usr/lib/grub" |
459 | + |
460 | + valid_flavours = { 'i386' : ['486', '686', '686-bigmem', |
461 | + '686-bigmem-etchnhalf', '686-etchnhalf', |
462 | + '686-smp', 'vserver-686'], |
463 | + 'amd64' : ['amd64', 'amd64-etchnhalf', 'amd64-generic', |
464 | + 'amd64-k8', 'amd64-k8-smp', 'vserver-amd64', |
465 | + 'vserver-amd64-k8-smp']} |
466 | + |
467 | + default_flavour = { 'i386' : '686-etchnhalf', 'amd64' : 'amd64-etchnhalf' } |
468 | + disk_prefix = 'sd' |
469 | + xen_kernel_flavour = None |
470 | + virtio_net = False |
471 | + |
472 | + def check_kernel_flavour(self, arch, flavour): |
473 | + return flavour in self.valid_flavours[arch] |
474 | + |
475 | + def check_arch_validity(self, arch): |
476 | + return arch in self.valid_flavours.keys() |
477 | + |
478 | + def install(self, destdir): |
479 | + self.destdir = destdir |
480 | + |
481 | + logging.debug("debootstrapping") |
482 | + self.debootstrap() |
483 | + |
484 | + logging.debug("Setting up sources.list") |
485 | + self.install_sources_list() |
486 | + |
487 | + logging.debug("Setting up apt proxy") |
488 | + self.install_apt_proxy() |
489 | + |
490 | + logging.debug("Installing fstab") |
491 | + self.install_fstab() |
492 | + |
493 | + logging.debug("Creating devices") |
494 | + self.create_devices() |
495 | + |
496 | + if self.vm.hypervisor.needs_bootloader: |
497 | + logging.debug("Installing grub") |
498 | + self.install_grub() |
499 | + |
500 | + logging.debug("Configuring guest networking") |
501 | + self.config_network() |
502 | + |
503 | + logging.debug("Preventing daemons from starting") |
504 | + self.prevent_daemons_starting() |
505 | + |
506 | + if self.vm.hypervisor.needs_bootloader: |
507 | + logging.debug("Installing menu.list") |
508 | + self.install_menu_lst() |
509 | + |
510 | + logging.debug("Installing kernel") |
511 | + self.install_kernel() |
512 | + |
513 | + logging.debug("Creating device.map") |
514 | + self.install_device_map() |
515 | + |
516 | + logging.debug("Installing extra packages") |
517 | + self.install_extras() |
518 | + |
519 | + logging.debug("Creating initial user") |
520 | + self.create_initial_user() |
521 | + |
522 | + logging.debug("Installing ssh keys") |
523 | + self.install_authorized_keys() |
524 | + |
525 | + logging.debug("Installing locales") |
526 | + self.install_locales() |
527 | + |
528 | + logging.debug("Copy host settings") |
529 | + self.copy_settings() |
530 | + |
531 | + logging.debug("Making sure system is up-to-date") |
532 | + self.update() |
533 | + |
534 | + logging.debug("Setting up final sources.list") |
535 | + self.install_sources_list(final=True) |
536 | + |
537 | + logging.debug("Unmounting volatile lrm filesystems") |
538 | + self.unmount_volatile() |
539 | + |
540 | + logging.debug("Unpreventing daemons from starting") |
541 | + self.unprevent_daemons_starting() |
542 | + |
543 | + def update(self): |
544 | + self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade', |
545 | + env={ 'DEBIAN_FRONTEND' : 'noninteractive' }) |
546 | + |
547 | + def install_authorized_keys(self): |
548 | + if self.vm.ssh_key: |
549 | + os.mkdir('%s/root/.ssh' % self.destdir, 0700) |
550 | + shutil.copy(self.vm.ssh_key, '%s/root/.ssh/authorized_keys' % self.destdir) |
551 | + os.chmod('%s/root/.ssh/authorized_keys' % self.destdir, 0644) |
552 | + if self.vm.ssh_user_key: |
553 | + os.mkdir('%s/home/%s/.ssh' % (self.destdir, self.vm.user), 0700) |
554 | + shutil.copy(self.vm.ssh_user_key, '%s/home/%s/.ssh/authorized_keys' % (self.destdir, self.vm.user)) |
555 | + os.chmod('%s/home/%s/.ssh/authorized_keys' % (self.destdir, self.vm.user), 0644) |
556 | + self.run_in_target('chown', '-R', '%s:%s' % (self.vm.user,)*2, '/home/%s/.ssh/' % (self.vm.user)) |
557 | + |
558 | + if self.vm.ssh_user_key or self.vm.ssh_key: |
559 | + if not self.vm.addpkg: |
560 | + self.vm.addpkg = [] |
561 | + self.vm.addpkg += ['openssh-server'] |
562 | + |
563 | + def update_passwords(self): |
564 | + # Set the user password, using md5 |
565 | + self.run_in_target('chpasswd', '-m', stdin=('%s:%s\n' % (self.vm.user, getattr(self.vm, 'pass')))) |
566 | + |
567 | + # Lock root account only if we didn't set the root password |
568 | + if self.vm.rootpass: |
569 | + self.run_in_target('chpasswd', '-m', stdin=('%s:%s\n' % ('root', self.vm.rootpass))) |
570 | + else: |
571 | + self.run_in_target('chpasswd', '-e', stdin='root:!\n') |
572 | + |
573 | + def create_initial_user(self): |
574 | + self.run_in_target('adduser', '--disabled-password', '--gecos', self.vm.name, self.vm.user) |
575 | + self.run_in_target('addgroup', '--system', 'admin') |
576 | + self.run_in_target('adduser', self.vm.user, 'admin') |
577 | + |
578 | + self.install_from_template('/etc/sudoers', 'sudoers') |
579 | + for group in ['adm', 'audio', 'cdrom', 'dialout', 'floppy', 'video', 'plugdev', 'dip', 'netdev', 'powerdev', 'lpadmin', 'scanner']: |
580 | + self.run_in_target('adduser', self.vm.user, group, ignore_fail=True) |
581 | + |
582 | + self.update_passwords() |
583 | + |
584 | + def kernel_name(self): |
585 | + return 'linux-image-2.6-%s' % (self.vm.flavour or self.default_flavour[self.vm.arch],) |
586 | + |
587 | + def config_network(self): |
588 | + self.vm.install_file('/etc/hostname', self.vm.hostname) |
589 | + self.install_from_template('/etc/hosts', 'etc_hosts', { 'hostname' : self.vm.hostname, 'domain' : self.vm.domain }) |
590 | + self.install_from_template('/etc/network/interfaces', 'interfaces') |
591 | + |
592 | + def unprevent_daemons_starting(self): |
593 | + os.unlink('%s/usr/sbin/policy-rc.d' % self.destdir) |
594 | + |
595 | + def prevent_daemons_starting(self): |
596 | + os.chmod(self.install_from_template('/usr/sbin/policy-rc.d', 'nostart-policy-rc.d'), 0755) |
597 | + |
598 | + def install_extras(self): |
599 | + if not self.vm.addpkg and not self.vm.removepkg: |
600 | + return |
601 | + cmd = ['apt-get', 'install', '-y', '--force-yes'] |
602 | + cmd += self.vm.addpkg or [] |
603 | + cmd += ['%s-' % pkg for pkg in self.vm.removepkg or []] |
604 | + self.run_in_target(env={ 'DEBIAN_FRONTEND' : 'noninteractive' }, *cmd) |
605 | + |
606 | + def unmount_volatile(self): |
607 | + for mntpnt in glob.glob('%s/lib/modules/*/volatile' % self.destdir): |
608 | + logging.debug("Unmounting %s" % mntpnt) |
609 | + run_cmd('umount', mntpnt) |
610 | + |
611 | + def install_menu_lst(self): |
612 | + run_cmd('mount', '--bind', '/dev', '%s/dev' % self.destdir) |
613 | + self.vm.add_clean_cmd('umount', '%s/dev' % self.destdir, ignore_fail=True) |
614 | + |
615 | + self.run_in_target('mount', '-t', 'proc', 'proc', '/proc') |
616 | + self.vm.add_clean_cmd('umount', '%s/proc' % self.destdir, ignore_fail=True) |
617 | + |
618 | + self.run_in_target(self.updategrub, '-y') |
619 | + self.mangle_grub_menu_lst() |
620 | + self.run_in_target(self.updategrub) |
621 | + self.run_in_target('grub-set-default', '0') |
622 | + |
623 | + run_cmd('umount', '%s/dev' % self.destdir) |
624 | + run_cmd('umount', '%s/proc' % self.destdir) |
625 | + |
626 | + def mangle_grub_menu_lst(self): |
627 | + bootdev = disk.bootpart(self.vm.disks) |
628 | + run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s\\2/g' % bootdev.fs.uuid, '%s/boot/grub/menu.lst' % self.destdir) |
629 | + run_cmd('sed', '-ie', 's/^# groot.*/# groot %s/g' % bootdev.get_grub_id(), '%s/boot/grub/menu.lst' % self.destdir) |
630 | + run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % self.destdir) |
631 | + |
632 | + def install_sources_list(self, final=False): |
633 | + if final: |
634 | + mirror, updates_mirror, security_mirror = self.vm.mirror, self.vm.mirror, self.vm.security_mirror |
635 | + else: |
636 | + mirror, updates_mirror, security_mirror = self.install_mirrors() |
637 | + |
638 | + self.install_from_template('/etc/apt/sources.list', 'sources.list', { 'mirror' : mirror, 'security_mirror' : security_mirror, 'updates_mirror' : updates_mirror }) |
639 | + |
640 | + # If setting up the final mirror, allow apt-get update to fail |
641 | + # (since we might be on a complete different network than the |
642 | + # final vm is going to be on). |
643 | + self.run_in_target('apt-get', 'update', ignore_fail=final) |
644 | + |
645 | + def install_apt_proxy(self): |
646 | + if self.vm.proxy is not None: |
647 | + self.vm.install_file('/etc/apt/apt.conf', '// Proxy added by vmbuilder\nAcquire::http { Proxy "%s"; };' % self.vm.proxy) |
648 | + |
649 | + def install_fstab(self): |
650 | + if self.vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE: |
651 | + self.install_from_template('/etc/fstab', 'etch_fstab_fsimage', { 'fss' : disk.get_ordered_filesystems(self.vm), 'prefix' : self.disk_prefix }) |
652 | + else: |
653 | + self.install_from_template('/etc/fstab', 'etch_fstab', { 'parts' : disk.get_ordered_partitions(self.vm.disks), 'prefix' : self.disk_prefix }) |
654 | + |
655 | + def install_device_map(self): |
656 | + self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix }) |
657 | + |
658 | + def debootstrap(self): |
659 | + cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch] |
660 | + if self.vm.variant: |
661 | + cmd += ['--variant=%s' % self.vm.variant] |
662 | + cmd += [self.vm.suite, self.destdir, self.debootstrap_mirror()] |
663 | + kwargs = { 'env' : { 'DEBIAN_FRONTEND' : 'noninteractive' } } |
664 | + if self.vm.proxy: |
665 | + kwargs['env']['http_proxy'] = self.vm.proxy |
666 | + run_cmd(*cmd, **kwargs) |
667 | + |
668 | + def debootstrap_mirror(self): |
669 | + if self.vm.iso: |
670 | + isodir = tempfile.mkdtemp() |
671 | + self.vm.add_clean_cb(lambda:os.rmdir(isodir)) |
672 | + run_cmd('mount', '-o', 'loop', '-t', 'iso9660', self.vm.iso, isodir) |
673 | + self.vm.add_clean_cmd('umount', isodir) |
674 | + self.iso_mounted = True |
675 | + |
676 | + return 'file://%s' % isodir |
677 | + else: |
678 | + return self.install_mirrors()[0] |
679 | + |
680 | + |
681 | + def install_mirrors(self): |
682 | + if self.vm.iso: |
683 | + mirror = "file:///isomnt" |
684 | + elif self.vm.install_mirror: |
685 | + mirror = self.vm.install_mirror |
686 | + else: |
687 | + mirror = self.vm.mirror |
688 | + |
689 | + if self.vm.install_mirror: |
690 | + updates_mirror = self.vm.install_mirror |
691 | + else: |
692 | + updates_mirror = self.vm.mirror |
693 | + |
694 | + if self.vm.install_security_mirror: |
695 | + security_mirror = self.vm.install_security_mirror |
696 | + else: |
697 | + security_mirror = self.vm.security_mirror |
698 | + |
699 | + return (mirror, updates_mirror, security_mirror) |
700 | + |
701 | + def install_kernel(self): |
702 | + self.install_from_template('/etc/kernel-img.conf', 'kernelimg', { 'updategrub' : self.updategrub }) |
703 | + run_cmd('chroot', self.destdir, 'apt-get', '--force-yes', '-y', 'install', self.kernel_name(), 'grub') |
704 | + |
705 | + def install_grub(self): |
706 | + self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'grub') |
707 | + run_cmd('cp', '-a', '%s%s/%s/' % (self.destdir, self.grubroot, self.vm.arch == 'amd64' and 'x86_64-pc' or 'i386-pc'), '%s/boot/grub' % self.destdir) |
708 | + |
709 | + |
710 | + def install_locales(self): |
711 | + self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'locales') |
712 | + |
713 | + def create_devices(self): |
714 | + import VMBuilder.plugins.xen |
715 | + |
716 | + if isinstance(self.vm.hypervisor, VMBuilder.plugins.xen.Xen): |
717 | + self.run_in_target('mknod', '/dev/xvda', 'b', '202', '0') |
718 | + self.run_in_target('mknod', '/dev/xvda1', 'b', '202', '1') |
719 | + self.run_in_target('mknod', '/dev/xvda2', 'b', '202', '2') |
720 | + self.run_in_target('mknod', '/dev/xvda3', 'b', '202', '3') |
721 | + self.run_in_target('mknod', '/dev/xvc0', 'c', '204', '191') |
722 | + |
723 | + def install_from_template(self, *args, **kwargs): |
724 | + return self.vm.distro.install_from_template(*args, **kwargs) |
725 | + |
726 | + def run_in_target(self, *args, **kwargs): |
727 | + self.vm.distro.run_in_target(*args, **kwargs) |
728 | + |
729 | + def copy_to_target(self, infile, destpath): |
730 | + logging.debug("Copying %s on host to %s in guest" % (infile, destpath)) |
731 | + dir = '%s/%s' % (self.destdir, os.path.dirname(destpath)) |
732 | + if not os.path.isdir(dir): |
733 | + os.makedirs(dir) |
734 | + if os.path.isdir(infile): |
735 | + shutil.copytree(infile, '%s/%s' % (self.destdir, destpath)) |
736 | + else: |
737 | + shutil.copy(infile, '%s/%s' % (self.destdir, destpath)) |
738 | + |
739 | + def post_mount(self, fs): |
740 | + if fs.mntpnt == '/': |
741 | + logging.debug("Creating /var/run in root filesystem") |
742 | + os.makedirs('%s/var/run' % fs.mntpath) |
743 | + logging.debug("Creating /var/lock in root filesystem") |
744 | + os.makedirs('%s/var/lock' % fs.mntpath) |
745 | + |
746 | + |
747 | + def copy_settings(self): |
748 | + self.copy_to_target('/etc/default/locale', '/etc/default/locale') |
749 | + csdir = '%s/etc/console-setup' % self.destdir |
750 | + have_cs = os.path.isdir(csdir) |
751 | + if have_cs: |
752 | + shutil.rmtree(csdir) |
753 | + self.copy_to_target('/etc/console-setup', '/etc/console-setup') |
754 | + self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup') |
755 | + self.copy_to_target('/etc/timezone', '/etc/timezone') |
756 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'tzdata') |
757 | + self.run_in_target('locale-gen', 'en_US.UTF-8') |
758 | + if self.vm.lang: |
759 | + self.run_in_target('locale-gen', self.vm.lang) |
760 | + self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang }) |
761 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales') |
762 | + if have_cs: |
763 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'console-setup') |
764 | + |
765 | + def install_vmbuilder_log(self, logfile, rootdir): |
766 | + shutil.copy(logfile, '%s/var/log/vmbuilder-install.log' % (rootdir,)) |
767 | |
768 | === added directory 'VMBuilder/plugins/debian/templates' |
769 | === added file 'VMBuilder/plugins/debian/templates/devicemap.tmpl' |
770 | --- VMBuilder/plugins/debian/templates/devicemap.tmpl 1970-01-01 00:00:00 +0000 |
771 | +++ VMBuilder/plugins/debian/templates/devicemap.tmpl 2009-06-02 11:01:44 +0000 |
772 | @@ -0,0 +1,3 @@ |
773 | +#for $disk in $disks |
774 | +$disk.get_grub_id() /dev/$prefix$disk.devletters() |
775 | +#end for |
776 | |
777 | === added file 'VMBuilder/plugins/debian/templates/etc_hosts.tmpl' |
778 | --- VMBuilder/plugins/debian/templates/etc_hosts.tmpl 1970-01-01 00:00:00 +0000 |
779 | +++ VMBuilder/plugins/debian/templates/etc_hosts.tmpl 2009-06-02 11:01:44 +0000 |
780 | @@ -0,0 +1,10 @@ |
781 | +127.0.0.1 localhost |
782 | +127.0.1.1 $hostname.$domain $hostname |
783 | + |
784 | +# The following lines are desirable for IPv6 capable hosts |
785 | +::1 ip6-localhost ip6-loopback |
786 | +fe00::0 ip6-localnet |
787 | +ff00::0 ip6-mcastprefix |
788 | +ff02::1 ip6-allnodes |
789 | +ff02::2 ip6-allrouters |
790 | +ff02::3 ip6-allhosts |
791 | |
792 | === added file 'VMBuilder/plugins/debian/templates/etch_fstab.tmpl' |
793 | --- VMBuilder/plugins/debian/templates/etch_fstab.tmpl 1970-01-01 00:00:00 +0000 |
794 | +++ VMBuilder/plugins/debian/templates/etch_fstab.tmpl 2009-06-02 11:03:02 +0000 |
795 | @@ -0,0 +1,10 @@ |
796 | +# /etc/fstab: static file system information. |
797 | +# |
798 | +# <file system> <mount point> <type> <options> <dump> <pass> |
799 | +proc /proc proc defaults 0 0 |
800 | +#for $part in $parts |
801 | +#echo '/dev/%s%-40s %-15s %-7s %-15s %d %d\n' % ($prefix, part.get_suffix(), part.mntpnt, part.fs.fstab_fstype(), part.fs.fstab_options(), 0, 0) |
802 | +#* |
803 | +echo "/dev/$prefix$part.get_suffix() $part.mntpnt $part.fs.fstab_fstype() $part.fs.fstab_options() 0 0 |
804 | +*# |
805 | +#end for |
806 | |
807 | === added file 'VMBuilder/plugins/debian/templates/etch_fstab_fsimage.tmpl' |
808 | --- VMBuilder/plugins/debian/templates/etch_fstab_fsimage.tmpl 1970-01-01 00:00:00 +0000 |
809 | +++ VMBuilder/plugins/debian/templates/etch_fstab_fsimage.tmpl 2009-06-02 11:03:02 +0000 |
810 | @@ -0,0 +1,10 @@ |
811 | +# /etc/fstab: static file system information. |
812 | +# |
813 | +# <file system> <mount point> <type> <options> <dump> <pass> |
814 | +proc /proc proc defaults 0 0 |
815 | +#for $fs in $fss |
816 | +#echo '/dev/%s%-40s %-15s %-7s %-15s %d %d\n' % ($prefix, fs.get_suffix(), fs.mntpnt, fs.fstab_fstype(), fs.fstab_options(), 0, 0) |
817 | +#* |
818 | +echo "/dev/$prefix$part.get_suffix() $part.mntpnt $part.fs.fstab_fstype() $part.fs.fstab_options() 0 0 |
819 | +*# |
820 | +#end for |
821 | |
822 | === added file 'VMBuilder/plugins/debian/templates/interfaces.tmpl' |
823 | --- VMBuilder/plugins/debian/templates/interfaces.tmpl 1970-01-01 00:00:00 +0000 |
824 | +++ VMBuilder/plugins/debian/templates/interfaces.tmpl 2009-06-02 11:01:44 +0000 |
825 | @@ -0,0 +1,22 @@ |
826 | +# This file describes the network interfaces available on your system |
827 | +# and how to activate them. For more information, see interfaces(5). |
828 | + |
829 | +# The loopback network interface |
830 | +auto lo |
831 | +iface lo inet loopback |
832 | + |
833 | +# The primary network interface |
834 | +auto eth0 |
835 | +#if $ip == 'dhcp' |
836 | +iface eth0 inet dhcp |
837 | +#else |
838 | +iface eth0 inet static |
839 | + address $ip |
840 | + netmask $mask |
841 | + network $net |
842 | + broadcast $bcast |
843 | + gateway $gw |
844 | + # dns-* options are implemented by the resolvconf package, if installed |
845 | + dns-nameservers $dns |
846 | + dns-search $domain |
847 | +#end if |
848 | |
849 | === added file 'VMBuilder/plugins/debian/templates/kernelimg.tmpl' |
850 | --- VMBuilder/plugins/debian/templates/kernelimg.tmpl 1970-01-01 00:00:00 +0000 |
851 | +++ VMBuilder/plugins/debian/templates/kernelimg.tmpl 2009-06-02 11:01:44 +0000 |
852 | @@ -0,0 +1,8 @@ |
853 | +do_symlinks = yes |
854 | +relative_links = yes |
855 | +do_bootfloppy = no |
856 | +do_initrd = yes |
857 | +link_in_boot = no |
858 | +postinst_hook = $updategrub |
859 | +postrm_hook = $updategrub |
860 | +do_bootloader = no |
861 | |
862 | === added file 'VMBuilder/plugins/debian/templates/locale.tmpl' |
863 | --- VMBuilder/plugins/debian/templates/locale.tmpl 1970-01-01 00:00:00 +0000 |
864 | +++ VMBuilder/plugins/debian/templates/locale.tmpl 2009-06-02 11:01:44 +0000 |
865 | @@ -0,0 +1,1 @@ |
866 | +LANG="$lang" |
867 | |
868 | === added file 'VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl' |
869 | --- VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl 1970-01-01 00:00:00 +0000 |
870 | +++ VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl 2009-06-02 11:01:44 +0000 |
871 | @@ -0,0 +1,18 @@ |
872 | +#!/bin/sh |
873 | + |
874 | +while true; do |
875 | + case "$1" in |
876 | + -*) |
877 | + shift |
878 | + ;; |
879 | + makedev) |
880 | + exit 0 |
881 | + ;; |
882 | + x11-common) |
883 | + exit 0 |
884 | + ;; |
885 | + *) |
886 | + exit 101 |
887 | + ;; |
888 | + esac |
889 | +done |
890 | |
891 | === added file 'VMBuilder/plugins/debian/templates/sources.list.tmpl' |
892 | --- VMBuilder/plugins/debian/templates/sources.list.tmpl 1970-01-01 00:00:00 +0000 |
893 | +++ VMBuilder/plugins/debian/templates/sources.list.tmpl 2009-06-04 12:26:50 +0000 |
894 | @@ -0,0 +1,6 @@ |
895 | +deb $mirror $suite #slurp |
896 | +#echo ' '.join($components) |
897 | + |
898 | +deb $security_mirror $suite/updates #slurp |
899 | +#echo ' '.join($components) |
900 | + |
901 | |
902 | === added file 'VMBuilder/plugins/debian/templates/sudoers.tmpl' |
903 | --- VMBuilder/plugins/debian/templates/sudoers.tmpl 1970-01-01 00:00:00 +0000 |
904 | +++ VMBuilder/plugins/debian/templates/sudoers.tmpl 2009-06-03 09:40:36 +0000 |
905 | @@ -0,0 +1,33 @@ |
906 | +# sudoers file. |
907 | +# |
908 | +# This file MUST be edited with the 'visudo' command as root. |
909 | +# Failure to use 'visudo' may result in syntax or file permission errors |
910 | +# that prevent sudo from running. |
911 | +# |
912 | +# See the sudoers man page for the details on how to write a sudoers file. |
913 | +# |
914 | + |
915 | +# Defaults syslog=auth, secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" |
916 | + |
917 | +# Host alias specification |
918 | + |
919 | +# User alias specification |
920 | + |
921 | +# Cmnd alias specification |
922 | + |
923 | +# Defaults specification |
924 | + |
925 | +# Runas alias specification |
926 | + |
927 | +# User privilege specification |
928 | +root ALL=(ALL) ALL |
929 | + |
930 | +# Uncomment to allow people in group wheel to run all commands |
931 | +# %wheel ALL=(ALL) ALL |
932 | + |
933 | +# Same thing without a password |
934 | +# %wheel ALL=(ALL) NOPASSWD: ALL |
935 | + |
936 | +# Samples |
937 | +# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom |
938 | +# %users localhost=/sbin/shutdown -h now |
939 | |
940 | === modified file 'VMBuilder/plugins/ubuntu/dapper.py' |
941 | --- VMBuilder/plugins/ubuntu/dapper.py 2009-05-07 21:00:20 +0000 |
942 | +++ VMBuilder/plugins/ubuntu/dapper.py 2009-06-02 10:32:59 +0000 |
943 | @@ -20,12 +20,12 @@ |
944 | import glob |
945 | import logging |
946 | import os |
947 | -import suite |
948 | import shutil |
949 | import socket |
950 | import tempfile |
951 | import VMBuilder |
952 | import VMBuilder.disk as disk |
953 | +import VMBuilder.suite as suite |
954 | from VMBuilder.util import run_cmd |
955 | |
956 | class Dapper(suite.Suite): |
957 | |
958 | === modified file 'VMBuilder/plugins/ubuntu/edgy.py' |
959 | --- VMBuilder/plugins/ubuntu/edgy.py 2009-05-04 13:08:30 +0000 |
960 | +++ VMBuilder/plugins/ubuntu/edgy.py 2009-06-02 10:32:59 +0000 |
961 | @@ -18,10 +18,10 @@ |
962 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
963 | # |
964 | import logging |
965 | -import suite |
966 | import shutil |
967 | import os |
968 | import VMBuilder.disk as disk |
969 | +import VMBuilder.suite as suite |
970 | from VMBuilder.util import run_cmd |
971 | from VMBuilder.plugins.ubuntu.dapper import Dapper |
972 | |
973 | |
974 | === modified file 'VMBuilder/plugins/ubuntu/feisty.py' |
975 | --- VMBuilder/plugins/ubuntu/feisty.py 2008-08-29 22:14:45 +0000 |
976 | +++ VMBuilder/plugins/ubuntu/feisty.py 2009-06-02 10:32:59 +0000 |
977 | @@ -18,8 +18,8 @@ |
978 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
979 | # |
980 | import logging |
981 | -import suite |
982 | import VMBuilder.disk as disk |
983 | +import VMBuilder.suite as suite |
984 | from VMBuilder.util import run_cmd |
985 | from VMBuilder.plugins.ubuntu.edgy import Edgy |
986 | |
987 | |
988 | === modified file 'VMBuilder/plugins/ubuntu/gutsy.py' |
989 | --- VMBuilder/plugins/ubuntu/gutsy.py 2008-11-03 18:23:47 +0000 |
990 | +++ VMBuilder/plugins/ubuntu/gutsy.py 2009-06-02 10:32:59 +0000 |
991 | @@ -18,8 +18,8 @@ |
992 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
993 | # |
994 | import logging |
995 | -import suite |
996 | import VMBuilder.disk as disk |
997 | +import VMBuilder.suite as suite |
998 | from VMBuilder.util import run_cmd |
999 | from VMBuilder.plugins.ubuntu.feisty import Feisty |
1000 | |
1001 | |
1002 | === modified file 'VMBuilder/plugins/ubuntu/hardy.py' |
1003 | --- VMBuilder/plugins/ubuntu/hardy.py 2008-11-06 15:36:18 +0000 |
1004 | +++ VMBuilder/plugins/ubuntu/hardy.py 2009-06-02 10:32:59 +0000 |
1005 | @@ -17,7 +17,7 @@ |
1006 | # You should have received a copy of the GNU General Public License |
1007 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1008 | # |
1009 | -import suite |
1010 | +import VMBuilder.suite as suite |
1011 | from VMBuilder.plugins.ubuntu.gutsy import Gutsy |
1012 | |
1013 | class Hardy(Gutsy): |
1014 | |
1015 | === modified file 'VMBuilder/plugins/ubuntu/intrepid.py' |
1016 | --- VMBuilder/plugins/ubuntu/intrepid.py 2009-02-17 14:39:16 +0000 |
1017 | +++ VMBuilder/plugins/ubuntu/intrepid.py 2009-06-02 10:32:59 +0000 |
1018 | @@ -17,9 +17,9 @@ |
1019 | # You should have received a copy of the GNU General Public License |
1020 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1021 | # |
1022 | -import suite |
1023 | import logging |
1024 | import VMBuilder.disk as disk |
1025 | +import VMBuilder.suite as suite |
1026 | from VMBuilder.util import run_cmd |
1027 | from VMBuilder.plugins.ubuntu.hardy import Hardy |
1028 | |
1029 | |
1030 | === modified file 'VMBuilder/plugins/ubuntu/jaunty.py' |
1031 | --- VMBuilder/plugins/ubuntu/jaunty.py 2009-05-07 21:00:20 +0000 |
1032 | +++ VMBuilder/plugins/ubuntu/jaunty.py 2009-06-02 10:32:59 +0000 |
1033 | @@ -17,9 +17,9 @@ |
1034 | # You should have received a copy of the GNU General Public License |
1035 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1036 | # |
1037 | -import suite |
1038 | import logging |
1039 | import VMBuilder.disk as disk |
1040 | +import VMBuilder.suite as suite |
1041 | from VMBuilder.util import run_cmd |
1042 | from VMBuilder.plugins.ubuntu.intrepid import Intrepid |
1043 | |
1044 | |
1045 | === modified file 'VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl' |
1046 | --- VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl 2009-04-25 14:45:26 +0000 |
1047 | +++ VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl 2009-06-04 23:13:01 +0000 |
1048 | @@ -12,12 +12,14 @@ |
1049 | |
1050 | |
1051 | #if $os_type == "ubuntu" |
1052 | -os_type = "Ubuntu" |
1053 | +os_type="Ubuntu" |
1054 | +#elif $os_type == "debian" |
1055 | +os_type="Debian" |
1056 | #else |
1057 | -os_type = "Other" |
1058 | +os_type="Unknown" |
1059 | #end if |
1060 | |
1061 | -disk_path = "#echo os.path.abspath(os.path.dirname($vm_disks[0]))/"# |
1062 | +disk_path = "#echo os.path.abspath(os.path.dirname($vm_disks[0]))#/" |
1063 | |
1064 | |
1065 | VBoxManage createvm -name $vm_name -ostype \$os_type -register |
1066 | @@ -54,7 +56,7 @@ |
1067 | #end if |
1068 | |
1069 | #if $ip |
1070 | -#if $ip == dhcp |
1071 | +#if $ip == "dhcp" |
1072 | VBoxManage modifyvm $vm_name -nic1 nat |
1073 | #else |
1074 | VBoxManage modifyvm $vm_name -nic1 intnet |
1075 | |
1076 | === modified file 'VMBuilder/plugins/virtualbox/vm.py' |
1077 | --- VMBuilder/plugins/virtualbox/vm.py 2009-05-05 08:21:10 +0000 |
1078 | +++ VMBuilder/plugins/virtualbox/vm.py 2009-06-04 23:13:42 +0000 |
1079 | @@ -19,14 +19,11 @@ |
1080 | # |
1081 | |
1082 | import os |
1083 | -import os.path |
1084 | import stat |
1085 | -import VMBuilder |
1086 | -from VMBuilder import register_hypervisor, Hypervisor, VMBuilderUserError |
1087 | -from VMBuilder.disk import vbox_manager_path |
1088 | import VMBuilder.hypervisor |
1089 | +from VMBuilder import register_hypervisor |
1090 | |
1091 | -class VirtualBox(Hypervisor): |
1092 | +class VirtualBox(VMBuilder.hypervisor.Hypervisor): |
1093 | preferred_storage = VMBuilder.hypervisor.STORAGE_DISK_IMAGE |
1094 | needs_bootloader = True |
1095 | name = 'VirtualBox' |
1096 | |
1097 | === renamed file 'VMBuilder/plugins/ubuntu/suite.py' => 'VMBuilder/suite.py' |
1098 | === modified file 'VMBuilder/vm.py' |
1099 | --- VMBuilder/vm.py 2009-05-07 14:09:08 +0000 |
1100 | +++ VMBuilder/vm.py 2009-06-04 01:11:24 +0000 |
1101 | @@ -301,7 +301,7 @@ |
1102 | if (ipclass > 0) and (ipclass <= 127): |
1103 | mask = 0xFF |
1104 | elif (ipclass > 128) and (ipclass < 192): |
1105 | - mask = OxFFFF |
1106 | + mask = 0xFFFF |
1107 | elif (ipclass < 224): |
1108 | mask = 0xFFFFFF |
1109 | else: |
1110 | |
1111 | === added file 'debian-vm-builder' |
1112 | --- debian-vm-builder 1970-01-01 00:00:00 +0000 |
1113 | +++ debian-vm-builder 2009-06-03 14:54:47 +0000 |
1114 | @@ -0,0 +1,29 @@ |
1115 | +#!/usr/bin/python |
1116 | +# |
1117 | +# Uncomplicated VM Builder |
1118 | +# Copyright (C) 2007-2008 Canonical Ltd. |
1119 | +# |
1120 | +# See AUTHORS for list of contributors |
1121 | +# |
1122 | +# This program is free software: you can redistribute it and/or modify |
1123 | +# it under the terms of the GNU General Public License as published by |
1124 | +# the Free Software Foundation, either version 3 of the License, or |
1125 | +# (at your option) any later version. |
1126 | +# |
1127 | +# This program is distributed in the hope that it will be useful, |
1128 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1129 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1130 | +# GNU General Public License for more details. |
1131 | +# |
1132 | +# You should have received a copy of the GNU General Public License |
1133 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1134 | +# |
1135 | + |
1136 | +#import sys |
1137 | +#import os |
1138 | +#sys.path += [os.getcwd()] |
1139 | + |
1140 | +import VMBuilder |
1141 | + |
1142 | +VMBuilder.set_frontend('ubuntu-vm-builder') |
1143 | +VMBuilder.run() |
1144 | |
1145 | === added file 'debian-vm-builder.1' |
1146 | --- debian-vm-builder.1 1970-01-01 00:00:00 +0000 |
1147 | +++ debian-vm-builder.1 2009-06-03 14:54:47 +0000 |
1148 | @@ -0,0 +1,7 @@ |
1149 | +.TH DEBIAN-VM-BUILDER 1 "Jun 2009" |
1150 | +.SH NAME |
1151 | +debian-vm-builder \- builds virtual machines from the command line |
1152 | +.SH DESCRIPTION |
1153 | +debian-vm-builder is now a wrapper to vmbuilder (part of the python-vm-builder package) and is only maintained for compatibility wih previous scripts. Please see the vmbuilder man page for more information or run |
1154 | +.B vmbuilder <hypervisor> <distro> --help |
1155 | +for a full list of options. |
1156 | |
1157 | === modified file 'setup.py' |
1158 | --- setup.py 2009-02-23 14:04:47 +0000 |
1159 | +++ setup.py 2009-06-03 20:46:16 +0000 |
1160 | @@ -1,3 +1,5 @@ |
1161 | +#!/usr/bin/python |
1162 | + |
1163 | from distutils.core import setup |
1164 | import VMBuilder.plugins |
1165 | from glob import glob |
I've added support for Debian Etch and fixed a lot of other bugs while doing so. Lenny and testing/unstable will follow soon. Had to start with Etch as I needed it for a customer...