2017-06-14 13:36:37 +02:00
|
|
|
# kas - setup tool for bitbake based projects
|
|
|
|
#
|
2020-11-15 09:57:51 +01:00
|
|
|
# Copyright (c) Siemens AG, 2017-2020
|
2017-06-14 13:36:37 +02:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be
|
|
|
|
# included in all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
This module contains common commands used by kas plugins.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
import tempfile
|
|
|
|
import logging
|
|
|
|
import shutil
|
|
|
|
import os
|
2018-08-13 14:11:22 +02:00
|
|
|
import pprint
|
2017-06-14 13:36:37 +02:00
|
|
|
from .libkas import (ssh_cleanup_agent, ssh_setup_agent, ssh_no_host_key_check,
|
2018-03-09 08:22:52 +01:00
|
|
|
get_build_environ, repos_fetch, repos_apply_patches)
|
2018-08-13 14:11:22 +02:00
|
|
|
from .includehandler import IncludeException
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
__license__ = 'MIT'
|
2018-09-05 11:13:03 +02:00
|
|
|
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Macro:
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Contains commands and provides method to run them.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2020-11-13 19:34:51 +01:00
|
|
|
def __init__(self, use_common_setup=True, use_common_cleanup=True):
|
|
|
|
if use_common_setup:
|
|
|
|
repo_loop = Loop('repo_setup_loop')
|
|
|
|
repo_loop.add(SetupReposStep())
|
|
|
|
|
|
|
|
self.setup_commands = [
|
|
|
|
SetupDir(),
|
|
|
|
]
|
|
|
|
|
2021-07-03 23:35:40 +02:00
|
|
|
if ('SSH_PRIVATE_KEY' in os.environ
|
|
|
|
or 'SSH_PRIVATE_KEY_FILE' in os.environ):
|
2020-11-13 19:34:51 +01:00
|
|
|
self.setup_commands.append(SetupSSHAgent())
|
|
|
|
|
|
|
|
self.setup_commands += [
|
2021-09-15 06:53:22 +02:00
|
|
|
SetupHome(),
|
2020-11-13 19:34:51 +01:00
|
|
|
InitSetupRepos(),
|
|
|
|
repo_loop,
|
|
|
|
FinishSetupRepos(),
|
|
|
|
ReposApplyPatches(),
|
2021-03-01 13:20:12 +01:00
|
|
|
SetupEnviron(),
|
2020-11-13 19:34:51 +01:00
|
|
|
WriteBBConfig(),
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
self.setup_commands = []
|
|
|
|
|
2021-07-03 23:35:40 +02:00
|
|
|
if (use_common_cleanup
|
|
|
|
and ('SSH_PRIVATE_KEY' in os.environ
|
|
|
|
or 'SSH_PRIVATE_KEY_FILE' in os.environ)):
|
2020-11-13 19:34:51 +01:00
|
|
|
self.cleanup_commands = [
|
|
|
|
CleanupSSHAgent(),
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
self.cleanup_commands = []
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
self.commands = []
|
|
|
|
|
|
|
|
def add(self, command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
Appends commands to the command list.
|
|
|
|
"""
|
2017-06-14 13:36:37 +02:00
|
|
|
self.commands.append(command)
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def run(self, ctx, skip=None):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Runs a command from the command list with respect to the
|
|
|
|
configuration.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
skip = skip or []
|
2020-11-13 19:34:51 +01:00
|
|
|
joined_commands = self.setup_commands + \
|
|
|
|
self.commands + self.cleanup_commands
|
|
|
|
for command in joined_commands:
|
2017-06-21 13:32:56 +02:00
|
|
|
command_name = str(command)
|
|
|
|
if command_name in skip:
|
2017-06-14 13:36:37 +02:00
|
|
|
continue
|
2017-09-26 09:33:31 +02:00
|
|
|
logging.debug('execute %s', command_name)
|
2018-08-13 14:11:22 +02:00
|
|
|
command.execute(ctx)
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Command:
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
An abstract class that defines the interface of a command.
|
|
|
|
"""
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
This method executes the command.
|
|
|
|
"""
|
2017-06-14 13:36:37 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-09-05 11:13:00 +02:00
|
|
|
class Loop(Command):
|
|
|
|
"""
|
|
|
|
A class that defines a set of commands as a loop.
|
|
|
|
"""
|
|
|
|
def __init__(self, name):
|
|
|
|
self.commands = []
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def add(self, command):
|
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Appends a command to the loop.
|
2018-09-05 11:13:00 +02:00
|
|
|
"""
|
|
|
|
self.commands.append(command)
|
|
|
|
|
|
|
|
def execute(self, ctx):
|
|
|
|
"""
|
|
|
|
Executes the loop.
|
|
|
|
"""
|
|
|
|
loop_name = str(self)
|
|
|
|
|
|
|
|
def executor(command):
|
|
|
|
command_name = str(command)
|
|
|
|
logging.debug('Loop %s: execute %s', loop_name, command_name)
|
|
|
|
return command.execute(ctx)
|
|
|
|
|
|
|
|
while all(executor(c) for c in self.commands):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
class SetupHome(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Sets up the home directory of kas.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
|
2022-02-23 02:02:01 +01:00
|
|
|
# A list of environment variables that SETUP_HOME uses
|
|
|
|
# This should be kept up to date with any code in execute()
|
|
|
|
ENV_VARS = [
|
|
|
|
'GIT_CREDENTIAL_HELPER',
|
2023-03-02 08:25:51 +01:00
|
|
|
'GIT_CREDENTIAL_USEHTTPPATH',
|
2022-02-23 02:02:01 +01:00
|
|
|
'AWS_CONFIG_FILE',
|
|
|
|
'AWS_SHARED_CREDENTIALS_FILE',
|
2022-06-23 14:51:22 +02:00
|
|
|
'NETRC_FILE',
|
2022-02-23 02:02:01 +01:00
|
|
|
]
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __init__(self):
|
2017-06-21 13:32:56 +02:00
|
|
|
super().__init__()
|
2017-06-14 13:36:37 +02:00
|
|
|
self.tmpdirname = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
def __del__(self):
|
|
|
|
shutil.rmtree(self.tmpdirname)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return 'setup_home'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2022-06-23 14:51:22 +02:00
|
|
|
if os.environ.get('NETRC_FILE', False):
|
|
|
|
shutil.copy(os.environ['NETRC_FILE'],
|
|
|
|
self.tmpdirname + "/.netrc")
|
2022-06-09 16:10:03 +02:00
|
|
|
if os.environ.get('CI_SERVER_HOST', False) \
|
|
|
|
and os.environ.get('CI_JOB_TOKEN', False):
|
2022-06-23 14:51:22 +02:00
|
|
|
with open(self.tmpdirname + '/.netrc', 'a') as fds:
|
|
|
|
fds.write('\n# appended by kas, you have gitlab CI env\n')
|
2022-04-21 13:08:22 +02:00
|
|
|
fds.write('machine ' + os.environ['CI_SERVER_HOST'] + '\n'
|
|
|
|
'login gitlab-ci-token\n'
|
|
|
|
'password ' + os.environ['CI_JOB_TOKEN'] + '\n')
|
2018-03-21 16:41:10 +01:00
|
|
|
with open(self.tmpdirname + '/.gitconfig', 'w') as fds:
|
|
|
|
fds.write('[User]\n'
|
|
|
|
'\temail = kas@example.com\n'
|
|
|
|
'\tname = Kas User\n')
|
2021-05-06 11:31:12 +02:00
|
|
|
if os.environ.get('GIT_CREDENTIAL_HELPER', False):
|
|
|
|
fds.write('[credential]\n'
|
|
|
|
'\thelper = '
|
|
|
|
+ os.environ.get('GIT_CREDENTIAL_HELPER')
|
|
|
|
+ '\n')
|
2023-03-02 08:25:51 +01:00
|
|
|
if os.environ.get('GIT_CREDENTIAL_USEHTTPPATH', False):
|
|
|
|
fds.write('\tuseHttpPath = '
|
|
|
|
+ os.environ.get('GIT_CREDENTIAL_USEHTTPPATH')
|
|
|
|
+ '\n')
|
2020-05-05 14:07:25 +02:00
|
|
|
|
2020-06-17 08:09:14 +02:00
|
|
|
if os.environ.get('AWS_CONFIG_FILE', False) \
|
|
|
|
and os.environ.get('AWS_SHARED_CREDENTIALS_FILE', False):
|
2020-05-05 14:07:25 +02:00
|
|
|
os.makedirs(self.tmpdirname + "/.aws")
|
|
|
|
|
|
|
|
shutil.copy(os.environ['AWS_CONFIG_FILE'],
|
|
|
|
self.tmpdirname + "/.aws/config")
|
|
|
|
shutil.copy(os.environ['AWS_SHARED_CREDENTIALS_FILE'],
|
|
|
|
self.tmpdirname + "/.aws/credentials")
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
ctx.environ['HOME'] = self.tmpdirname
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SetupDir(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
Creates the build directory.
|
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
|
|
|
return 'setup_dir'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
|
|
|
os.chdir(ctx.kas_work_dir)
|
|
|
|
if not os.path.exists(ctx.build_dir):
|
|
|
|
os.mkdir(ctx.build_dir)
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SetupSSHAgent(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Sets up the ssh agent configuration.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
|
|
|
return 'setup_ssh_agent'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2018-08-24 19:18:04 +02:00
|
|
|
ssh_setup_agent()
|
|
|
|
ssh_no_host_key_check()
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CleanupSSHAgent(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Removes all the identities and stops the ssh-agent instance.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return 'cleanup_ssh_agent'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2018-08-24 19:18:04 +02:00
|
|
|
ssh_cleanup_agent()
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SetupEnviron(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Sets up the kas environment.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
|
|
|
return 'setup_environ'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2020-11-15 09:57:51 +01:00
|
|
|
ctx.environ.update(get_build_environ(ctx.config.get_build_system()))
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
class WriteBBConfig(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
Writes bitbake configuration files into the build directory.
|
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
2018-08-13 14:11:22 +02:00
|
|
|
return 'write_bbconfig'
|
2017-06-14 13:36:37 +02:00
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2022-04-27 14:10:31 +02:00
|
|
|
def _get_layer_path_under_topdir(ctx, layer):
|
|
|
|
"""
|
|
|
|
Returns a path relative to ${TOPDIR}.
|
|
|
|
TOPDIR is a BB variable pointing to the build directory.
|
|
|
|
It is not expanded by KAS, hence we avoid
|
|
|
|
absolute paths pointing into the build host.
|
|
|
|
"""
|
|
|
|
relpath = os.path.relpath(layer, ctx.build_dir)
|
|
|
|
return '${TOPDIR}/' + relpath
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def _write_bblayers_conf(ctx):
|
|
|
|
filename = ctx.build_dir + '/conf/bblayers.conf'
|
2017-12-21 17:21:40 +01:00
|
|
|
if not os.path.isdir(os.path.dirname(filename)):
|
|
|
|
os.makedirs(os.path.dirname(filename))
|
2017-06-21 13:32:56 +02:00
|
|
|
with open(filename, 'w') as fds:
|
2018-08-13 14:11:22 +02:00
|
|
|
fds.write(ctx.config.get_bblayers_conf_header())
|
2017-07-17 22:38:07 +02:00
|
|
|
fds.write('BBLAYERS ?= " \\\n ')
|
|
|
|
fds.write(' \\\n '.join(
|
2022-04-27 14:10:31 +02:00
|
|
|
sorted(_get_layer_path_under_topdir(ctx, layer)
|
|
|
|
for repo in ctx.config.get_repos()
|
2017-07-17 22:38:07 +02:00
|
|
|
for layer in repo.layers)))
|
2017-06-21 13:32:56 +02:00
|
|
|
fds.write('"\n')
|
2021-10-11 08:10:29 +02:00
|
|
|
fds.write('BBPATH ?= "${TOPDIR}"\n')
|
|
|
|
fds.write('BBFILES ??= ""\n')
|
2017-06-21 13:32:56 +02:00
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def _write_local_conf(ctx):
|
|
|
|
filename = ctx.build_dir + '/conf/local.conf'
|
2017-06-21 13:32:56 +02:00
|
|
|
with open(filename, 'w') as fds:
|
2018-08-13 14:11:22 +02:00
|
|
|
fds.write(ctx.config.get_local_conf_header())
|
|
|
|
fds.write('MACHINE ??= "{}"\n'.format(
|
|
|
|
ctx.config.get_machine()))
|
|
|
|
fds.write('DISTRO ??= "{}"\n'.format(
|
|
|
|
ctx.config.get_distro()))
|
2017-11-07 17:20:17 +01:00
|
|
|
fds.write('BBMULTICONFIG ?= "{}"\n'.format(
|
2018-08-13 14:11:22 +02:00
|
|
|
ctx.config.get_multiconfig()))
|
2017-06-21 13:32:56 +02:00
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
_write_bblayers_conf(ctx)
|
|
|
|
_write_local_conf(ctx)
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ReposFetch(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
Fetches repositories defined in the configuration
|
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
|
|
|
return 'repos_fetch'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2018-08-24 19:18:06 +02:00
|
|
|
repos_fetch(ctx.config.get_repos())
|
2017-06-14 13:36:37 +02:00
|
|
|
|
|
|
|
|
2018-03-09 08:22:52 +01:00
|
|
|
class ReposApplyPatches(Command):
|
|
|
|
"""
|
|
|
|
Applies the patches defined in the configuration to the repositories.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return 'repos_apply_patches'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
2018-08-24 19:18:06 +02:00
|
|
|
repos_apply_patches(ctx.config.get_repos())
|
2018-03-09 08:22:52 +01:00
|
|
|
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
class ReposCheckout(Command):
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Ensures that the right revision of each repo is checked out.
|
2017-06-21 13:32:56 +02:00
|
|
|
"""
|
|
|
|
|
2017-06-14 13:36:37 +02:00
|
|
|
def __str__(self):
|
|
|
|
return 'repos_checkout'
|
|
|
|
|
2018-08-13 14:11:22 +02:00
|
|
|
def execute(self, ctx):
|
|
|
|
for repo in ctx.config.get_repos():
|
2018-08-24 19:18:06 +02:00
|
|
|
repo.checkout()
|
2018-08-13 14:11:22 +02:00
|
|
|
|
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
class InitSetupRepos(Command):
|
2018-08-13 14:11:22 +02:00
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Prepares setting up repos including the include logic
|
2018-08-13 14:11:22 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
2018-09-05 11:13:01 +02:00
|
|
|
return 'init_setup_repos'
|
2018-08-13 14:11:22 +02:00
|
|
|
|
|
|
|
def execute(self, ctx):
|
2018-09-05 11:13:01 +02:00
|
|
|
ctx.missing_repo_names = ctx.config.find_missing_repos()
|
|
|
|
ctx.missing_repo_names_old = None
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
|
|
|
|
class SetupReposStep(Command):
|
|
|
|
"""
|
|
|
|
Single step of the checkout repos loop
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return 'setup_repos_step'
|
|
|
|
|
|
|
|
def execute(self, ctx):
|
|
|
|
if not ctx.missing_repo_names:
|
|
|
|
return False
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
if ctx.missing_repo_names == ctx.missing_repo_names_old:
|
|
|
|
raise IncludeException('Could not fetch all repos needed by '
|
|
|
|
'includes.')
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
logging.debug('Missing repos for complete config:\n%s',
|
|
|
|
pprint.pformat(ctx.missing_repo_names))
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2020-10-10 16:11:16 +02:00
|
|
|
ctx.missing_repos = []
|
|
|
|
for repo_name in ctx.missing_repo_names:
|
2022-07-08 16:45:09 +02:00
|
|
|
if repo_name not in ctx.config.get_repos_config():
|
2023-05-04 04:50:18 +02:00
|
|
|
raise IncludeException('Include references unknown repo: {}'
|
|
|
|
.format(repo_name))
|
2022-07-08 16:45:09 +02:00
|
|
|
ctx.missing_repos.append(ctx.config.get_repo(repo_name))
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
repos_fetch(ctx.missing_repos)
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
for repo in ctx.missing_repos:
|
|
|
|
repo.checkout()
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2022-07-08 16:45:09 +02:00
|
|
|
ctx.config.repo_dict.update(
|
|
|
|
{repo.name: repo for repo in ctx.missing_repos})
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
repo_paths = {r: ctx.config.repo_dict[r].path for r
|
|
|
|
in ctx.config.repo_dict}
|
|
|
|
ctx.missing_repo_names_old = ctx.missing_repo_names
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2022-07-08 16:45:11 +02:00
|
|
|
ctx.missing_repo_names = \
|
|
|
|
ctx.config.find_missing_repos(repo_paths)
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2018-09-05 11:13:01 +02:00
|
|
|
return ctx.missing_repo_names
|
|
|
|
|
|
|
|
|
|
|
|
class FinishSetupRepos(Command):
|
|
|
|
"""
|
2018-09-05 11:13:03 +02:00
|
|
|
Finalizes the repo setup loop
|
2018-09-05 11:13:01 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return 'finish_setup_repos'
|
|
|
|
|
|
|
|
def execute(self, ctx):
|
2018-08-13 14:11:22 +02:00
|
|
|
# now fetch everything with complete config and check out layers
|
2020-11-13 19:34:49 +01:00
|
|
|
repos_fetch(ctx.config.get_repos())
|
2018-08-13 14:11:22 +02:00
|
|
|
|
2020-11-13 19:34:49 +01:00
|
|
|
for repo in ctx.config.get_repos():
|
|
|
|
repo.checkout()
|
2018-08-13 14:11:22 +02:00
|
|
|
|
|
|
|
logging.debug('Configuration from config file:\n%s',
|
2022-07-08 16:45:11 +02:00
|
|
|
pprint.pformat(ctx.config.get_config()))
|