bootstrap-vz/common/tasks/host.py

39 lines
1.2 KiB
Python
Raw Normal View History

2013-07-10 10:49:45 +02:00
from base import Task
from common import phases
from common.exceptions import TaskError
class HostDependencies(Task):
description = 'Determining required host dependencies'
phase = phases.preparation
def run(self, info):
info.host_dependencies.add('debootstrap')
from common.fs.loopbackvolume import LoopbackVolume
if isinstance(info.volume, LoopbackVolume):
info.host_dependencies.add('qemu-utils')
if 'xfs' in (p.filesystem for p in info.volume.partition_map.partitions):
info.host_dependencies.add('xfsprogs')
from base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions):
info.host_dependencies.update(['parted', 'kpartx'])
class CheckHostDependencies(Task):
2013-07-10 10:49:45 +02:00
description = 'Checking installed host packages'
phase = phases.preparation
predecessors = [HostDependencies]
2013-07-10 10:49:45 +02:00
def run(self, info):
from common.tools import log_check_call
from subprocess import CalledProcessError
for package in info.host_dependencies:
2013-07-10 10:49:45 +02:00
try:
log_check_call(['/usr/bin/dpkg-query', '-s', package])
2013-07-10 10:49:45 +02:00
except CalledProcessError:
2013-12-29 20:54:36 +01:00
msg = "The package `{0}\' is not installed".format(package)
2013-07-10 10:49:45 +02:00
raise TaskError(msg)