diff --git a/bin/pungi-config-validate b/bin/pungi-config-validate index 67913a60..bb0ce541 100755 --- a/bin/pungi-config-validate +++ b/bin/pungi-config-validate @@ -5,20 +5,24 @@ from __future__ import print_function import argparse import json -import kobo.conf import os import sys +import kobo.conf +import six + here = sys.path[0] if here != '/usr/bin': # Git checkout sys.path[0] = os.path.dirname(here) -import pungi.compose import pungi.checks +import pungi.compose import pungi.paths import pungi.phases +import pungi.wrappers.scm import pungi.util +from pungi.wrappers.variants import VariantsXmlParser class ValidationCompose(pungi.compose.Compose): @@ -30,6 +34,7 @@ class ValidationCompose(pungi.compose.Compose): self.skip_phases = [] self.has_old_composes = has_old self.paths = pungi.paths.Paths(self) + self.variants = {} @property def old_composes(self): @@ -52,6 +57,20 @@ class ValidationCompose(pungi.compose.Compose): return '0' +def read_variants(compose, config): + with pungi.util.temp_dir() as tmp_dir: + scm_dict = compose.conf["variants_file"] + if isinstance(scm_dict, six.string_types) and scm_dict[0] != '/': + config_dir = os.path.dirname(config) + scm_dict = os.path.join(config_dir, scm_dict) + files = pungi.wrappers.scm.get_file_from_scm(scm_dict, tmp_dir) + tree_arches = compose.conf.get("tree_arches") + tree_variants = compose.conf.get("tree_variants") + with open(os.path.join(tmp_dir, files[0]), "r") as file_obj: + parser = VariantsXmlParser(file_obj, tree_arches, tree_variants) + compose.variants = parser.parse() + + def run(config, topdir, has_old): conf = kobo.conf.PyConfigParser() conf.load_from_file(config) @@ -63,6 +82,11 @@ def run(config, topdir, has_old): sys.exit(1) compose = ValidationCompose(conf, has_old, topdir) + try: + read_variants(compose, config) + except: + # Failed to read variants, no big deal. + pass pkgset_phase = pungi.phases.PkgsetPhase(compose) phases = [ diff --git a/pungi/phases/ostree_installer.py b/pungi/phases/ostree_installer.py index 46633cc1..ceb1f038 100644 --- a/pungi/phases/ostree_installer.py +++ b/pungi/phases/ostree_installer.py @@ -20,6 +20,25 @@ class OstreeInstallerPhase(PhaseLoggerMixin, ConfigGuardedPhase): super(OstreeInstallerPhase, self).__init__(compose) self.pool = ThreadPool(logger=self.logger) + def validate(self): + errors = [] + try: + super(OstreeInstallerPhase, self).validate() + except ValueError as exc: + errors = exc.message.split('\n') + + for variant in self.compose.get_variants(): + for arch in variant.arches: + conf = util.get_arch_variant_data(self.compose.conf, self.name, + arch, variant) + if conf and not variant.is_empty: + errors.append('Can not generate ostree installer for %s.%s: ' + 'it has buildinstall running already and the ' + 'files would clash.' % (variant.uid, arch)) + + if errors: + raise ValueError('\n'.join(errors)) + def run(self): for variant in self.compose.get_variants(): for arch in variant.arches: