2013-06-23 15:26:08 +02:00
|
|
|
from phase import Phase
|
2013-12-29 23:52:08 +01:00
|
|
|
from task import Task
|
2014-11-30 15:59:52 +01:00
|
|
|
from main import main
|
2014-01-05 14:03:04 +01:00
|
|
|
|
2015-02-22 16:44:58 +01:00
|
|
|
__all__ = ['Phase', 'Task', 'main']
|
|
|
|
|
2014-01-05 14:03:04 +01:00
|
|
|
|
|
|
|
def validate_manifest(data, validator, error):
|
2016-03-15 17:56:26 +01:00
|
|
|
"""Validates the manifest using the base manifest
|
2014-03-23 16:04:03 +01:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
:param dict data: The data of the manifest
|
|
|
|
:param function validator: The function that validates the manifest given the data and a path
|
|
|
|
:param function error: The function tha raises an error when the validation fails
|
|
|
|
"""
|
2016-09-12 18:47:20 +02:00
|
|
|
from bootstrapvz.common.tools import rel_path
|
|
|
|
validator(data, rel_path(__file__, 'manifest-schema.yml'))
|
2014-05-04 19:09:34 +02:00
|
|
|
|
2016-09-12 18:47:20 +02:00
|
|
|
from bootstrapvz.common.releases import get_release, squeeze
|
2016-03-15 17:56:26 +01:00
|
|
|
release = get_release(data['system']['release'])
|
2015-04-29 20:55:55 +02:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
if release < squeeze:
|
|
|
|
error('Only Debian squeeze and later is supported', ['system', 'release'])
|
2015-04-08 21:37:29 +02:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
# Check the bootloader/partitioning configuration.
|
|
|
|
# Doing this via the schema is a pain and does not output a useful error message.
|
|
|
|
if data['system']['bootloader'] == 'grub':
|
2015-04-08 21:37:29 +02:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
if data['volume']['partitions']['type'] == 'none':
|
|
|
|
error('Grub cannot boot from unpartitioned disks', ['system', 'bootloader'])
|
2015-04-08 21:37:29 +02:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
if release == squeeze:
|
|
|
|
error('Grub installation on squeeze is not supported', ['system', 'bootloader'])
|
2016-03-11 03:01:18 +01:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
# Check the provided apt.conf(5) options
|
|
|
|
if 'packages' in data:
|
|
|
|
for name, val in data['packages'].get('apt.conf.d', {}).iteritems():
|
|
|
|
from bootstrapvz.common.tools import log_call
|
2016-03-11 03:01:18 +01:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
status, _, _ = log_call(['apt-config', '-c=/dev/stdin', 'dump'],
|
|
|
|
stdin=val + '\n')
|
2016-03-11 03:01:18 +01:00
|
|
|
|
2016-03-15 17:56:26 +01:00
|
|
|
if status != 0:
|
|
|
|
error('apt.conf(5) syntax error', ['packages', 'apt.conf.d', name])
|