mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Support installation of VirtualBox Guest Additions
This commit is contained in:
parent
65e3f37520
commit
d0ec90f491
4 changed files with 71 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"provider": "virtualbox",
|
||||
"bootstrapper": {
|
||||
"workspace": "/target"
|
||||
"workspace": "/target"
|
||||
// "guest_additions": "/root/images/VBoxGuestAdditions.iso"
|
||||
},
|
||||
"image": {
|
||||
"name": "debian-{release}-{architecture}-{%y}{%m}{%d}",
|
||||
|
|
|
@ -49,6 +49,12 @@ def resolve_tasks(tasklist, manifest):
|
|||
|
||||
loopback.MoveImage)
|
||||
|
||||
if manifest.bootstrapper.get('guest_additions', False):
|
||||
from tasks import guest_additions
|
||||
tasklist.add(guest_additions.CheckGuestAdditionsPath,
|
||||
guest_additions.AddGuestAdditionsPackages,
|
||||
guest_additions.InstallGuestAdditions)
|
||||
|
||||
if manifest.bootstrapper.get('tarball', False):
|
||||
tasklist.add(bootstrap.MakeTarball)
|
||||
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
"title": "VirtualBox manifest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bootstrapper": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"guest_additions": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"volume": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
55
providers/virtualbox/tasks/guest_additions.py
Normal file
55
providers/virtualbox/tasks/guest_additions.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks.packages import ImagePackages
|
||||
from common.tasks.host import CheckPackages
|
||||
from common.tasks.filesystem import FStab
|
||||
from common.exceptions import TaskError
|
||||
|
||||
|
||||
class CheckGuestAdditionsPath(Task):
|
||||
description = 'Checking whether the VirtualBox Guest Additions image exists'
|
||||
phase = phases.preparation
|
||||
|
||||
def run(self, 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.preparation
|
||||
predecessors = [ImagePackages]
|
||||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
info.img_packages[0].update(['bzip2',
|
||||
'build-essential',
|
||||
'dkms',
|
||||
])
|
||||
|
||||
|
||||
class InstallGuestAdditions(Task):
|
||||
description = 'Installing the VirtualBox Guest Additions'
|
||||
phase = phases.system_modification
|
||||
predecessors = [FStab]
|
||||
|
||||
def run(self, info):
|
||||
import os
|
||||
from common.tools import log_call
|
||||
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')
|
||||
# Install will exit with $?=1 because X11 isn't installed
|
||||
log_call(['/usr/sbin/chroot', info.root,
|
||||
install_script, '--nox11'])
|
||||
|
||||
root.remove_mount(mount_path)
|
||||
os.rmdir(mount_path)
|
Loading…
Add table
Reference in a new issue