Merge lp:~josephbisch/vmbuilder/debian into lp:vmbuilder
- debian
- Merge into 0.12
Proposed by
Joseph Bisch
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Serge Hallyn | ||||
Approved revision: | 491 | ||||
Merged at revision: | 491 | ||||
Proposed branch: | lp:~josephbisch/vmbuilder/debian | ||||
Merge into: | lp:vmbuilder | ||||
Diff against target: |
1147 lines (+1021/-0) 25 files modified
VMBuilder/plugins/debian/__init__.py (+19/-0) VMBuilder/plugins/debian/distro.py (+286/-0) VMBuilder/plugins/debian/etch.py (+23/-0) VMBuilder/plugins/debian/jessie.py (+23/-0) VMBuilder/plugins/debian/lenny.py (+23/-0) VMBuilder/plugins/debian/potato.py (+387/-0) VMBuilder/plugins/debian/sarge.py (+23/-0) VMBuilder/plugins/debian/squeeze.py (+23/-0) VMBuilder/plugins/debian/stretch.py (+23/-0) VMBuilder/plugins/debian/suite.py (+28/-0) VMBuilder/plugins/debian/templates/devicemap.tmpl (+3/-0) VMBuilder/plugins/debian/templates/etc_hosts.tmpl (+10/-0) VMBuilder/plugins/debian/templates/initctl-stub.tmpl (+3/-0) VMBuilder/plugins/debian/templates/interfaces.tmpl (+22/-0) VMBuilder/plugins/debian/templates/is-compat-env.tmpl (+3/-0) VMBuilder/plugins/debian/templates/kernelimg.tmpl (+8/-0) VMBuilder/plugins/debian/templates/locale.tmpl (+1/-0) VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl (+18/-0) VMBuilder/plugins/debian/templates/sources.list.tmpl (+8/-0) VMBuilder/plugins/debian/templates/sudoers.tmpl (+23/-0) VMBuilder/plugins/debian/templates/timezone.tmpl (+1/-0) VMBuilder/plugins/debian/templates/upstart.tmpl (+16/-0) VMBuilder/plugins/debian/templates/xen-ld-so-conf.tmpl (+1/-0) VMBuilder/plugins/debian/wheezy.py (+23/-0) VMBuilder/plugins/debian/woody.py (+23/-0) |
||||
To merge this branch: | bzr merge lp:~josephbisch/vmbuilder/debian | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Serge Hallyn | Approve | ||
Review via email: mp+275791@code.launchpad.net |
Commit message
Description of the change
Add Debian guest support. Initial support. Only KVM Jessie and Stretch tested.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'VMBuilder/plugins/debian' |
2 | === added file 'VMBuilder/plugins/debian/__init__.py' |
3 | --- VMBuilder/plugins/debian/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ VMBuilder/plugins/debian/__init__.py 2015-10-27 01:09:47 +0000 |
5 | @@ -0,0 +1,19 @@ |
6 | +# |
7 | +# Uncomplicated VM Builder |
8 | +# Copyright (C) 2007-2009 Canonical Ltd. |
9 | +# |
10 | +# See AUTHORS for list of contributors |
11 | +# |
12 | +# This program is free software: you can redistribute it and/or modify |
13 | +# it under the terms of the GNU General Public License version 3, as |
14 | +# published by the Free Software Foundation. |
15 | +# |
16 | +# This program is distributed in the hope that it will be useful, |
17 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | +# GNU General Public License for more details. |
20 | +# |
21 | +# You should have received a copy of the GNU General Public License |
22 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | +# |
24 | +import distro |
25 | |
26 | === added file 'VMBuilder/plugins/debian/distro.py' |
27 | --- VMBuilder/plugins/debian/distro.py 1970-01-01 00:00:00 +0000 |
28 | +++ VMBuilder/plugins/debian/distro.py 2015-10-27 01:09:47 +0000 |
29 | @@ -0,0 +1,286 @@ |
30 | +# |
31 | +# Uncomplicated VM Builder |
32 | +# Copyright (C) 2007-2010 Canonical Ltd. |
33 | +# |
34 | +# See AUTHORS for list of contributors |
35 | +# |
36 | +# This program is free software: you can redistribute it and/or modify |
37 | +# it under the terms of the GNU General Public License version 3, as |
38 | +# published by the Free Software Foundation. |
39 | +# |
40 | +# This program is distributed in the hope that it will be useful, |
41 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
42 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
43 | +# GNU General Public License for more details. |
44 | +# |
45 | +# You should have received a copy of the GNU General Public License |
46 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
47 | +# |
48 | +import logging |
49 | +import os |
50 | +import shutil |
51 | +import stat |
52 | +import VMBuilder |
53 | +from VMBuilder import register_distro, Distro |
54 | +from VMBuilder.util import run_cmd |
55 | +from VMBuilder.exception import VMBuilderUserError, VMBuilderException |
56 | + |
57 | +class Debian(Distro): |
58 | + name = 'Debian' |
59 | + arg = 'debian' |
60 | + suites = ['potato', 'woody', 'sarge', 'etch', 'lenny', |
61 | + 'squeeze', 'wheezy', 'jessie', 'stretch' ] |
62 | + |
63 | + # Maps host arch to valid guest archs |
64 | + valid_archs = { 'amd64' : ['amd64', 'i386' ], |
65 | + 'i386' : [ 'i386' ] } |
66 | + |
67 | + xen_kernel = '' |
68 | + |
69 | + def register_options(self): |
70 | + group = self.setting_group('Package options') |
71 | + group.add_setting('addpkg', type='list', metavar='PKG', help='Install PKG into the guest (can be specified multiple times).') |
72 | + group.add_setting('removepkg', type='list', metavar='PKG', help='Remove PKG from the guest (can be specified multiple times)') |
73 | + group.add_setting('seedfile', metavar="SEEDFILE", help='Seed the debconf database with the contents of this seed file before installing packages') |
74 | + |
75 | + group = self.setting_group('General OS options') |
76 | + self.host_arch = run_cmd('dpkg', '--print-architecture').rstrip() |
77 | + group.add_setting('arch', extra_args=['-a'], default=self.host_arch, help='Specify the target architecture. Valid options: amd64 i386 (defaults to host arch)') |
78 | + group.add_setting('hostname', default='debian', help='Set NAME as the hostname of the guest. Default: debian. Also uses this name as the VM name.') |
79 | + |
80 | + group = self.setting_group('Installation options') |
81 | + group.add_setting('suite', default='jessie', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites)) |
82 | + group.add_setting('flavour', extra_args=['--kernel-flavour'], help='Kernel flavour to use. Default and valid options depend on architecture and suite') |
83 | + group.add_setting('variant', metavar='VARIANT', help='Passed to debootstrap --variant flag; use minbase, buildd, or fakechroot.') |
84 | + group.add_setting('debootstrap-tarball', metavar='FILE', help='Passed to debootstrap --unpack-tarball flag.') |
85 | + group.add_setting('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.') |
86 | + group.add_setting('mirror', metavar='URL', help='Use Debian mirror at URL instead of the default, which is http://ftp.debian.org/debian for official arches and http://ports.ubuntu.com/ubuntu-ports otherwise') |
87 | + group.add_setting('proxy', metavar='URL', help='Use proxy at URL for cached packages') |
88 | + group.add_setting('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') |
89 | + group.add_setting('security-mirror', metavar='URL', help='Use Debian security mirror at URL instead of the default, which is http://security.debian.org/debian-security.') |
90 | + group.add_setting('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') |
91 | + group.add_setting('components', type='list', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).') |
92 | + group.add_setting('lang', metavar='LANG', default=get_locale(), help='Set the locale to LANG [default: %default]') |
93 | + group.add_setting('timezone', metavar='TZ', default='UTC', help='Set the timezone to TZ in the vm. [default: %default]') |
94 | + |
95 | + group = self.setting_group('Settings for the initial user') |
96 | + group.add_setting('user', default='debian', help='Username of initial user [default: %default]') |
97 | + group.add_setting('name', default='Debian', help='Full name of initial user [default: %default]') |
98 | + group.add_setting('pass', default='debian', help='Password of initial user [default: %default]') |
99 | + group.add_setting('rootpass', help='Initial root password (WARNING: this has strong security implications).') |
100 | + group.add_setting('uid', type='int', help='Initial UID value.') |
101 | + group.add_setting('gid', help='Initial GID value.') |
102 | + group.add_setting('lock-user', type='bool', default=False, help='Lock the initial user [default: %default]') |
103 | + |
104 | + group = self.setting_group('Other options') |
105 | + group.add_setting('ssh-key', metavar='PATH', help='Add PATH to root\'s ~/.ssh/authorized_keys (WARNING: this has strong security implications).') |
106 | + group.add_setting('ssh-user-key', help='Add PATH to the user\'s ~/.ssh/authorized_keys.') |
107 | + group.add_setting('manifest', metavar='PATH', help='If passed, a manifest will be written to PATH') |
108 | + |
109 | + def set_defaults(self): |
110 | + self.set_setting_default('mirror', 'http://ftp.debian.org/debian') |
111 | + self.set_setting_default('security-mirror', 'http://security.debian.org/debian-security') |
112 | + |
113 | + self.set_setting_default('components', ['main']) |
114 | + |
115 | + def preflight_check(self): |
116 | + """While not all of these are strictly checks, their failure would inevitably |
117 | + lead to failure, and since we can check them before we start setting up disk |
118 | + and whatnot, we might as well go ahead an do this now.""" |
119 | + |
120 | + suite = self.get_setting('suite') |
121 | + if not suite in self.suites: |
122 | + raise VMBuilderUserError('Invalid suite: "%s". Valid suites are: %s' % (suite, ' '.join(self.suites))) |
123 | + |
124 | + modname = 'VMBuilder.plugins.debian.%s' % (suite, ) |
125 | + mod = __import__(modname, fromlist=[suite]) |
126 | + self.suite = getattr(mod, suite.capitalize())(self) |
127 | + |
128 | + arch = self.get_setting('arch') |
129 | + if arch not in self.valid_archs[self.host_arch] or \ |
130 | + not self.suite.check_arch_validity(arch): |
131 | + raise VMBuilderUserError('%s is not a valid architecture. Valid architectures are: %s' % (arch, |
132 | + ' '.join(self.valid_archs[self.host_arch]))) |
133 | + |
134 | + components = self.get_setting('components') |
135 | + if not components: |
136 | + self.set_config_value_list = ['main', 'contrib'] |
137 | + else: |
138 | + if type(components) is str: |
139 | + self.vm.components = self.vm.components.split(',') |
140 | + |
141 | + self.context.virtio_net = self.use_virtio_net() |
142 | + |
143 | + # check if the seedfile exists if one is to be used |
144 | + seedfile = self.context.get_setting('seedfile') |
145 | + if seedfile and not os.path.exists(seedfile): |
146 | + raise VMBuilderUserError("Seedfile '%s' does not exist" % seedfile) |
147 | + |
148 | + lang = self.get_setting('lang') |
149 | + |
150 | +# FIXME |
151 | +# if getattr(self.vm, 'ec2', False): |
152 | +# self.get_ec2_kernel() |
153 | +# self.get_ec2_ramdisk() |
154 | +# self.apply_ec2_settings() |
155 | + |
156 | + def bootstrap(self): |
157 | + self.suite.debootstrap() |
158 | + self.suite.pre_install() |
159 | + |
160 | + def configure_os(self): |
161 | + self.suite.install_apt_proxy() |
162 | + self.suite.install_sources_list() |
163 | + self.suite.create_devices() |
164 | + self.suite.prevent_daemons_starting() |
165 | + self.suite.mount_dev_proc() |
166 | + self.suite.install_extras() |
167 | + self.suite.create_initial_user() |
168 | + self.suite.install_authorized_keys() |
169 | + self.suite.set_timezone() |
170 | + self.suite.set_locale() |
171 | + self.suite.update() |
172 | + self.suite.install_sources_list(final=True) |
173 | + self.suite.run_in_target('apt-get', 'clean'); |
174 | + self.suite.unmount_volatile() |
175 | + self.suite.unmount_proc() |
176 | + self.suite.unmount_dev_pts() |
177 | + self.suite.unmount_dev() |
178 | + self.suite.unprevent_daemons_starting() |
179 | + self.suite.create_manifest() |
180 | + |
181 | + def configure_networking(self, nics): |
182 | + self.suite.config_host_and_domainname() |
183 | + self.suite.config_interfaces(nics) |
184 | + |
185 | + def configure_mounting(self, disks, filesystems): |
186 | + self.suite.install_fstab(disks, filesystems) |
187 | + |
188 | + def install(self, destdir): |
189 | + self.destdir = destdir |
190 | + self.suite.install(destdir) |
191 | + |
192 | + def install_vmbuilder_log(self, logfile, rootdir): |
193 | + self.suite.install_vmbuilder_log(logfile, rootdir) |
194 | + |
195 | + def post_mount(self, fs): |
196 | + self.suite.post_mount(fs) |
197 | + |
198 | + def use_virtio_net(self): |
199 | + return self.suite.virtio_net |
200 | + |
201 | + def install_bootloader_cleanup(self, chroot_dir): |
202 | + self.context.cancel_cleanup(self.install_bootloader_cleanup) |
203 | + tmpdir = '%s/tmp/vmbuilder-grub' % chroot_dir |
204 | + for disk in os.listdir(tmpdir): |
205 | + if disk != 'device.map': |
206 | + run_cmd('umount', os.path.join(tmpdir, disk)) |
207 | + shutil.rmtree(tmpdir) |
208 | + |
209 | + def install_kernel(self, destdir): |
210 | + self.suite.install_kernel(destdir) |
211 | + |
212 | + def install_bootloader(self, chroot_dir, disks): |
213 | + root_dev = VMBuilder.disk.bootpart(disks).get_grub_id() |
214 | + |
215 | + tmpdir = '/tmp/vmbuilder-grub' |
216 | + os.makedirs('%s%s' % (chroot_dir, tmpdir)) |
217 | + self.context.add_clean_cb(self.install_bootloader_cleanup) |
218 | + devmapfile = os.path.join(tmpdir, 'device.map') |
219 | + devmap = open('%s%s' % (chroot_dir, devmapfile), 'w') |
220 | + for (disk, id) in zip(disks, range(len(disks))): |
221 | + new_filename = os.path.join(tmpdir, os.path.basename(disk.filename)) |
222 | + open('%s%s' % (chroot_dir, new_filename), 'w').close() |
223 | + run_cmd('mount', '--bind', disk.filename, '%s%s' % (chroot_dir, new_filename)) |
224 | + st = os.stat(disk.filename) |
225 | + if stat.S_ISBLK(st.st_mode): |
226 | + for (part, part_id) in zip(disk.partitions, range(len(disk.partitions))): |
227 | + part_mountpnt = '%s%s%d' % (chroot_dir, new_filename, part_id+1) |
228 | + open(part_mountpnt, 'w').close() |
229 | + run_cmd('mount', '--bind', part.filename, part_mountpnt) |
230 | + devmap.write("(hd%d) %s\n" % (id, new_filename)) |
231 | + devmap.close() |
232 | + run_cmd('cat', '%s%s' % (chroot_dir, devmapfile)) |
233 | + self.suite.install_grub(chroot_dir) |
234 | + self.run_in_target('grub', '--device-map=%s' % devmapfile, '--batch', stdin='''root %s |
235 | +setup (hd0) |
236 | +EOT''' % root_dev) |
237 | + self.suite.install_menu_lst(disks) |
238 | + self.install_bootloader_cleanup(chroot_dir) |
239 | + |
240 | + def xen_kernel_version(self): |
241 | + if self.suite.xen_kernel_flavour: |
242 | + # if this is ec2, do not call rmadison. |
243 | + # this could be replaced with a method to get most recent |
244 | + # stable kernel, but really, this is not used at all for ec2 |
245 | + if hasattr(self.context, 'ec2') and self.context.ec2: |
246 | + logging.debug("selecting ec2 kernel") |
247 | + self.xen_kernel = "2.6.ec2-kernel" |
248 | + return self.xen_kernel |
249 | + if not self.xen_kernel: |
250 | + rmad = run_cmd('rmadison', 'linux-image-%s' % self.suite.xen_kernel_flavour) |
251 | + version = ['0', '0','0', '0'] |
252 | + |
253 | + for line in rmad.splitlines(): |
254 | + sline = line.split('|') |
255 | + |
256 | + if sline[2].strip().startswith(self.context.get_setting('suite')): |
257 | + vt = sline[1].strip().split('.') |
258 | + for i in range(4): |
259 | + if int(vt[i]) > int(version[i]): |
260 | + version = vt |
261 | + break |
262 | + |
263 | + if version[0] == '0': |
264 | + raise VMBuilderException('Something is wrong, no valid xen kernel for the suite %s found by rmadison' % self.context.suite) |
265 | + |
266 | + self.xen_kernel = '%s.%s.%s-%s' % (version[0],version[1],version[2],version[3]) |
267 | + return self.xen_kernel |
268 | + else: |
269 | + raise VMBuilderUserError('There is no valid xen kernel for the suite selected.') |
270 | + |
271 | + def xen_kernel_initrd_path(self, which): |
272 | + path = '/boot/%s-%s-%s' % (which, self.xen_kernel_version(), self.suite.xen_kernel_flavour) |
273 | + return path |
274 | + |
275 | + def xen_kernel_path(self): |
276 | + return self.xen_kernel_initrd_path('kernel') |
277 | + |
278 | + def xen_ramdisk_path(self): |
279 | + return self.xen_kernel_initrd_path('ramdisk') |
280 | + |
281 | + def get_ec2_kernel(self): |
282 | + if self.suite.ec2_kernel_info: |
283 | + return self.suite.ec2_kernel_info[self.context.arch] |
284 | + else: |
285 | + raise VMBuilderUserError('EC2 is not supported for the suite selected') |
286 | + |
287 | + def get_ec2_ramdisk(self): |
288 | + if self.suite.ec2_ramdisk_info: |
289 | + return self.suite.ec2_ramdisk_info[self.context.arch] |
290 | + else: |
291 | + raise VMBuilderUserError('EC2 is not supported for the suite selected') |
292 | + |
293 | + def disable_hwclock_access(self): |
294 | + return self.suite.disable_hwclock_access() |
295 | + |
296 | + def apply_ec2_settings(self): |
297 | + return self.suite.apply_ec2_settings() |
298 | + |
299 | + def has_256_bit_inode_ext3_support(self): |
300 | + return self.suite.has_256_bit_inode_ext3_support() |
301 | + |
302 | + def preferred_filesystem(self): |
303 | + return self.suite.preferred_filesystem |
304 | + |
305 | +def get_locale(): |
306 | + lang = os.getenv('LANG') |
307 | + if lang is None: |
308 | + return 'C' |
309 | + # People's $LANG looks different since lucid, but locale-gen still |
310 | + # wants the old format. |
311 | + if lang.endswith('utf8'): |
312 | + return lang[:-4] + 'UTF-8' |
313 | + return lang |
314 | + |
315 | +register_distro(Debian) |
316 | |
317 | === added file 'VMBuilder/plugins/debian/etch.py' |
318 | --- VMBuilder/plugins/debian/etch.py 1970-01-01 00:00:00 +0000 |
319 | +++ VMBuilder/plugins/debian/etch.py 2015-10-27 01:09:47 +0000 |
320 | @@ -0,0 +1,23 @@ |
321 | +# |
322 | +# Uncomplicated VM Builder |
323 | +# Copyright (C) 2007-2010 Canonical Ltd. |
324 | +# |
325 | +# See AUTHORS for list of contributors |
326 | +# |
327 | +# This program is free software: you can redistribute it and/or modify |
328 | +# it under the terms of the GNU General Public License version 3, as |
329 | +# published by the Free Software Foundation. |
330 | +# |
331 | +# This program is distributed in the hope that it will be useful, |
332 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
333 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
334 | +# GNU General Public License for more details. |
335 | +# |
336 | +# You should have received a copy of the GNU General Public License |
337 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
338 | +# |
339 | +import time |
340 | +from VMBuilder.plugins.debian.sarge import Sarge |
341 | + |
342 | +class Etch(Sarge): |
343 | + pass |
344 | |
345 | === added file 'VMBuilder/plugins/debian/jessie.py' |
346 | --- VMBuilder/plugins/debian/jessie.py 1970-01-01 00:00:00 +0000 |
347 | +++ VMBuilder/plugins/debian/jessie.py 2015-10-27 01:09:47 +0000 |
348 | @@ -0,0 +1,23 @@ |
349 | +# |
350 | +# Uncomplicated VM Builder |
351 | +# Copyright (C) 2007-2010 Canonical Ltd. |
352 | +# |
353 | +# See AUTHORS for list of contributors |
354 | +# |
355 | +# This program is free software: you can redistribute it and/or modify |
356 | +# it under the terms of the GNU General Public License version 3, as |
357 | +# published by the Free Software Foundation. |
358 | +# |
359 | +# This program is distributed in the hope that it will be useful, |
360 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
361 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
362 | +# GNU General Public License for more details. |
363 | +# |
364 | +# You should have received a copy of the GNU General Public License |
365 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
366 | +# |
367 | +import time |
368 | +from VMBuilder.plugins.debian.wheezy import Wheezy |
369 | + |
370 | +class Jessie(Wheezy): |
371 | + pass |
372 | |
373 | === added file 'VMBuilder/plugins/debian/lenny.py' |
374 | --- VMBuilder/plugins/debian/lenny.py 1970-01-01 00:00:00 +0000 |
375 | +++ VMBuilder/plugins/debian/lenny.py 2015-10-27 01:09:47 +0000 |
376 | @@ -0,0 +1,23 @@ |
377 | +# |
378 | +# Uncomplicated VM Builder |
379 | +# Copyright (C) 2007-2010 Canonical Ltd. |
380 | +# |
381 | +# See AUTHORS for list of contributors |
382 | +# |
383 | +# This program is free software: you can redistribute it and/or modify |
384 | +# it under the terms of the GNU General Public License version 3, as |
385 | +# published by the Free Software Foundation. |
386 | +# |
387 | +# This program is distributed in the hope that it will be useful, |
388 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
389 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
390 | +# GNU General Public License for more details. |
391 | +# |
392 | +# You should have received a copy of the GNU General Public License |
393 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
394 | +# |
395 | +import time |
396 | +from VMBuilder.plugins.debian.etch import Etch |
397 | + |
398 | +class Lenny(Etch): |
399 | + disk_prefix = 'sd' |
400 | |
401 | === added file 'VMBuilder/plugins/debian/potato.py' |
402 | --- VMBuilder/plugins/debian/potato.py 1970-01-01 00:00:00 +0000 |
403 | +++ VMBuilder/plugins/debian/potato.py 2015-10-27 01:09:47 +0000 |
404 | @@ -0,0 +1,387 @@ |
405 | +# |
406 | +# Uncomplicated VM Builder |
407 | +# Copyright (C) 2007-2010 Canonical Ltd. |
408 | +# |
409 | +# See AUTHORS for list of contributors |
410 | +# |
411 | +# This program is free software: you can redistribute it and/or modify |
412 | +# it under the terms of the GNU General Public License version 3, as |
413 | +# published by the Free Software Foundation. |
414 | +# |
415 | +# This program is distributed in the hope that it will be useful, |
416 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
417 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
418 | +# GNU General Public License for more details. |
419 | +# |
420 | +# You should have received a copy of the GNU General Public License |
421 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
422 | +# |
423 | +import glob |
424 | +import logging |
425 | +import os |
426 | +import suite |
427 | +import shutil |
428 | +import tempfile |
429 | +import VMBuilder.disk as disk |
430 | +from VMBuilder.util import run_cmd |
431 | +from VMBuilder.exception import VMBuilderException |
432 | + |
433 | +class Potato(suite.Suite): |
434 | + updategrub = "/usr/sbin/update-grub" |
435 | + grubroot = "/usr/lib/grub" |
436 | + valid_flavours = { 'i386' : ['486', '586', '686-pae'], |
437 | + 'amd64' : ['amd64']} |
438 | + default_flavour = { 'i386' : '686-pae', 'amd64' : 'amd64' } |
439 | + disk_prefix = 'hd' |
440 | + xen_kernel_flavour = None |
441 | + virtio_net = False |
442 | + chpasswd_cmd = [ 'chpasswd', '--md5' ] |
443 | + preferred_filesystem = 'ext3' |
444 | + |
445 | + def pre_install(self): |
446 | + pass |
447 | + |
448 | + def check_kernel_flavour(self, arch, flavour): |
449 | + return flavour in self.valid_flavours[arch] |
450 | + |
451 | + def check_arch_validity(self, arch): |
452 | + return arch in self.valid_flavours.keys() |
453 | + |
454 | + def install(self, destdir): |
455 | + raise VMBuilderException('Do not call this method!') |
456 | + |
457 | + # These are still missing after the refactoring. |
458 | + logging.debug("Creating device.map") |
459 | + self.install_device_map() |
460 | + |
461 | + logging.debug("Copy host settings") |
462 | + self.copy_settings() |
463 | + |
464 | + if hasattr(self.context, 'ec2') and self.context.ec2: |
465 | + logging.debug("Configuring for ec2") |
466 | + self.install_ec2() |
467 | + |
468 | + def create_manifest(self): |
469 | + manifest = self.context.get_setting('manifest') |
470 | + if manifest: |
471 | + logging.debug("Creating manifest") |
472 | + manifest_contents = self.run_in_target('dpkg-query', '-W', '--showformat=${Package} ${Version}\n') |
473 | + fp = open(manifest, 'w') |
474 | + fp.write(manifest_contents) |
475 | + fp.close |
476 | + self.call_hook('fix_ownership', manifest) |
477 | + |
478 | + def update(self): |
479 | + self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade', |
480 | + env={ 'DEBIAN_FRONTEND' : 'noninteractive' }) |
481 | + |
482 | + def install_authorized_keys(self): |
483 | + ssh_key = self.context.get_setting('ssh-key') |
484 | + if ssh_key: |
485 | + os.mkdir('%s/root/.ssh' % self.context.chroot_dir, 0700) |
486 | + shutil.copy(ssh_key, '%s/root/.ssh/authorized_keys' % self.context.chroot_dir) |
487 | + os.chmod('%s/root/.ssh/authorized_keys' % self.context.chroot_dir, 0644) |
488 | + |
489 | + user = self.context.get_setting('user') |
490 | + ssh_user_key = self.context.get_setting('ssh-user-key') |
491 | + if ssh_user_key: |
492 | + os.mkdir('%s/home/%s/.ssh' % (self.context.chroot_dir, user), 0700) |
493 | + shutil.copy(ssh_user_key, '%s/home/%s/.ssh/authorized_keys' % (self.context.chroot_dir, user)) |
494 | + os.chmod('%s/home/%s/.ssh/authorized_keys' % (self.context.chroot_dir, user), 0644) |
495 | + self.run_in_target('chown', '-R', '%s:%s' % ((user,)*2), '/home/%s/.ssh/' % (user)) |
496 | + |
497 | + if ssh_user_key or ssh_key: |
498 | + addpkg = self.context.get_setting('addpkg') |
499 | + addpkg += ['openssh-server'] |
500 | + self.context.set_setting('addpkg', addpkg) |
501 | + |
502 | + def mount_dev_proc(self): |
503 | + run_cmd('mount', '--bind', '/dev', '%s/dev' % self.context.chroot_dir) |
504 | + self.context.add_clean_cb(self.unmount_dev) |
505 | + |
506 | + run_cmd('mount', '--bind', '/dev/pts', '%s/dev/pts' % self.context.chroot_dir) |
507 | + self.context.add_clean_cb(self.unmount_dev_pts) |
508 | + |
509 | + self.run_in_target('mount', '-t', 'proc', 'proc', '/proc') |
510 | + self.context.add_clean_cb(self.unmount_proc) |
511 | + |
512 | + def unmount_proc(self): |
513 | + self.context.cancel_cleanup(self.unmount_proc) |
514 | + run_cmd('umount', '%s/proc' % self.context.chroot_dir) |
515 | + |
516 | + def unmount_dev_pts(self): |
517 | + self.context.cancel_cleanup(self.unmount_dev_pts) |
518 | + run_cmd('umount', '%s/dev/pts' % self.context.chroot_dir) |
519 | + |
520 | + def unmount_dev(self): |
521 | + self.context.cancel_cleanup(self.unmount_dev) |
522 | + run_cmd('umount', '%s/dev' % self.context.chroot_dir) |
523 | + |
524 | + def update_passwords(self): |
525 | + # Set the user password, using md5 |
526 | + user = self.context.get_setting('user') |
527 | + passwd = self.context.get_setting('pass') |
528 | + self.run_in_target(stdin=('%s:%s\n' % (user, passwd)), *self.chpasswd_cmd) |
529 | + |
530 | + # Lock root account only if we didn't set the root password |
531 | + rootpass = self.context.get_setting('rootpass') |
532 | + if rootpass: |
533 | + self.run_in_target(stdin=('%s:%s\n' % ('root', rootpass)), *self.chpasswd_cmd) |
534 | + else: |
535 | + self.run_in_target('usermod', '-L', 'root') |
536 | + |
537 | + lock_user = self.context.get_setting('lock-user') |
538 | + if lock_user: |
539 | + logging.info('Locking %s' % (user, )) |
540 | + self.run_in_target('usermod', '-L', user) |
541 | + |
542 | + def create_initial_user(self): |
543 | + uid = self.context.get_setting('uid') |
544 | + name = self.context.get_setting('name') |
545 | + user = self.context.get_setting('user') |
546 | + if uid: |
547 | + self.run_in_target('adduser', '--disabled-password', '--uid', uid, '--gecos', name, user) |
548 | + else: |
549 | + self.run_in_target('adduser', '--disabled-password', '--gecos', name, user) |
550 | + |
551 | + self.run_in_target('addgroup', '--system', 'admin') |
552 | + self.run_in_target('adduser', user, 'admin') |
553 | + |
554 | + self.install_from_template('/etc/sudoers', 'sudoers') |
555 | + for group in ['adm', 'audio', 'cdrom', 'dialout', 'floppy', 'video', 'plugdev', 'dip', 'netdev', 'powerdev', 'lpadmin', 'scanner']: |
556 | + self.run_in_target('adduser', user, group, ignore_fail=True) |
557 | + |
558 | + self.update_passwords() |
559 | + |
560 | + def kernel_name(self): |
561 | + flavour = self.context.get_setting('flavour') |
562 | + arch = self.context.get_setting('arch') |
563 | + return 'linux-image-%s' % (flavour or self.default_flavour[arch],) |
564 | + |
565 | + def config_host_and_domainname(self): |
566 | + hostname = self.context.get_setting('hostname') |
567 | + domain = self.context.get_setting('domain') |
568 | + self.context.install_file('/etc/hostname', hostname) |
569 | + self.install_from_template('/etc/hosts', 'etc_hosts', { 'hostname' : hostname, 'domain' : domain }) |
570 | + |
571 | + def config_interfaces(self, nics): |
572 | + self.install_from_template('/etc/network/interfaces', 'interfaces', |
573 | + { 'ip' : nics[0].type == 'dhcp' and 'dhcp' or nics[0].ip, |
574 | + 'mask' : nics[0].netmask, |
575 | + 'net' : nics[0].network, |
576 | + 'bcast' : nics[0].broadcast, |
577 | + 'gw' : nics[0].gateway, |
578 | + 'dns' : nics[0].dns, |
579 | + 'domain' : self.context.get_setting('domain') }) |
580 | + |
581 | + def unprevent_daemons_starting(self): |
582 | + os.unlink('%s/usr/sbin/policy-rc.d' % self.context.chroot_dir) |
583 | + |
584 | + def prevent_daemons_starting(self): |
585 | + os.chmod(self.install_from_template('/usr/sbin/policy-rc.d', 'nostart-policy-rc.d'), 0755) |
586 | + |
587 | + def seed(self, seedfile): |
588 | + """Seed debconf with the contents of a seedfile""" |
589 | + logging.info('Seeding with "%s"' % seedfile) |
590 | + |
591 | + self.run_in_target('debconf-set-selections', stdin=open(seedfile, 'r').read()) |
592 | + |
593 | + def install_extras(self): |
594 | + seedfile = self.context.get_setting('seedfile') |
595 | + if seedfile: |
596 | + self.seed(seedfile) |
597 | + |
598 | + addpkg = self.context.get_setting('addpkg') |
599 | + removepkg = self.context.get_setting('removepkg') |
600 | + if not addpkg and not removepkg: |
601 | + return |
602 | + |
603 | + cmd = ['apt-get', 'install', '-y', '--force-yes'] |
604 | + cmd += addpkg or [] |
605 | + cmd += ['%s-' % pkg for pkg in removepkg or []] |
606 | + self.run_in_target(env={ 'DEBIAN_FRONTEND' : 'noninteractive' }, *cmd) |
607 | + |
608 | + def unmount_volatile(self): |
609 | + for mntpnt in glob.glob('%s/lib/modules/*/volatile' % self.context.chroot_dir): |
610 | + logging.debug("Unmounting %s" % mntpnt) |
611 | + run_cmd('sleep', '10') |
612 | + run_cmd('umount', mntpnt) |
613 | + |
614 | + def install_menu_lst(self, disks): |
615 | + self.run_in_target(self.updategrub, '-y') |
616 | + self.mangle_grub_menu_lst(disks) |
617 | + self.run_in_target(self.updategrub) |
618 | + self.run_in_target('grub-set-default', '0') |
619 | + |
620 | + def mangle_grub_menu_lst(self, disks): |
621 | + rootdev = disk.rootpart(disks) |
622 | + bootdev = disk.bootpart(disks) |
623 | + run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s rw/g' % rootdev.fs.uuid, '%s/boot/grub/menu.lst' % self.context.chroot_dir) |
624 | + run_cmd('sed', '-ie', 's/^# groot.*/# groot=(hd0,0)/g', '%s/boot/grub/menu.lst' % self.context.chroot_dir) |
625 | + run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % self.context.chroot_dir) |
626 | + |
627 | + def install_sources_list(self, final=False): |
628 | + if final: |
629 | + mirror = updates_mirror = self.context.get_setting('mirror') |
630 | + security_mirror = self.context.get_setting('security-mirror') |
631 | + else: |
632 | + mirror, updates_mirror, security_mirror = self.install_mirrors() |
633 | + |
634 | + components = self.context.get_setting('components') |
635 | + suite = self.context.get_setting('suite') |
636 | + self.install_from_template('/etc/apt/sources.list', 'sources.list', { 'mirror' : mirror, |
637 | + 'security_mirror' : security_mirror, |
638 | + 'updates_mirror' : updates_mirror, |
639 | + 'components' : components, |
640 | + 'suite' : suite }) |
641 | + |
642 | + # If setting up the final mirror, allow apt-get update to fail |
643 | + # (since we might be on a complete different network than the |
644 | + # final vm is going to be on). |
645 | + self.run_in_target('apt-get', 'update', ignore_fail=final) |
646 | + |
647 | + def install_apt_proxy(self): |
648 | + proxy = self.context.get_setting('proxy') |
649 | + if proxy is not None: |
650 | + self.context.install_file('/etc/apt/apt.conf', '// Proxy added by vmbuilder\nAcquire::http { Proxy "%s"; };' % proxy) |
651 | + |
652 | + def fstab(self): |
653 | + retval = '''# /etc/fstab: static file system information. |
654 | +# |
655 | +# <file system> <mount point> <type> <options> <dump> <pass> |
656 | +proc /proc proc defaults 0 0 |
657 | +''' |
658 | + parts = disk.get_ordered_partitions(self.context.disks) |
659 | + for part in parts: |
660 | + 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) |
661 | + return retval |
662 | + |
663 | + def install_device_map(self): |
664 | + self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix }) |
665 | + |
666 | + def debootstrap(self): |
667 | + arch = self.context.get_setting('arch') |
668 | + cmd = ['/usr/sbin/debootstrap', '--arch=%s' % arch] |
669 | + |
670 | + variant = self.context.get_setting('variant') |
671 | + if variant: |
672 | + cmd += ['--variant=%s' % variant] |
673 | + |
674 | + debootstrap_tarball = self.context.get_setting('debootstrap-tarball') |
675 | + if debootstrap_tarball: |
676 | + cmd += ['--unpack-tarball=%s' % debootstrap_tarball] |
677 | + |
678 | + suite = self.context.get_setting('suite') |
679 | + cmd += [suite, self.context.chroot_dir, self.debootstrap_mirror()] |
680 | + kwargs = { 'env' : { 'DEBIAN_FRONTEND' : 'noninteractive' } } |
681 | + |
682 | + proxy = self.context.get_setting('proxy') |
683 | + if proxy: |
684 | + kwargs['env']['http_proxy'] = proxy |
685 | + run_cmd(*cmd, **kwargs) |
686 | + |
687 | + def debootstrap_mirror(self): |
688 | + iso = self.context.get_setting('iso') |
689 | + if iso: |
690 | + isodir = tempfile.mkdtemp() |
691 | + self.context.add_clean_cb(lambda:os.rmdir(isodir)) |
692 | + run_cmd('mount', '-o', 'loop', '-t', 'iso9660', iso, isodir) |
693 | + self.context.add_clean_cmd('umount', isodir) |
694 | + self.iso_mounted = True |
695 | + |
696 | + return 'file://%s' % isodir |
697 | + else: |
698 | + return self.install_mirrors()[0] |
699 | + |
700 | + |
701 | + def install_mirrors(self): |
702 | + install_mirror = self.context.get_setting('install-mirror') |
703 | + if install_mirror: |
704 | + mirror = install_mirror |
705 | + else: |
706 | + mirror = self.context.get_setting('mirror') |
707 | + |
708 | + updates_mirror = mirror |
709 | + |
710 | + install_security_mirror = self.context.get_setting('install-security-mirror') |
711 | + if install_security_mirror: |
712 | + security_mirror = install_security_mirror |
713 | + else: |
714 | + security_mirror = self.context.get_setting('security-mirror') |
715 | + |
716 | + return (mirror, updates_mirror, security_mirror) |
717 | + |
718 | + def install_kernel(self, destdir): |
719 | + run_cmd('chroot', destdir, 'apt-get', '--force-yes', '-y', 'install', self.kernel_name(), env={ 'DEBIAN_FRONTEND' : 'noninteractive' }) |
720 | + |
721 | + def install_grub(self, chroot_dir): |
722 | + self.install_from_template('/etc/kernel-img.conf', 'kernelimg', { 'updategrub' : self.updategrub }) |
723 | + arch = self.context.get_setting('arch') |
724 | + self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'grub', env={ 'DEBIAN_FRONTEND' : 'noninteractive' }) |
725 | + run_cmd('rsync', '-a', '%s%s/%s/' % (chroot_dir, self.grubroot, arch == 'amd64' and 'x86_64-pc' or 'i386-pc'), '%s/boot/grub/' % chroot_dir) |
726 | + |
727 | + def create_devices(self): |
728 | + pass |
729 | +# FIXME |
730 | +# import VMBuilder.plugins.xen |
731 | + |
732 | +# if isinstance(self.context.hypervisor, VMBuilder.plugins.xen.Xen): |
733 | +# self.run_in_target('mknod', '/dev/xvda', 'b', '202', '0') |
734 | +# self.run_in_target('mknod', '/dev/xvda1', 'b', '202', '1') |
735 | +# self.run_in_target('mknod', '/dev/xvda2', 'b', '202', '2') |
736 | +# self.run_in_target('mknod', '/dev/xvda3', 'b', '202', '3') |
737 | +# self.run_in_target('mknod', '/dev/xvc0', 'c', '204', '191') |
738 | + |
739 | + def install_from_template(self, *args, **kwargs): |
740 | + return self.context.install_from_template(*args, **kwargs) |
741 | + |
742 | + def run_in_target(self, *args, **kwargs): |
743 | + return self.context.run_in_target(*args, **kwargs) |
744 | + |
745 | + def copy_to_target(self, infile, destpath): |
746 | + logging.debug("Copying %s on host to %s in guest" % (infile, destpath)) |
747 | + dir = '%s/%s' % (self.destdir, os.path.dirname(destpath)) |
748 | + if not os.path.isdir(dir): |
749 | + os.makedirs(dir) |
750 | + if os.path.isdir(infile): |
751 | + shutil.copytree(infile, '%s/%s' % (self.destdir, destpath)) |
752 | + else: |
753 | + shutil.copy(infile, '%s/%s' % (self.destdir, destpath)) |
754 | + |
755 | + def post_mount(self, fs): |
756 | + if fs.mntpnt == '/': |
757 | + logging.debug("Creating /var/run in root filesystem") |
758 | + os.makedirs('%s/var/run' % fs.mntpath) |
759 | + logging.debug("Creating /var/lock in root filesystem") |
760 | + os.makedirs('%s/var/lock' % fs.mntpath) |
761 | + |
762 | + def set_locale(self): |
763 | + lang = self.context.get_setting('lang') |
764 | + if lang: |
765 | + self.install_from_template('/etc/default/locale', 'locale', { 'lang' : lang }) |
766 | + if lang != "C": |
767 | + self.run_in_target('locale-gen', lang) |
768 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'libc6') |
769 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales') |
770 | + |
771 | + def install_vmbuilder_log(self, logfile, rootdir): |
772 | + shutil.copy(logfile, '%s/var/log/vmbuilder-install.log' % (rootdir,)) |
773 | + |
774 | + def set_timezone(self): |
775 | + timezone = self.context.get_setting('timezone') |
776 | + if timezone: |
777 | + self.install_from_template('/etc/timezone', 'timezone', { 'timezone' : timezone }) |
778 | + self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales') |
779 | + |
780 | + def install_ec2(self): |
781 | + if self.context.ec2: |
782 | + logging.debug('This suite does not support ec2') |
783 | + |
784 | + def disable_hwclock_access(self): |
785 | + fp = open('%s/etc/default/rcS' % self.destdir, 'a') |
786 | + fp.write('HWCLOCKACCESS=no') |
787 | + fp.close() |
788 | + |
789 | + def has_256_bit_inode_ext3_support(self): |
790 | + return False |
791 | + |
792 | |
793 | === added file 'VMBuilder/plugins/debian/sarge.py' |
794 | --- VMBuilder/plugins/debian/sarge.py 1970-01-01 00:00:00 +0000 |
795 | +++ VMBuilder/plugins/debian/sarge.py 2015-10-27 01:09:47 +0000 |
796 | @@ -0,0 +1,23 @@ |
797 | +# |
798 | +# Uncomplicated VM Builder |
799 | +# Copyright (C) 2007-2010 Canonical Ltd. |
800 | +# |
801 | +# See AUTHORS for list of contributors |
802 | +# |
803 | +# This program is free software: you can redistribute it and/or modify |
804 | +# it under the terms of the GNU General Public License version 3, as |
805 | +# published by the Free Software Foundation. |
806 | +# |
807 | +# This program is distributed in the hope that it will be useful, |
808 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
809 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
810 | +# GNU General Public License for more details. |
811 | +# |
812 | +# You should have received a copy of the GNU General Public License |
813 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
814 | +# |
815 | +import time |
816 | +from VMBuilder.plugins.debian.woody import Woody |
817 | + |
818 | +class Sarge(Woody): |
819 | + pass |
820 | |
821 | === added file 'VMBuilder/plugins/debian/squeeze.py' |
822 | --- VMBuilder/plugins/debian/squeeze.py 1970-01-01 00:00:00 +0000 |
823 | +++ VMBuilder/plugins/debian/squeeze.py 2015-10-27 01:09:47 +0000 |
824 | @@ -0,0 +1,23 @@ |
825 | +# |
826 | +# Uncomplicated VM Builder |
827 | +# Copyright (C) 2007-2010 Canonical Ltd. |
828 | +# |
829 | +# See AUTHORS for list of contributors |
830 | +# |
831 | +# This program is free software: you can redistribute it and/or modify |
832 | +# it under the terms of the GNU General Public License version 3, as |
833 | +# published by the Free Software Foundation. |
834 | +# |
835 | +# This program is distributed in the hope that it will be useful, |
836 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
837 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
838 | +# GNU General Public License for more details. |
839 | +# |
840 | +# You should have received a copy of the GNU General Public License |
841 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
842 | +# |
843 | +import time |
844 | +from VMBuilder.plugins.debian.lenny import Lenny |
845 | + |
846 | +class Squeeze(Lenny): |
847 | + pass |
848 | |
849 | === added file 'VMBuilder/plugins/debian/stretch.py' |
850 | --- VMBuilder/plugins/debian/stretch.py 1970-01-01 00:00:00 +0000 |
851 | +++ VMBuilder/plugins/debian/stretch.py 2015-10-27 01:09:47 +0000 |
852 | @@ -0,0 +1,23 @@ |
853 | +# |
854 | +# Uncomplicated VM Builder |
855 | +# Copyright (C) 2007-2010 Canonical Ltd. |
856 | +# |
857 | +# See AUTHORS for list of contributors |
858 | +# |
859 | +# This program is free software: you can redistribute it and/or modify |
860 | +# it under the terms of the GNU General Public License version 3, as |
861 | +# published by the Free Software Foundation. |
862 | +# |
863 | +# This program is distributed in the hope that it will be useful, |
864 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
865 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
866 | +# GNU General Public License for more details. |
867 | +# |
868 | +# You should have received a copy of the GNU General Public License |
869 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
870 | +# |
871 | +import time |
872 | +from VMBuilder.plugins.debian.jessie import Jessie |
873 | + |
874 | +class Stretch(Jessie): |
875 | + pass |
876 | |
877 | === added file 'VMBuilder/plugins/debian/suite.py' |
878 | --- VMBuilder/plugins/debian/suite.py 1970-01-01 00:00:00 +0000 |
879 | +++ VMBuilder/plugins/debian/suite.py 2015-10-27 01:09:47 +0000 |
880 | @@ -0,0 +1,28 @@ |
881 | +# |
882 | +# Uncomplicated VM Builder |
883 | +# Copyright (C) 2007-2009 Canonical Ltd. |
884 | +# |
885 | +# See AUTHORS for list of contributors |
886 | +# |
887 | +# This program is free software: you can redistribute it and/or modify |
888 | +# it under the terms of the GNU General Public License version 3, as |
889 | +# published by the Free Software Foundation. |
890 | +# |
891 | +# This program is distributed in the hope that it will be useful, |
892 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
893 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
894 | +# GNU General Public License for more details. |
895 | +# |
896 | +# You should have received a copy of the GNU General Public License |
897 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
898 | +# |
899 | + |
900 | +class Suite(object): |
901 | + def __init__(self, context): |
902 | + self.context = context |
903 | + self.isodir = '/media/vmbuilder_inst_image' |
904 | + self.iso_mounted = False |
905 | + |
906 | + def check_arch_validity(self, arch): |
907 | + """Checks whether the given arch is valid for this suite""" |
908 | + raise NotImplemented('Suite subclasses need to implement the check_arch_validity method') |
909 | |
910 | === added directory 'VMBuilder/plugins/debian/templates' |
911 | === added file 'VMBuilder/plugins/debian/templates/devicemap.tmpl' |
912 | --- VMBuilder/plugins/debian/templates/devicemap.tmpl 1970-01-01 00:00:00 +0000 |
913 | +++ VMBuilder/plugins/debian/templates/devicemap.tmpl 2015-10-27 01:09:47 +0000 |
914 | @@ -0,0 +1,3 @@ |
915 | +#for $disk in $disks |
916 | +$disk.get_grub_id() /dev/$prefix$disk.devletters() |
917 | +#end for |
918 | |
919 | === added file 'VMBuilder/plugins/debian/templates/etc_hosts.tmpl' |
920 | --- VMBuilder/plugins/debian/templates/etc_hosts.tmpl 1970-01-01 00:00:00 +0000 |
921 | +++ VMBuilder/plugins/debian/templates/etc_hosts.tmpl 2015-10-27 01:09:47 +0000 |
922 | @@ -0,0 +1,10 @@ |
923 | +127.0.0.1 localhost |
924 | +127.0.1.1 $hostname.$domain $hostname |
925 | + |
926 | +# The following lines are desirable for IPv6 capable hosts |
927 | +::1 ip6-localhost ip6-loopback |
928 | +fe00::0 ip6-localnet |
929 | +ff00::0 ip6-mcastprefix |
930 | +ff02::1 ip6-allnodes |
931 | +ff02::2 ip6-allrouters |
932 | +ff02::3 ip6-allhosts |
933 | |
934 | === added file 'VMBuilder/plugins/debian/templates/initctl-stub.tmpl' |
935 | --- VMBuilder/plugins/debian/templates/initctl-stub.tmpl 1970-01-01 00:00:00 +0000 |
936 | +++ VMBuilder/plugins/debian/templates/initctl-stub.tmpl 2015-10-27 01:09:47 +0000 |
937 | @@ -0,0 +1,3 @@ |
938 | +#!/bin/sh |
939 | +echo |
940 | +echo "Warning: Fake initctl called, doing nothing" |
941 | |
942 | === added file 'VMBuilder/plugins/debian/templates/interfaces.tmpl' |
943 | --- VMBuilder/plugins/debian/templates/interfaces.tmpl 1970-01-01 00:00:00 +0000 |
944 | +++ VMBuilder/plugins/debian/templates/interfaces.tmpl 2015-10-27 01:09:47 +0000 |
945 | @@ -0,0 +1,22 @@ |
946 | +# This file describes the network interfaces available on your system |
947 | +# and how to activate them. For more information, see interfaces(5). |
948 | + |
949 | +# The loopback network interface |
950 | +auto lo |
951 | +iface lo inet loopback |
952 | + |
953 | +# The primary network interface |
954 | +auto eth0 |
955 | +#if $ip == 'dhcp' |
956 | +iface eth0 inet dhcp |
957 | +#else |
958 | +iface eth0 inet static |
959 | + address $ip |
960 | + netmask $mask |
961 | + network $net |
962 | + broadcast $bcast |
963 | + gateway $gw |
964 | + # dns-* options are implemented by the resolvconf package, if installed |
965 | + dns-nameservers $dns |
966 | + dns-search $domain |
967 | +#end if |
968 | |
969 | === added file 'VMBuilder/plugins/debian/templates/is-compat-env.tmpl' |
970 | --- VMBuilder/plugins/debian/templates/is-compat-env.tmpl 1970-01-01 00:00:00 +0000 |
971 | +++ VMBuilder/plugins/debian/templates/is-compat-env.tmpl 2015-10-27 01:09:47 +0000 |
972 | @@ -0,0 +1,3 @@ |
973 | +# this is read by ec2-is-compat-env to determine if this is an |
974 | +# ec2 compatible environment |
975 | +compat=1 |
976 | |
977 | === added file 'VMBuilder/plugins/debian/templates/kernelimg.tmpl' |
978 | --- VMBuilder/plugins/debian/templates/kernelimg.tmpl 1970-01-01 00:00:00 +0000 |
979 | +++ VMBuilder/plugins/debian/templates/kernelimg.tmpl 2015-10-27 01:09:47 +0000 |
980 | @@ -0,0 +1,8 @@ |
981 | +do_symlinks = yes |
982 | +relative_links = yes |
983 | +do_bootfloppy = no |
984 | +do_initrd = yes |
985 | +link_in_boot = no |
986 | +postinst_hook = $updategrub |
987 | +postrm_hook = $updategrub |
988 | +do_bootloader = no |
989 | |
990 | === added file 'VMBuilder/plugins/debian/templates/locale.tmpl' |
991 | --- VMBuilder/plugins/debian/templates/locale.tmpl 1970-01-01 00:00:00 +0000 |
992 | +++ VMBuilder/plugins/debian/templates/locale.tmpl 2015-10-27 01:09:47 +0000 |
993 | @@ -0,0 +1,1 @@ |
994 | +LANG="$lang" |
995 | |
996 | === added file 'VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl' |
997 | --- VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl 1970-01-01 00:00:00 +0000 |
998 | +++ VMBuilder/plugins/debian/templates/nostart-policy-rc.d.tmpl 2015-10-27 01:09:47 +0000 |
999 | @@ -0,0 +1,18 @@ |
1000 | +#!/bin/sh |
1001 | + |
1002 | +while true; do |
1003 | + case "$1" in |
1004 | + -*) |
1005 | + shift |
1006 | + ;; |
1007 | + makedev) |
1008 | + exit 0 |
1009 | + ;; |
1010 | + x11-common) |
1011 | + exit 0 |
1012 | + ;; |
1013 | + *) |
1014 | + exit 101 |
1015 | + ;; |
1016 | + esac |
1017 | +done |
1018 | |
1019 | === added file 'VMBuilder/plugins/debian/templates/sources.list.tmpl' |
1020 | --- VMBuilder/plugins/debian/templates/sources.list.tmpl 1970-01-01 00:00:00 +0000 |
1021 | +++ VMBuilder/plugins/debian/templates/sources.list.tmpl 2015-10-27 01:09:47 +0000 |
1022 | @@ -0,0 +1,8 @@ |
1023 | +deb $mirror $suite #slurp |
1024 | +#echo ' '.join($components) |
1025 | + |
1026 | +deb $updates_mirror $suite-updates #slurp |
1027 | +#echo ' '.join($components) |
1028 | + |
1029 | +deb $security_mirror $suite/updates #slurp |
1030 | +#echo ' '.join($components) |
1031 | |
1032 | === added file 'VMBuilder/plugins/debian/templates/sudoers.tmpl' |
1033 | --- VMBuilder/plugins/debian/templates/sudoers.tmpl 1970-01-01 00:00:00 +0000 |
1034 | +++ VMBuilder/plugins/debian/templates/sudoers.tmpl 2015-10-27 01:09:47 +0000 |
1035 | @@ -0,0 +1,23 @@ |
1036 | +# /etc/sudoers |
1037 | +# |
1038 | +# This file MUST be edited with the 'visudo' command as root. |
1039 | +# |
1040 | +# See the man page for details on how to write a sudoers file. |
1041 | +# Defaults |
1042 | + |
1043 | +Defaults !lecture,tty_tickets,!fqdn |
1044 | + |
1045 | +# Uncomment to allow members of group sudo to not need a password |
1046 | +# %sudo ALL=NOPASSWD: ALL |
1047 | + |
1048 | +# Host alias specification |
1049 | + |
1050 | +# User alias specification |
1051 | + |
1052 | +# Cmnd alias specification |
1053 | + |
1054 | +# User privilege specification |
1055 | +root ALL=(ALL) ALL |
1056 | + |
1057 | +# Members of the admin group may gain root privileges |
1058 | +%admin ALL=(ALL) ALL |
1059 | |
1060 | === added file 'VMBuilder/plugins/debian/templates/timezone.tmpl' |
1061 | --- VMBuilder/plugins/debian/templates/timezone.tmpl 1970-01-01 00:00:00 +0000 |
1062 | +++ VMBuilder/plugins/debian/templates/timezone.tmpl 2015-10-27 01:09:47 +0000 |
1063 | @@ -0,0 +1,1 @@ |
1064 | +$timezone |
1065 | |
1066 | === added file 'VMBuilder/plugins/debian/templates/upstart.tmpl' |
1067 | --- VMBuilder/plugins/debian/templates/upstart.tmpl 1970-01-01 00:00:00 +0000 |
1068 | +++ VMBuilder/plugins/debian/templates/upstart.tmpl 2015-10-27 01:09:47 +0000 |
1069 | @@ -0,0 +1,16 @@ |
1070 | +# $console - getty |
1071 | +# |
1072 | +# This service maintains a getty on $console from the point the system is |
1073 | +# started until it is shut down again. |
1074 | + |
1075 | +start on stopped rc2 |
1076 | +start on stopped rc3 |
1077 | +start on stopped rc4 |
1078 | +start on stopped rc5 |
1079 | + |
1080 | +stop on runlevel 0 |
1081 | +stop on runlevel 1 |
1082 | +stop on runlevel 6 |
1083 | + |
1084 | +respawn |
1085 | +exec /sbin/getty 38400 $console |
1086 | |
1087 | === added file 'VMBuilder/plugins/debian/templates/xen-ld-so-conf.tmpl' |
1088 | --- VMBuilder/plugins/debian/templates/xen-ld-so-conf.tmpl 1970-01-01 00:00:00 +0000 |
1089 | +++ VMBuilder/plugins/debian/templates/xen-ld-so-conf.tmpl 2015-10-27 01:09:47 +0000 |
1090 | @@ -0,0 +1,1 @@ |
1091 | +hwcap 0 nosegneg |
1092 | |
1093 | === added file 'VMBuilder/plugins/debian/wheezy.py' |
1094 | --- VMBuilder/plugins/debian/wheezy.py 1970-01-01 00:00:00 +0000 |
1095 | +++ VMBuilder/plugins/debian/wheezy.py 2015-10-27 01:09:47 +0000 |
1096 | @@ -0,0 +1,23 @@ |
1097 | +# |
1098 | +# Uncomplicated VM Builder |
1099 | +# Copyright (C) 2007-2010 Canonical Ltd. |
1100 | +# |
1101 | +# See AUTHORS for list of contributors |
1102 | +# |
1103 | +# This program is free software: you can redistribute it and/or modify |
1104 | +# it under the terms of the GNU General Public License version 3, as |
1105 | +# published by the Free Software Foundation. |
1106 | +# |
1107 | +# This program is distributed in the hope that it will be useful, |
1108 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1109 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1110 | +# GNU General Public License for more details. |
1111 | +# |
1112 | +# You should have received a copy of the GNU General Public License |
1113 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1114 | +# |
1115 | +import time |
1116 | +from VMBuilder.plugins.debian.squeeze import Squeeze |
1117 | + |
1118 | +class Wheezy(Squeeze): |
1119 | + pass |
1120 | |
1121 | === added file 'VMBuilder/plugins/debian/woody.py' |
1122 | --- VMBuilder/plugins/debian/woody.py 1970-01-01 00:00:00 +0000 |
1123 | +++ VMBuilder/plugins/debian/woody.py 2015-10-27 01:09:47 +0000 |
1124 | @@ -0,0 +1,23 @@ |
1125 | +# |
1126 | +# Uncomplicated VM Builder |
1127 | +# Copyright (C) 2007-2010 Canonical Ltd. |
1128 | +# |
1129 | +# See AUTHORS for list of contributors |
1130 | +# |
1131 | +# This program is free software: you can redistribute it and/or modify |
1132 | +# it under the terms of the GNU General Public License version 3, as |
1133 | +# published by the Free Software Foundation. |
1134 | +# |
1135 | +# This program is distributed in the hope that it will be useful, |
1136 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1137 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1138 | +# GNU General Public License for more details. |
1139 | +# |
1140 | +# You should have received a copy of the GNU General Public License |
1141 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1142 | +# |
1143 | +import time |
1144 | +from VMBuilder.plugins.debian.potato import Potato |
1145 | + |
1146 | +class Woody(Potato): |
1147 | + pass |
Thanks, looks good. Ideally a lot of that duplicated code and templates could be shared, especially so that future updates/bugfixes don't end up accidentally being applied in only one. But that can be a future patch, esp since i'm not sure how we'd have to implement it.