kas: Factor out common setup & cleanup steps
The list of steps to be executed within a macro is split into setup commands, main commands and cleanup commands to ensure that new steps are added to the appropriate place in the execution order by plugins. By default, the setup and cleanup commands are set to the default list of steps which the build and shell plugins have in common. It's expected that most future plugins will also share these common setup and cleanup steps but we do provide arguments to the Macro initialiser to skip these if customisation is needed. Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
@@ -33,17 +33,12 @@
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libkas import find_program, run_cmd
|
||||
from kas.libcmds import (Macro, Command, SetupDir, CleanupSSHAgent,
|
||||
SetupSSHAgent, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.libcmds import Macro, Command
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@@ -84,33 +79,7 @@ class Build:
|
||||
ctx.config = Config(args.config, args.target, args.task)
|
||||
|
||||
macro = Macro()
|
||||
|
||||
# Prepare
|
||||
macro.add(SetupDir())
|
||||
|
||||
if 'SSH_PRIVATE_KEY' in os.environ:
|
||||
macro.add(SetupSSHAgent())
|
||||
|
||||
macro.add(InitSetupRepos())
|
||||
|
||||
repo_loop = Loop('repo_setup_loop')
|
||||
repo_loop.add(SetupReposStep())
|
||||
|
||||
macro.add(repo_loop)
|
||||
macro.add(FinishSetupRepos())
|
||||
|
||||
macro.add(SetupEnviron())
|
||||
macro.add(SetupHome())
|
||||
macro.add(ReposApplyPatches())
|
||||
|
||||
macro.add(WriteBBConfig())
|
||||
|
||||
# Build
|
||||
macro.add(BuildCommand(args.extra_bitbake_args))
|
||||
|
||||
if 'SSH_PRIVATE_KEY' in os.environ:
|
||||
macro.add(CleanupSSHAgent())
|
||||
|
||||
macro.run(ctx, args.skip)
|
||||
|
||||
|
||||
|
@@ -38,16 +38,11 @@
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libcmds import (Macro, Command, SetupDir, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
CleanupSSHAgent, SetupSSHAgent,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.libcmds import Macro, Command
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@@ -93,33 +88,7 @@ class Shell:
|
||||
]
|
||||
|
||||
macro = Macro()
|
||||
|
||||
# Prepare
|
||||
macro.add(SetupDir())
|
||||
|
||||
if 'SSH_PRIVATE_KEY' in os.environ:
|
||||
macro.add(SetupSSHAgent())
|
||||
|
||||
macro.add(InitSetupRepos())
|
||||
|
||||
repo_loop = Loop('repo_setup_loop')
|
||||
repo_loop.add(SetupReposStep())
|
||||
|
||||
macro.add(repo_loop)
|
||||
macro.add(FinishSetupRepos())
|
||||
|
||||
macro.add(SetupEnviron())
|
||||
macro.add(SetupHome())
|
||||
macro.add(ReposApplyPatches())
|
||||
|
||||
macro.add(WriteBBConfig())
|
||||
|
||||
# Shell
|
||||
macro.add(ShellCommand(args.command))
|
||||
|
||||
if 'SSH_PRIVATE_KEY' in os.environ:
|
||||
macro.add(CleanupSSHAgent())
|
||||
|
||||
macro.run(ctx, args.skip)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user