diff options
Diffstat (limited to 'scripts/devtool')
-rwxr-xr-x | scripts/devtool | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/scripts/devtool b/scripts/devtool index 8a4f41bc37..60ea3e8298 100755 --- a/scripts/devtool +++ b/scripts/devtool | |||
@@ -100,10 +100,11 @@ def read_workspace(): | |||
100 | _enable_workspace_layer(config.workspace_path, config, basepath) | 100 | _enable_workspace_layer(config.workspace_path, config, basepath) |
101 | 101 | ||
102 | logger.debug('Reading workspace in %s' % config.workspace_path) | 102 | logger.debug('Reading workspace in %s' % config.workspace_path) |
103 | externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-([^ =]+))? *= *"([^"]*)"$') | 103 | externalsrc_re = re.compile(r'^EXTERNALSRC(:pn-([^ =]+))? *= *"([^"]*)"$') |
104 | for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')): | 104 | for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')): |
105 | with open(fn, 'r') as f: | 105 | with open(fn, 'r') as f: |
106 | pnvalues = {} | 106 | pnvalues = {} |
107 | pn = None | ||
107 | for line in f: | 108 | for line in f: |
108 | res = externalsrc_re.match(line.rstrip()) | 109 | res = externalsrc_re.match(line.rstrip()) |
109 | if res: | 110 | if res: |
@@ -123,6 +124,9 @@ def read_workspace(): | |||
123 | elif line.startswith('# srctreebase: '): | 124 | elif line.startswith('# srctreebase: '): |
124 | pnvalues['srctreebase'] = line.split(':', 1)[1].strip() | 125 | pnvalues['srctreebase'] = line.split(':', 1)[1].strip() |
125 | if pnvalues: | 126 | if pnvalues: |
127 | if not pn: | ||
128 | raise DevtoolError("Found *.bbappend in %s, but could not determine EXTERNALSRC:pn-*. " | ||
129 | "Maybe still using old syntax?" % config.workspace_path) | ||
126 | if not pnvalues.get('srctreebase', None): | 130 | if not pnvalues.get('srctreebase', None): |
127 | pnvalues['srctreebase'] = pnvalues['srctree'] | 131 | pnvalues['srctreebase'] = pnvalues['srctree'] |
128 | logger.debug('Found recipe %s' % pnvalues) | 132 | logger.debug('Found recipe %s' % pnvalues) |
@@ -133,17 +137,27 @@ def create_workspace(args, config, basepath, workspace): | |||
133 | workspacedir = os.path.abspath(args.layerpath) | 137 | workspacedir = os.path.abspath(args.layerpath) |
134 | else: | 138 | else: |
135 | workspacedir = os.path.abspath(os.path.join(basepath, 'workspace')) | 139 | workspacedir = os.path.abspath(os.path.join(basepath, 'workspace')) |
136 | _create_workspace(workspacedir, config, basepath) | 140 | layerseries = None |
141 | if args.layerseries: | ||
142 | layerseries = args.layerseries | ||
143 | _create_workspace(workspacedir, config, basepath, layerseries) | ||
137 | if not args.create_only: | 144 | if not args.create_only: |
138 | _enable_workspace_layer(workspacedir, config, basepath) | 145 | _enable_workspace_layer(workspacedir, config, basepath) |
139 | 146 | ||
140 | def _create_workspace(workspacedir, config, basepath): | 147 | def _create_workspace(workspacedir, config, basepath, layerseries=None): |
141 | import bb | 148 | import bb |
142 | 149 | ||
143 | confdir = os.path.join(workspacedir, 'conf') | 150 | confdir = os.path.join(workspacedir, 'conf') |
144 | if os.path.exists(os.path.join(confdir, 'layer.conf')): | 151 | if os.path.exists(os.path.join(confdir, 'layer.conf')): |
145 | logger.info('Specified workspace already set up, leaving as-is') | 152 | logger.info('Specified workspace already set up, leaving as-is') |
146 | else: | 153 | else: |
154 | if not layerseries: | ||
155 | tinfoil = setup_tinfoil(config_only=True, basepath=basepath) | ||
156 | try: | ||
157 | layerseries = tinfoil.config_data.getVar('LAYERSERIES_CORENAMES') | ||
158 | finally: | ||
159 | tinfoil.shutdown() | ||
160 | |||
147 | # Add a config file | 161 | # Add a config file |
148 | bb.utils.mkdirhier(confdir) | 162 | bb.utils.mkdirhier(confdir) |
149 | with open(os.path.join(confdir, 'layer.conf'), 'w') as f: | 163 | with open(os.path.join(confdir, 'layer.conf'), 'w') as f: |
@@ -155,7 +169,7 @@ def _create_workspace(workspacedir, config, basepath): | |||
155 | f.write('BBFILE_PATTERN_workspacelayer = "^$' + '{LAYERDIR}/"\n') | 169 | f.write('BBFILE_PATTERN_workspacelayer = "^$' + '{LAYERDIR}/"\n') |
156 | f.write('BBFILE_PATTERN_IGNORE_EMPTY_workspacelayer = "1"\n') | 170 | f.write('BBFILE_PATTERN_IGNORE_EMPTY_workspacelayer = "1"\n') |
157 | f.write('BBFILE_PRIORITY_workspacelayer = "99"\n') | 171 | f.write('BBFILE_PRIORITY_workspacelayer = "99"\n') |
158 | f.write('LAYERSERIES_COMPAT_workspacelayer = "${LAYERSERIES_COMPAT_core}"\n') | 172 | f.write('LAYERSERIES_COMPAT_workspacelayer = "%s"\n' % layerseries) |
159 | # Add a README file | 173 | # Add a README file |
160 | with open(os.path.join(workspacedir, 'README'), 'w') as f: | 174 | with open(os.path.join(workspacedir, 'README'), 'w') as f: |
161 | f.write('This layer was created by the OpenEmbedded devtool utility in order to\n') | 175 | f.write('This layer was created by the OpenEmbedded devtool utility in order to\n') |
@@ -285,8 +299,9 @@ def main(): | |||
285 | return 2 | 299 | return 2 |
286 | 300 | ||
287 | # Search BBPATH first to allow layers to override plugins in scripts_path | 301 | # Search BBPATH first to allow layers to override plugins in scripts_path |
288 | for path in global_args.bbpath.split(':') + [scripts_path]: | 302 | pluginpaths = [os.path.join(path, 'lib', 'devtool') for path in global_args.bbpath.split(':') + [scripts_path]] |
289 | pluginpath = os.path.join(path, 'lib', 'devtool') | 303 | context.pluginpaths = pluginpaths |
304 | for pluginpath in pluginpaths: | ||
290 | scriptutils.load_plugins(logger, plugins, pluginpath) | 305 | scriptutils.load_plugins(logger, plugins, pluginpath) |
291 | 306 | ||
292 | subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') | 307 | subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') |
@@ -305,6 +320,7 @@ def main(): | |||
305 | description='Sets up a new workspace. NOTE: other devtool subcommands will create a workspace automatically as needed, so you only need to use %(prog)s if you want to specify where the workspace should be located.', | 320 | description='Sets up a new workspace. NOTE: other devtool subcommands will create a workspace automatically as needed, so you only need to use %(prog)s if you want to specify where the workspace should be located.', |
306 | group='advanced') | 321 | group='advanced') |
307 | parser_create_workspace.add_argument('layerpath', nargs='?', help='Path in which the workspace layer should be created') | 322 | parser_create_workspace.add_argument('layerpath', nargs='?', help='Path in which the workspace layer should be created') |
323 | parser_create_workspace.add_argument('--layerseries', help='Layer series the workspace should be set to be compatible with') | ||
308 | parser_create_workspace.add_argument('--create-only', action="store_true", help='Only create the workspace layer, do not alter configuration') | 324 | parser_create_workspace.add_argument('--create-only', action="store_true", help='Only create the workspace layer, do not alter configuration') |
309 | parser_create_workspace.set_defaults(func=create_workspace, no_workspace=True) | 325 | parser_create_workspace.set_defaults(func=create_workspace, no_workspace=True) |
310 | 326 | ||
@@ -314,10 +330,10 @@ def main(): | |||
314 | 330 | ||
315 | args = parser.parse_args(unparsed_args, namespace=global_args) | 331 | args = parser.parse_args(unparsed_args, namespace=global_args) |
316 | 332 | ||
317 | if not getattr(args, 'no_workspace', False): | ||
318 | read_workspace() | ||
319 | |||
320 | try: | 333 | try: |
334 | if not getattr(args, 'no_workspace', False): | ||
335 | read_workspace() | ||
336 | |||
321 | ret = args.func(args, config, basepath, workspace) | 337 | ret = args.func(args, config, basepath, workspace) |
322 | except DevtoolError as err: | 338 | except DevtoolError as err: |
323 | if str(err): | 339 | if str(err): |