ostbuild: Adapt "status" to expanded manifest
This commit is contained in:
parent
ff81b21bcf
commit
d3059d254b
|
|
@ -75,20 +75,24 @@ def get_git_version_describe(dirpath, commit=None):
|
|||
version = run_sync_get_output(args, cwd=dirpath)
|
||||
return version.strip()
|
||||
|
||||
def manifest_target(manifest, architecture):
|
||||
return '%s-%s-devel' % (manifest['name'], architecture)
|
||||
def manifest_target(manifest):
|
||||
name = manifest['name']
|
||||
is_runtime = name.endswith('-runtime')
|
||||
# HACK - we should really name builds just like e.g. gnomeos-3.4-i686
|
||||
if is_runtime:
|
||||
return name[:-len('-runtime')] + '-devel'
|
||||
return name
|
||||
|
||||
def manifest_base(manifest, roottype, architecture):
|
||||
return 'bases/%s-%s-%s' % (manifest['base'],
|
||||
architecture, roottype)
|
||||
def manifest_base(manifest):
|
||||
return 'bases/%s' % (manifest['base'],)
|
||||
|
||||
def manifest_buildname(manifest, component, architecture):
|
||||
return 'artifacts/%s/%s/%s' % (manifest_target (manifest, architecture),
|
||||
def manifest_buildname(manifest, component):
|
||||
return 'artifacts/%s/%s/%s' % (manifest_target(manifest),
|
||||
component['name'],
|
||||
component['branch'])
|
||||
|
||||
def manifest_buildroot_name(manifest, component, architecture):
|
||||
return 'buildroots/%s/%s/%s' % (manifest_target (manifest, architecture),
|
||||
def manifest_buildroot_name(manifest, component):
|
||||
return 'buildroots/%s/%s/%s' % (manifest_target (manifest),
|
||||
component['name'],
|
||||
component['branch'])
|
||||
|
||||
|
|
@ -112,11 +116,11 @@ def compose(repo, target, artifacts):
|
|||
os.unlink(path)
|
||||
return revision
|
||||
|
||||
def compose_buildroot(manifest, repo, buildroot_name, component, dependencies, architecture):
|
||||
base = manifest_base(manifest, 'devel', architecture)
|
||||
def compose_buildroot(manifest, repo, buildroot_name, component, dependencies):
|
||||
base = 'bases/%s' % (manifest['base'], )
|
||||
buildroot_contents = [base + ':/']
|
||||
for dep in dependencies:
|
||||
dep_buildname = manifest_buildname(manifest, dep, architecture)
|
||||
dep_buildname = manifest_buildname(manifest, dep)
|
||||
buildroot_contents.append(dep_buildname + ':/runtime')
|
||||
buildroot_contents.append(dep_buildname + ':/devel')
|
||||
|
||||
|
|
|
|||
|
|
@ -91,13 +91,14 @@ class OstbuildBuild(builtins.Builtin):
|
|||
|
||||
return result
|
||||
|
||||
def _build_one_component(self, meta, architecture):
|
||||
def _build_one_component(self, meta):
|
||||
name = meta['name']
|
||||
branch = meta['branch']
|
||||
architecture = meta['arch']
|
||||
|
||||
target = buildutil.manifest_target(self.manifest, architecture)
|
||||
buildname = buildutil.manifest_buildname(self.manifest, meta, architecture)
|
||||
buildroot_name = buildutil.manifest_buildroot_name(self.manifest, meta, architecture)
|
||||
target = buildutil.manifest_target(self.manifest)
|
||||
buildname = buildutil.manifest_buildname(self.manifest, meta)
|
||||
buildroot_name = buildutil.manifest_buildroot_name(self.manifest, meta)
|
||||
|
||||
(keytype, uri) = buildutil.parse_src_key(meta['src'])
|
||||
|
||||
|
|
@ -135,10 +136,10 @@ class OstbuildBuild(builtins.Builtin):
|
|||
|
||||
metadata_path = os.path.join(component_src, '_ostbuild-meta.json')
|
||||
f = open(metadata_path, 'w')
|
||||
json.dump(artifact_meta, f)
|
||||
json.dump(artifact_meta, f, indent=4, sort_keys=True)
|
||||
f.close()
|
||||
|
||||
run_sync(['ostbuild', 'checkout', name], cwd=checkoutdir)
|
||||
run_sync(['ostbuild', 'checkout', '--manifest=' + self.manifest_path, name], cwd=checkoutdir)
|
||||
|
||||
logdir = os.path.join(self.workdir, 'logs', 'compile', name)
|
||||
old_logdir = os.path.join(self.workdir, 'old-logs', 'compile', name)
|
||||
|
|
@ -155,7 +156,7 @@ class OstbuildBuild(builtins.Builtin):
|
|||
log("Logging to %s" % (log_path, ))
|
||||
f = open(log_path, 'w')
|
||||
chroot_args = self._get_ostbuild_chroot_args(architecture)
|
||||
chroot_args.extend(['--meta=' + metadata_path])
|
||||
chroot_args.extend(['--pristine', '--manifest=' + self.manifest_path])
|
||||
if self.buildopts.shell_on_failure:
|
||||
ecode = run_sync_monitor_log_file(chroot_args, log_path, cwd=component_src, fatal_on_error=False)
|
||||
if ecode != 0:
|
||||
|
|
@ -228,6 +229,7 @@ class OstbuildBuild(builtins.Builtin):
|
|||
self.buildopts.shell_on_failure = args.shell_on_failure
|
||||
self.buildopts.skip_built = args.skip_built
|
||||
|
||||
self.manifest_path = args.manifest
|
||||
self.manifest = json.load(open(args.manifest))
|
||||
|
||||
components = self.manifest['components']
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class OstbuildCheckout(builtins.Builtin):
|
|||
|
||||
def execute(self, argv):
|
||||
parser = argparse.ArgumentParser(description=self.short_description)
|
||||
parser.add_argument('--manifest', required=True)
|
||||
parser.add_argument('components', nargs='*')
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
|
@ -45,8 +46,7 @@ class OstbuildCheckout(builtins.Builtin):
|
|||
|
||||
self.parse_config()
|
||||
|
||||
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
||||
self.manifest = json.load(open(build_manifest_path))
|
||||
self.manifest = json.load(open(args.manifest))
|
||||
|
||||
if len(args.components) > 0:
|
||||
checkout_components = args.components
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
|||
|
||||
def execute(self, argv):
|
||||
parser = argparse.ArgumentParser(description=self.short_description)
|
||||
parser.add_argument('--meta')
|
||||
parser.add_argument('--manifest', required=True)
|
||||
parser.add_argument('--pristine', action='store_true')
|
||||
parser.add_argument('--debug-shell', action='store_true')
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
|
@ -39,21 +40,13 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
|||
self.parse_config()
|
||||
|
||||
component_name = os.path.basename(os.getcwd())
|
||||
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
||||
self.manifest = json.load(open(build_manifest_path))
|
||||
self.manifest = json.load(open(args.manifest))
|
||||
|
||||
if args.meta is not None:
|
||||
f = open(args.meta)
|
||||
self.metadata = json.load(f)
|
||||
f.close()
|
||||
|
||||
component = buildutil.find_component_in_manifest(self.manifest, self.metadata['name'])
|
||||
else:
|
||||
component = buildutil.find_component_in_manifest(self.manifest, component_name)
|
||||
if component is None:
|
||||
fatal("Couldn't find component '%s' in manifest" % (component_name, ))
|
||||
|
||||
self.metadata = component
|
||||
component = buildutil.find_component_in_manifest(self.manifest, component_name)
|
||||
self.metadata = component
|
||||
if component is None:
|
||||
fatal("Couldn't find component '%s' in manifest" % (component_name, ))
|
||||
if not args.pristine:
|
||||
self.metadata['src'] = 'dirty:worktree'
|
||||
self.metadata['revision'] = 'dirty-worktree'
|
||||
|
||||
|
|
@ -62,11 +55,9 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
|||
dependencies = components[:index]
|
||||
|
||||
architecture = os.uname()[4]
|
||||
buildroot_name = buildutil.manifest_buildroot_name(self.manifest, self.metadata, architecture)
|
||||
buildroot_name = self.manifest['name']
|
||||
buildroot_version = buildutil.compose_buildroot(self.manifest, self.repo, buildroot_name,
|
||||
self.metadata, dependencies, architecture)
|
||||
self.metadata['buildroot-name'] = buildroot_name
|
||||
self.metadata['buildroot-version'] = buildroot_version
|
||||
self.metadata, dependencies)
|
||||
|
||||
if 'name' not in self.metadata:
|
||||
sys.stderr.write('Missing required key "%s" in metadata' % (k, ))
|
||||
|
|
@ -115,7 +106,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
|||
os.mkdir(sourcedir)
|
||||
|
||||
output_metadata = open('_ostbuild-meta.json', 'w')
|
||||
json.dump(self.metadata, output_metadata)
|
||||
json.dump(self.metadata, output_metadata, indent=4, sort_keys=True)
|
||||
output_metadata.close()
|
||||
|
||||
chroot_sourcedir = os.path.join('/ostbuild', 'source', self.metadata['name'])
|
||||
|
|
@ -142,6 +133,15 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
|||
env_copy['PWD'] = chroot_sourcedir
|
||||
run_sync(child_args, env=env_copy, keep_stdin=args.debug_shell)
|
||||
|
||||
shutil.copy(build_manifest_path, resultdir)
|
||||
recorded_meta = dict(self.metadata)
|
||||
del recorded_meta['revision']
|
||||
patches_recorded_meta = recorded_meta.get('patches')
|
||||
if patches_recorded_meta is not None:
|
||||
del patches_recorded_meta['revision']
|
||||
|
||||
recorded_meta_path = os.path.join(resultdir, '_ostbuild-meta.json')
|
||||
recorded_meta_f = open(recorded_meta_path, 'w')
|
||||
json.dump(recorded_meta, recorded_meta_f, indent=4, sort_keys=True)
|
||||
recorded_meta_f.close()
|
||||
|
||||
builtins.register(OstbuildChrootCompileOne)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
# http://people.gnome.org/~walters/docs/build-api.txt
|
||||
|
||||
import os,sys,stat,subprocess,tempfile,re,shutil
|
||||
import argparse
|
||||
from StringIO import StringIO
|
||||
import json
|
||||
|
||||
|
|
@ -34,27 +35,29 @@ class OstbuildStatus(builtins.Builtin):
|
|||
def __init__(self):
|
||||
builtins.Builtin.__init__(self)
|
||||
|
||||
def execute(self, args):
|
||||
self.parse_config()
|
||||
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
||||
self.manifest = json.load(open(build_manifest_path))
|
||||
def execute(self, argv):
|
||||
parser = argparse.ArgumentParser(description=self.short_description)
|
||||
parser.add_argument('--manifest', required=True)
|
||||
|
||||
for architecture in self.manifest['architectures']:
|
||||
for component in self.manifest['components']:
|
||||
branch = buildutil.manifest_buildname(self.manifest, component, architecture)
|
||||
build_revision = run_sync_get_output(['ostree', '--repo=' + self.repo,
|
||||
'show',
|
||||
'--print-metadata-key=ostbuild-artifact-version',
|
||||
branch],
|
||||
none_on_error=True)
|
||||
if build_revision is None:
|
||||
build_revision = '(not built)'
|
||||
if build_revision != component['revision']:
|
||||
build_status = '(needs build)'
|
||||
else:
|
||||
build_status = 'ok'
|
||||
sys.stdout.write('{:<40} {:<95} {:<10}\n'.format(component['name'],
|
||||
build_revision, build_status))
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
self.parse_config()
|
||||
self.manifest = json.load(open(args.manifest))
|
||||
|
||||
for component in self.manifest['components']:
|
||||
branch = buildutil.manifest_buildname(self.manifest, component)
|
||||
build_revision = run_sync_get_output(['ostree', '--repo=' + self.repo,
|
||||
'show',
|
||||
'--print-metadata-key=ostbuild-artifact-version',
|
||||
branch],
|
||||
none_on_error=True)
|
||||
if build_revision is None:
|
||||
build_revision = '(not built)'
|
||||
if build_revision != component['revision']:
|
||||
build_status = '(needs build)'
|
||||
else:
|
||||
build_status = 'ok'
|
||||
sys.stdout.write('{:<40} {:<95} {:<10}\n'.format(component['name'],
|
||||
build_revision, build_status))
|
||||
|
||||
builtins.register(OstbuildStatus)
|
||||
|
|
|
|||
Loading…
Reference in New Issue