2016-04-01 07:26:41 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import kobo.conf
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
here = sys.path[0]
|
|
|
|
if here != '/usr/bin':
|
|
|
|
# Git checkout
|
|
|
|
sys.path[0] = os.path.dirname(here)
|
|
|
|
|
|
|
|
import pungi.compose
|
2016-08-22 14:08:25 +00:00
|
|
|
import pungi.checks
|
2016-08-11 08:21:35 +00:00
|
|
|
import pungi.paths
|
2016-08-22 14:08:25 +00:00
|
|
|
import pungi.phases
|
2017-02-17 12:44:11 +00:00
|
|
|
import pungi.util
|
2016-04-01 07:26:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ValidationCompose(pungi.compose.Compose):
|
2016-08-11 08:21:35 +00:00
|
|
|
def __init__(self, conf, has_old, topdir):
|
|
|
|
self.topdir = topdir
|
2016-04-01 07:26:41 +00:00
|
|
|
self.conf = conf
|
|
|
|
self._logger = None
|
|
|
|
self.just_phases = []
|
|
|
|
self.skip_phases = []
|
|
|
|
self.has_old_composes = has_old
|
2016-08-11 08:21:35 +00:00
|
|
|
self.paths = pungi.paths.Paths(self)
|
2016-04-01 07:26:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def old_composes(self):
|
|
|
|
return '/dummy' if self.has_old_composes else None
|
|
|
|
|
2016-08-11 08:21:35 +00:00
|
|
|
@property
|
|
|
|
def compose_id(self):
|
|
|
|
return 'Dummy-1.0-20160811.t.0'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def compose_type(self):
|
|
|
|
return 'test'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def compose_date(self):
|
|
|
|
return '20160811'
|
|
|
|
|
|
|
|
@property
|
|
|
|
def compose_respin(self):
|
|
|
|
return '0'
|
|
|
|
|
2016-04-01 07:26:41 +00:00
|
|
|
|
|
|
|
def run(config, topdir, has_old):
|
|
|
|
conf = kobo.conf.PyConfigParser()
|
|
|
|
conf.load_from_file(config)
|
|
|
|
|
2016-12-07 14:57:35 +00:00
|
|
|
errors, warnings = pungi.checks.validate(conf)
|
2016-10-20 08:49:28 +00:00
|
|
|
if errors or warnings:
|
|
|
|
for error in errors + warnings:
|
2016-08-22 14:08:25 +00:00
|
|
|
print(error)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2016-08-11 08:21:35 +00:00
|
|
|
compose = ValidationCompose(conf, has_old, topdir)
|
2016-04-01 07:26:41 +00:00
|
|
|
|
|
|
|
pkgset_phase = pungi.phases.PkgsetPhase(compose)
|
|
|
|
phases = [
|
|
|
|
pungi.phases.InitPhase(compose),
|
|
|
|
pungi.phases.BuildinstallPhase(compose),
|
|
|
|
pkgset_phase,
|
|
|
|
pungi.phases.GatherPhase(compose, pkgset_phase),
|
|
|
|
pungi.phases.ExtraFilesPhase(compose, pkgset_phase),
|
|
|
|
pungi.phases.CreaterepoPhase(compose),
|
2016-04-05 07:13:01 +00:00
|
|
|
pungi.phases.OstreeInstallerPhase(compose),
|
2016-04-01 07:26:41 +00:00
|
|
|
pungi.phases.OSTreePhase(compose),
|
|
|
|
pungi.phases.ProductimgPhase(compose, pkgset_phase),
|
|
|
|
pungi.phases.CreateisoPhase(compose),
|
|
|
|
pungi.phases.LiveImagesPhase(compose),
|
|
|
|
pungi.phases.LiveMediaPhase(compose),
|
|
|
|
pungi.phases.ImageBuildPhase(compose),
|
|
|
|
pungi.phases.ImageChecksumPhase(compose),
|
|
|
|
pungi.phases.TestPhase(compose),
|
|
|
|
]
|
|
|
|
|
|
|
|
errors = []
|
|
|
|
for phase in phases:
|
|
|
|
if phase.skip():
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
phase.validate()
|
|
|
|
except ValueError as ex:
|
|
|
|
for i in str(ex).splitlines():
|
|
|
|
errors.append("%s: %s" % (phase.name.upper(), i))
|
|
|
|
|
|
|
|
return errors
|
|
|
|
|
|
|
|
|
|
|
|
def main(args=None):
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('config', metavar='CONFIG',
|
|
|
|
help='configuration file to validate')
|
|
|
|
parser.add_argument('--old-composes', action='store_true',
|
|
|
|
help='indicate if pungi-koji will be run with --old-composes option')
|
|
|
|
opts = parser.parse_args(args)
|
|
|
|
|
2017-02-17 12:44:11 +00:00
|
|
|
with pungi.util.temp_dir() as topdir:
|
2016-04-01 07:26:41 +00:00
|
|
|
errors = run(opts.config, topdir, opts.old_composes)
|
|
|
|
|
|
|
|
for msg in errors:
|
|
|
|
print(msg)
|
|
|
|
|
|
|
|
return bool(errors)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if main():
|
|
|
|
sys.exit(1)
|