bootstrap-vz/providers/virtualbox/tasks/guest_additions.py
Tiago Ilieve 43e3d9678a Don't check Guest Additions installation status
I've been discussing that with Anders for over a week and we agreed that
checking the return code of the Guest Additions installation is just a
waste of time. It seems to return 1 no matter what happen, like:

- It has been launched without administrator privileges: OK
- Requirements like bzip2 and gcc are missing: OK
- Kernel headers or dkms are missing: OK
- It was installed successfully, but without X11 drivers: ???

There isn't even a way (at least until the current 4.3.x version) to
disable the X11 drivers installation. The `--nox11` option, just "Do not
spawn an xterm".

And the worst part: until the version 4.2.x, it returned 0 if it could
be installed with no errors beside this one about the missing X11
drivers. This means that this verification will most likely fail on any
other version older than 4.3.x, preventing the build from finishing in a
successful way. So, we can't really rely on its return code whatsoever.

That said, neither him or me likes the idea of ignoring the return code
of a command. It just happens that we can't do anything about that.
2014-04-01 23:37:45 -03:00

60 lines
1.9 KiB
Python

from base import Task
from common import phases
from common.tasks.packages import InstallPackages
from common.exceptions import TaskError
class CheckGuestAdditionsPath(Task):
description = 'Checking whether the VirtualBox Guest Additions image exists'
phase = phases.preparation
@classmethod
def run(cls, info):
import os.path
guest_additions_path = info.manifest.bootstrapper['guest_additions']
if not os.path.exists(guest_additions_path):
msg = 'The file {file} does not exist.'.format(file=guest_additions_path)
raise TaskError(msg)
class AddGuestAdditionsPackages(Task):
description = 'Adding packages to support Guest Additions installation'
phase = phases.package_installation
successors = [InstallPackages]
@classmethod
def run(cls, info):
info.packages.add('bzip2')
info.packages.add('build-essential')
info.packages.add('dkms')
from common.tools import log_check_call
[kernel_version] = log_check_call(['chroot', info.root,
'uname', '-r'])
kernel_headers_pkg = 'linux-headers-{version}'.format(version=kernel_version)
info.packages.add(kernel_headers_pkg)
class InstallGuestAdditions(Task):
description = 'Installing the VirtualBox Guest Additions'
phase = phases.package_installation
predecessors = [InstallPackages]
@classmethod
def run(cls, info):
import os
guest_additions_path = info.manifest.bootstrapper['guest_additions']
mount_dir = 'mnt/guest_additions'
mount_path = os.path.join(info.root, mount_dir)
os.mkdir(mount_path)
root = info.volume.partition_map.root
root.add_mount(guest_additions_path, mount_path, ['-o', 'loop'])
install_script = os.path.join('/', mount_dir, 'VBoxLinuxAdditions.run')
from common.tools import log_call
status, out, err = log_call(['chroot', info.root,
install_script, '--nox11'])
log_call(['chroot', info.root, 'service', 'vboxadd-service', 'stop'])
root.remove_mount(mount_path)
os.rmdir(mount_path)