Commit 02de6607 authored by locallycompact-ct's avatar locallycompact-ct

Remove get_build_commands now covered by defslib, replace...

Remove get_build_commands now covered by defslib, replace gather_integration_commands with in-scope reduce
parent a237c48b
Pipeline #4776180 failed with stages
in 28 minutes and 10 seconds
......@@ -22,7 +22,7 @@ import sys
import fcntl
from ybd import app, cache, sandbox
from import cleanup, config, log, RetryException, setup, spawn, timer
from ybd.assembly import compose, build
from ybd.assembly import compose, build, install_contents
from ybd.cache import get_cache, get_remote
from ybd.deployment import deploy
from ybd.concourse import Pipeline
......@@ -31,6 +31,7 @@ from defslib import MorphologyResolver, Actuator
import copy
import sandboxlib
import yaml
from functools import reduce
def write_cache_key():
......@@ -42,6 +43,7 @@ def write_cache_key():
def build_assemblage(actuator, target):
orig = copy.deepcopy(target)
with timer('CACHE-KEYS', 'cache-key calculations'):
......@@ -49,8 +51,18 @@ def build_assemblage(actuator, target):
if not get_cache(y):
with sandbox.setup(y):
## Gather and run s-i commands by pretending we're a chunk
a = reduce(lambda x,y: dict(x, **y.get('system-integration', {})), target['contents'], {})
commands = dict(("%s-%s" % (f, x), g) for x,p in a.items() for f,g in p.items())
t = reduce(lambda r,s: r + s, commands.values(), [])
target['install-commands'] = t
with sandbox.setup(target):
build(actuator, target, target['contents'])
original_cwd = os.getcwd()
......@@ -123,10 +123,12 @@ def build(actuator, dn, contents):
with claim(dn):
if dn.get('kind', 'chunk') == 'chunk':
s = actuator.lens(dn, contents)
install_dependencies(dn, s['supports'])
supports = actuator.lens(dn, contents)['supports']
install_dependencies(dn, supports)
supports = contents
with timer(dn, 'build of %s' % dn['cache']):
run_build(dn, s['supports'])
run_build(dn, supports)
with timer(dn, 'artifact creation'):
......@@ -154,7 +156,6 @@ def run_build(dn, supports):
dn['SOURCE_DATE_EPOCH'] = repos.source_date_epoch(dn['checkout'])
env_vars = sandbox.env_vars_for_build(dn, supports)
log(dn, 'Logging build commands to %s' % dn['log'])
......@@ -200,56 +201,3 @@ def claim(dn):
if os.path.isfile(lockfile(dn)):
def get_build_commands(dn):
'''Get commands specified in d, plus commands implied by build-system
The containing definition may point to another definition file (using
the 'path' field in YBD's internal data model) that contains build
instructions, or it may only specify a predefined build system, using
'build-system' field.
The definition containing build instructions can specify a predefined
build-system and then override some or all of the command sequences it
If the definition file doesn't exist and no build-system is specified,
this function will scan the contents the checked-out source repo and try
to autodetect what build system is used.
if dn.get('kind', None) == "system":
# Systems must run their integration scripts as install commands
dn['install-commands'] = gather_integration_commands(dn)
exit = True if config.get('check-definitions') == 'exit' else False
for build_step in app.defs.defaults['build-steps']:
if dn.get(build_step, None) is None:
commands = app.defs.defaults['build-systems'][bs].get(build_step, [])
dn[build_step] = commands
def gather_integration_commands(dn):
# 1. iterate all subcomponents (recursively) looking for sys-int commands
# 2. gather them all up
# 3. asciibetically sort them
# 4. concat the lists
def _gather_recursively(component, commands):
if 'system-integration' in component:
for product, it in component['system-integration'].items():
for name, cmdseq in it.items():
commands["%s-%s" % (name, product)] = cmdseq
for subcomponent in component.get('contents', []):
_gather_recursively(app.defs.get(subcomponent), commands)
all_commands = {}
_gather_recursively(dn, all_commands)
result = []
for key in sorted(list(all_commands.keys())):
return result
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment