2013-07-10 10:49:45 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
from common.exceptions import TaskError
|
|
|
|
|
|
|
|
|
2013-12-29 16:09:47 +01:00
|
|
|
class HostDependencies(Task):
|
|
|
|
description = 'Determining required host dependencies'
|
|
|
|
phase = phases.preparation
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-12-29 16:09:47 +01:00
|
|
|
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
|
2013-12-29 16:09:47 +01:00
|
|
|
predecessors = [HostDependencies]
|
2013-07-10 10:49:45 +02:00
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-10 10:49:45 +02:00
|
|
|
from common.tools import log_check_call
|
|
|
|
from subprocess import CalledProcessError
|
2013-12-29 16:09:47 +01:00
|
|
|
for package in info.host_dependencies:
|
2013-07-10 10:49:45 +02:00
|
|
|
try:
|
2013-10-27 09:24:07 +01:00
|
|
|
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)
|