diff options
author | Chris Laplante <chris.laplante@agilent.com> | 2025-01-12 09:53:53 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-01-20 13:38:59 +0000 |
commit | e6503a7f38ab064649eeb50bbfeac943446ec2ad (patch) | |
tree | d87794a8c98116a4cfeb3cda1a14e0ec1e4e36f2 /scripts/devtool | |
parent | e59da05be4365c4922e880e07a81549927cd92be (diff) | |
download | poky-e6503a7f38ab064649eeb50bbfeac943446ec2ad.tar.gz |
devtool: un-globalize the 'basepath' variable
(From OE-Core rev: 8a73a384e9cbd7ecf3b6f05bfc28574784725801)
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/devtool')
-rwxr-xr-x | scripts/devtool | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/scripts/devtool b/scripts/devtool index 60ea3e8298..acc4e0e982 100755 --- a/scripts/devtool +++ b/scripts/devtool | |||
@@ -13,10 +13,8 @@ import argparse | |||
13 | import glob | 13 | import glob |
14 | import re | 14 | import re |
15 | import configparser | 15 | import configparser |
16 | import subprocess | ||
17 | import logging | 16 | import logging |
18 | 17 | ||
19 | basepath = '' | ||
20 | workspace = {} | 18 | workspace = {} |
21 | config = None | 19 | config = None |
22 | context = None | 20 | context = None |
@@ -33,13 +31,15 @@ logger = scriptutils.logger_create('devtool') | |||
33 | plugins = [] | 31 | plugins = [] |
34 | 32 | ||
35 | 33 | ||
36 | class ConfigHandler(object): | 34 | class ConfigHandler: |
35 | basepath = None | ||
37 | config_file = '' | 36 | config_file = '' |
38 | config_obj = None | 37 | config_obj = None |
39 | init_path = '' | 38 | init_path = '' |
40 | workspace_path = '' | 39 | workspace_path = '' |
41 | 40 | ||
42 | def __init__(self, filename): | 41 | def __init__(self, basepath, filename): |
42 | self.basepath = basepath | ||
43 | self.config_file = filename | 43 | self.config_file = filename |
44 | self.config_obj = configparser.ConfigParser() | 44 | self.config_obj = configparser.ConfigParser() |
45 | 45 | ||
@@ -59,14 +59,14 @@ class ConfigHandler(object): | |||
59 | 59 | ||
60 | if self.config_obj.has_option('General', 'init_path'): | 60 | if self.config_obj.has_option('General', 'init_path'): |
61 | pth = self.get('General', 'init_path') | 61 | pth = self.get('General', 'init_path') |
62 | self.init_path = os.path.join(basepath, pth) | 62 | self.init_path = os.path.join(self.basepath, pth) |
63 | if not os.path.exists(self.init_path): | 63 | if not os.path.exists(self.init_path): |
64 | logger.error('init_path %s specified in config file cannot be found' % pth) | 64 | logger.error('init_path %s specified in config file cannot be found' % pth) |
65 | return False | 65 | return False |
66 | else: | 66 | else: |
67 | self.config_obj.add_section('General') | 67 | self.config_obj.add_section('General') |
68 | 68 | ||
69 | self.workspace_path = self.get('General', 'workspace_path', os.path.join(basepath, 'workspace')) | 69 | self.workspace_path = self.get('General', 'workspace_path', os.path.join(self.basepath, 'workspace')) |
70 | return True | 70 | return True |
71 | 71 | ||
72 | 72 | ||
@@ -86,7 +86,7 @@ class Context: | |||
86 | self.__dict__.update(kwargs) | 86 | self.__dict__.update(kwargs) |
87 | 87 | ||
88 | 88 | ||
89 | def read_workspace(): | 89 | def read_workspace(basepath): |
90 | global workspace | 90 | global workspace |
91 | workspace = {} | 91 | workspace = {} |
92 | if not os.path.exists(os.path.join(config.workspace_path, 'conf', 'layer.conf')): | 92 | if not os.path.exists(os.path.join(config.workspace_path, 'conf', 'layer.conf')): |
@@ -209,7 +209,6 @@ def _enable_workspace_layer(workspacedir, config, basepath): | |||
209 | 209 | ||
210 | 210 | ||
211 | def main(): | 211 | def main(): |
212 | global basepath | ||
213 | global config | 212 | global config |
214 | global context | 213 | global context |
215 | 214 | ||
@@ -264,7 +263,7 @@ def main(): | |||
264 | 263 | ||
265 | logger.debug('Using basepath %s' % basepath) | 264 | logger.debug('Using basepath %s' % basepath) |
266 | 265 | ||
267 | config = ConfigHandler(os.path.join(basepath, 'conf', 'devtool.conf')) | 266 | config = ConfigHandler(basepath, os.path.join(basepath, 'conf', 'devtool.conf')) |
268 | if not config.read(): | 267 | if not config.read(): |
269 | return -1 | 268 | return -1 |
270 | context.config = config | 269 | context.config = config |
@@ -332,7 +331,7 @@ def main(): | |||
332 | 331 | ||
333 | try: | 332 | try: |
334 | if not getattr(args, 'no_workspace', False): | 333 | if not getattr(args, 'no_workspace', False): |
335 | read_workspace() | 334 | read_workspace(basepath) |
336 | 335 | ||
337 | ret = args.func(args, config, basepath, workspace) | 336 | ret = args.func(args, config, basepath, workspace) |
338 | except DevtoolError as err: | 337 | except DevtoolError as err: |