From e8b88168f5228c8314f5bdf139edfdeebc0044b5 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Sun, 19 Feb 2023 20:30:23 +0100 Subject: scripts/oe-setup-layers: correct variable names - layers should be called repos The script is operating on layer repositories, which can and do sometimes contain several layers. This distinction is important as the script will be tweaked to write a record of actual layer locations. (From OE-Core rev: 833965e6001db98039c0aa816ae661232213bcea) Signed-off-by: Alexander Kanavin Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- scripts/oe-setup-layers | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'scripts/oe-setup-layers') diff --git a/scripts/oe-setup-layers b/scripts/oe-setup-layers index 461560de9f..6c02262663 100755 --- a/scripts/oe-setup-layers +++ b/scripts/oe-setup-layers @@ -19,8 +19,8 @@ import json import os import subprocess -def _is_layer_git_repo(layerdir): - git_dir = os.path.join(layerdir, ".git") +def _is_repo_git_repo(repodir): + git_dir = os.path.join(repodir, ".git") if not os.access(git_dir, os.R_OK): return False try: @@ -28,73 +28,73 @@ def _is_layer_git_repo(layerdir): except subprocess.CalledProcessError: return False -def _is_layer_at_rev(layerdir, rev): +def _is_repo_at_rev(repodir, rev): try: - curr_rev = subprocess.check_output("git -C %s rev-parse HEAD" % layerdir, shell=True, stderr=subprocess.DEVNULL) + curr_rev = subprocess.check_output("git -C %s rev-parse HEAD" % repodir, shell=True, stderr=subprocess.DEVNULL) if curr_rev.strip().decode("utf-8") == rev: return True except subprocess.CalledProcessError: pass return False -def _is_layer_at_remote_uri(layerdir, remote, uri): +def _is_repo_at_remote_uri(repodir, remote, uri): try: - curr_uri = subprocess.check_output("git -C %s remote get-url %s" % (layerdir, remote), shell=True, stderr=subprocess.DEVNULL) + curr_uri = subprocess.check_output("git -C %s remote get-url %s" % (repodir, remote), shell=True, stderr=subprocess.DEVNULL) if curr_uri.strip().decode("utf-8") == uri: return True except subprocess.CalledProcessError: pass return False -def _contains_submodules(layerdir): - return os.path.exists(os.path.join(layerdir,".gitmodules")) +def _contains_submodules(repodir): + return os.path.exists(os.path.join(repodir,".gitmodules")) def _do_checkout(args, json): - layers = json['sources'] - for l_name in layers: - l_data = layers[l_name] - layerdir = os.path.abspath(os.path.join(args['destdir'], l_data['path'])) + repos = json['sources'] + for r_name in repos: + r_data = repos[r_name] + repodir = os.path.abspath(os.path.join(args['destdir'], r_data['path'])) - if 'contains_this_file' in l_data.keys(): + if 'contains_this_file' in r_data.keys(): force_arg = 'force_bootstraplayer_checkout' if not args[force_arg]: - print('Note: not checking out source {layer}, use {layerflag} to override.'.format(layer=l_name, layerflag='--force-bootstraplayer-checkout')) + print('Note: not checking out source {repo}, use {repoflag} to override.'.format(repo=r_name, repoflag='--force-bootstraplayer-checkout')) continue - l_remote = l_data['git-remote'] - rev = l_remote['rev'] - desc = l_remote['describe'] + r_remote = r_data['git-remote'] + rev = r_remote['rev'] + desc = r_remote['describe'] if not desc: desc = rev[:10] - branch = l_remote['branch'] - remotes = l_remote['remotes'] + branch = r_remote['branch'] + remotes = r_remote['remotes'] - print('\nSetting up source {}, revision {}, branch {}'.format(l_name, desc, branch)) - if not _is_layer_git_repo(layerdir): - cmd = 'git init -q {}'.format(layerdir) + print('\nSetting up source {}, revision {}, branch {}'.format(r_name, desc, branch)) + if not _is_repo_git_repo(repodir): + cmd = 'git init -q {}'.format(repodir) print("Running '{}'".format(cmd)) subprocess.check_output(cmd, shell=True) for remote in remotes: - if not _is_layer_at_remote_uri(layerdir, remote, remotes[remote]['uri']): + if not _is_repo_at_remote_uri(repodir, remote, remotes[remote]['uri']): cmd = "git remote remove {} > /dev/null 2>&1; git remote add {} {}".format(remote, remote, remotes[remote]['uri']) - print("Running '{}' in {}".format(cmd, layerdir)) - subprocess.check_output(cmd, shell=True, cwd=layerdir) + print("Running '{}' in {}".format(cmd, repodir)) + subprocess.check_output(cmd, shell=True, cwd=repodir) cmd = "git fetch -q {} || true".format(remote) - print("Running '{}' in {}".format(cmd, layerdir)) - subprocess.check_output(cmd, shell=True, cwd=layerdir) + print("Running '{}' in {}".format(cmd, repodir)) + subprocess.check_output(cmd, shell=True, cwd=repodir) - if not _is_layer_at_rev(layerdir, rev): + if not _is_repo_at_rev(repodir, rev): cmd = "git fetch -q --all || true" - print("Running '{}' in {}".format(cmd, layerdir)) - subprocess.check_output(cmd, shell=True, cwd=layerdir) + print("Running '{}' in {}".format(cmd, repodir)) + subprocess.check_output(cmd, shell=True, cwd=repodir) cmd = 'git checkout -q {}'.format(rev) - print("Running '{}' in {}".format(cmd, layerdir)) - subprocess.check_output(cmd, shell=True, cwd=layerdir) + print("Running '{}' in {}".format(cmd, repodir)) + subprocess.check_output(cmd, shell=True, cwd=repodir) - if _contains_submodules(layerdir): - print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(layerdir)) + if _contains_submodules(repodir): + print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(repodir)) parser = argparse.ArgumentParser(description="A self contained python script that fetches all the needed layers and sets them to correct revisions using data in a json format from a separate file. The json data can be created from an active build directory with 'bitbake-layers create-layers-setup destdir' and there's a sample file and a schema in meta/files/") -- cgit v1.2.3-54-g00ecf