diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2023-02-19 20:30:23 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-20 15:18:30 +0000 |
commit | e8b88168f5228c8314f5bdf139edfdeebc0044b5 (patch) | |
tree | bebbf8f7619c148ccc74f2677569992d4837bd5f /scripts/oe-setup-layers | |
parent | a7e3c0f04665c802f563bfe5444ae3246138e802 (diff) | |
download | poky-e8b88168f5228c8314f5bdf139edfdeebc0044b5.tar.gz |
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 <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-setup-layers')
-rwxr-xr-x | scripts/oe-setup-layers | 68 |
1 files changed, 34 insertions, 34 deletions
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 | |||
19 | import os | 19 | import os |
20 | import subprocess | 20 | import subprocess |
21 | 21 | ||
22 | def _is_layer_git_repo(layerdir): | 22 | def _is_repo_git_repo(repodir): |
23 | git_dir = os.path.join(layerdir, ".git") | 23 | git_dir = os.path.join(repodir, ".git") |
24 | if not os.access(git_dir, os.R_OK): | 24 | if not os.access(git_dir, os.R_OK): |
25 | return False | 25 | return False |
26 | try: | 26 | try: |
@@ -28,73 +28,73 @@ def _is_layer_git_repo(layerdir): | |||
28 | except subprocess.CalledProcessError: | 28 | except subprocess.CalledProcessError: |
29 | return False | 29 | return False |
30 | 30 | ||
31 | def _is_layer_at_rev(layerdir, rev): | 31 | def _is_repo_at_rev(repodir, rev): |
32 | try: | 32 | try: |
33 | curr_rev = subprocess.check_output("git -C %s rev-parse HEAD" % layerdir, shell=True, stderr=subprocess.DEVNULL) | 33 | curr_rev = subprocess.check_output("git -C %s rev-parse HEAD" % repodir, shell=True, stderr=subprocess.DEVNULL) |
34 | if curr_rev.strip().decode("utf-8") == rev: | 34 | if curr_rev.strip().decode("utf-8") == rev: |
35 | return True | 35 | return True |
36 | except subprocess.CalledProcessError: | 36 | except subprocess.CalledProcessError: |
37 | pass | 37 | pass |
38 | return False | 38 | return False |
39 | 39 | ||
40 | def _is_layer_at_remote_uri(layerdir, remote, uri): | 40 | def _is_repo_at_remote_uri(repodir, remote, uri): |
41 | try: | 41 | try: |
42 | curr_uri = subprocess.check_output("git -C %s remote get-url %s" % (layerdir, remote), shell=True, stderr=subprocess.DEVNULL) | 42 | curr_uri = subprocess.check_output("git -C %s remote get-url %s" % (repodir, remote), shell=True, stderr=subprocess.DEVNULL) |
43 | if curr_uri.strip().decode("utf-8") == uri: | 43 | if curr_uri.strip().decode("utf-8") == uri: |
44 | return True | 44 | return True |
45 | except subprocess.CalledProcessError: | 45 | except subprocess.CalledProcessError: |
46 | pass | 46 | pass |
47 | return False | 47 | return False |
48 | 48 | ||
49 | def _contains_submodules(layerdir): | 49 | def _contains_submodules(repodir): |
50 | return os.path.exists(os.path.join(layerdir,".gitmodules")) | 50 | return os.path.exists(os.path.join(repodir,".gitmodules")) |
51 | 51 | ||
52 | def _do_checkout(args, json): | 52 | def _do_checkout(args, json): |
53 | layers = json['sources'] | 53 | repos = json['sources'] |
54 | for l_name in layers: | 54 | for r_name in repos: |
55 | l_data = layers[l_name] | 55 | r_data = repos[r_name] |
56 | layerdir = os.path.abspath(os.path.join(args['destdir'], l_data['path'])) | 56 | repodir = os.path.abspath(os.path.join(args['destdir'], r_data['path'])) |
57 | 57 | ||
58 | if 'contains_this_file' in l_data.keys(): | 58 | if 'contains_this_file' in r_data.keys(): |
59 | force_arg = 'force_bootstraplayer_checkout' | 59 | force_arg = 'force_bootstraplayer_checkout' |
60 | if not args[force_arg]: | 60 | if not args[force_arg]: |
61 | print('Note: not checking out source {layer}, use {layerflag} to override.'.format(layer=l_name, layerflag='--force-bootstraplayer-checkout')) | 61 | print('Note: not checking out source {repo}, use {repoflag} to override.'.format(repo=r_name, repoflag='--force-bootstraplayer-checkout')) |
62 | continue | 62 | continue |
63 | l_remote = l_data['git-remote'] | 63 | r_remote = r_data['git-remote'] |
64 | rev = l_remote['rev'] | 64 | rev = r_remote['rev'] |
65 | desc = l_remote['describe'] | 65 | desc = r_remote['describe'] |
66 | if not desc: | 66 | if not desc: |
67 | desc = rev[:10] | 67 | desc = rev[:10] |
68 | branch = l_remote['branch'] | 68 | branch = r_remote['branch'] |
69 | remotes = l_remote['remotes'] | 69 | remotes = r_remote['remotes'] |
70 | 70 | ||
71 | print('\nSetting up source {}, revision {}, branch {}'.format(l_name, desc, branch)) | 71 | print('\nSetting up source {}, revision {}, branch {}'.format(r_name, desc, branch)) |
72 | if not _is_layer_git_repo(layerdir): | 72 | if not _is_repo_git_repo(repodir): |
73 | cmd = 'git init -q {}'.format(layerdir) | 73 | cmd = 'git init -q {}'.format(repodir) |
74 | print("Running '{}'".format(cmd)) | 74 | print("Running '{}'".format(cmd)) |
75 | subprocess.check_output(cmd, shell=True) | 75 | subprocess.check_output(cmd, shell=True) |
76 | 76 | ||
77 | for remote in remotes: | 77 | for remote in remotes: |
78 | if not _is_layer_at_remote_uri(layerdir, remote, remotes[remote]['uri']): | 78 | if not _is_repo_at_remote_uri(repodir, remote, remotes[remote]['uri']): |
79 | cmd = "git remote remove {} > /dev/null 2>&1; git remote add {} {}".format(remote, remote, remotes[remote]['uri']) | 79 | cmd = "git remote remove {} > /dev/null 2>&1; git remote add {} {}".format(remote, remote, remotes[remote]['uri']) |
80 | print("Running '{}' in {}".format(cmd, layerdir)) | 80 | print("Running '{}' in {}".format(cmd, repodir)) |
81 | subprocess.check_output(cmd, shell=True, cwd=layerdir) | 81 | subprocess.check_output(cmd, shell=True, cwd=repodir) |
82 | 82 | ||
83 | cmd = "git fetch -q {} || true".format(remote) | 83 | cmd = "git fetch -q {} || true".format(remote) |
84 | print("Running '{}' in {}".format(cmd, layerdir)) | 84 | print("Running '{}' in {}".format(cmd, repodir)) |
85 | subprocess.check_output(cmd, shell=True, cwd=layerdir) | 85 | subprocess.check_output(cmd, shell=True, cwd=repodir) |
86 | 86 | ||
87 | if not _is_layer_at_rev(layerdir, rev): | 87 | if not _is_repo_at_rev(repodir, rev): |
88 | cmd = "git fetch -q --all || true" | 88 | cmd = "git fetch -q --all || true" |
89 | print("Running '{}' in {}".format(cmd, layerdir)) | 89 | print("Running '{}' in {}".format(cmd, repodir)) |
90 | subprocess.check_output(cmd, shell=True, cwd=layerdir) | 90 | subprocess.check_output(cmd, shell=True, cwd=repodir) |
91 | 91 | ||
92 | cmd = 'git checkout -q {}'.format(rev) | 92 | cmd = 'git checkout -q {}'.format(rev) |
93 | print("Running '{}' in {}".format(cmd, layerdir)) | 93 | print("Running '{}' in {}".format(cmd, repodir)) |
94 | subprocess.check_output(cmd, shell=True, cwd=layerdir) | 94 | subprocess.check_output(cmd, shell=True, cwd=repodir) |
95 | 95 | ||
96 | if _contains_submodules(layerdir): | 96 | if _contains_submodules(repodir): |
97 | print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(layerdir)) | 97 | print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(repodir)) |
98 | 98 | ||
99 | 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/") | 99 | 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/") |
100 | 100 | ||