summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool
diff options
context:
space:
mode:
authorJuan M Cruz Alcaraz <juan.m.cruz.alcaraz@linux.intel.com>2017-09-08 06:34:34 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-13 22:07:42 +0100
commit688e0894aa664090a88614e7cf9b77acadf42940 (patch)
treecae6d201b00fce27d476689ad046c75094e58bab /scripts/lib/devtool
parent6cfb161ed9413783569df684dff7a96a19904bf8 (diff)
downloadpoky-688e0894aa664090a88614e7cf9b77acadf42940.tar.gz
devtool/standard: set a preferred provider when adding a new recipe with devtool
A recipe added with "devtool add" requires to be able to take precedence on recipes previously defined with PREFERRED_PROVIDER. By adding the parameter "--provides" to "devtool add" it is possible to specify an element to be provided by the recipe. A devtool recipe can override a previous PREFERRED_PROVIDER using the layer configuration file in the workspace. E.g. devtool add my-libgl git@git://my-libgl-repository --provides virtual/libgl [YOCTO #10415] (From OE-Core rev: adeea2fe6895898a5e6006e798898f0f5dabd890) Signed-off-by: Juan M Cruz Alcaraz <juan.m.cruz.alcaraz@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool')
-rw-r--r--scripts/lib/devtool/standard.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 0998fa7055..4b489cfd79 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -161,6 +161,8 @@ def add(args, config, basepath, workspace):
161 extracmdopts += ' --srcrev %s' % args.srcrev 161 extracmdopts += ' --srcrev %s' % args.srcrev
162 if args.srcbranch: 162 if args.srcbranch:
163 extracmdopts += ' --srcbranch %s' % args.srcbranch 163 extracmdopts += ' --srcbranch %s' % args.srcbranch
164 if args.provides:
165 extracmdopts += ' --provides %s' % args.provides
164 166
165 tempdir = tempfile.mkdtemp(prefix='devtool') 167 tempdir = tempfile.mkdtemp(prefix='devtool')
166 try: 168 try:
@@ -276,6 +278,24 @@ def add(args, config, basepath, workspace):
276 f.write(' done\n') 278 f.write(' done\n')
277 f.write('}\n') 279 f.write('}\n')
278 280
281 # Check if the new layer provides recipes whose priorities have been
282 # overriden by PREFERRED_PROVIDER.
283 recipe_name = rd.getVar('PN')
284 provides = rd.getVar('PROVIDES')
285 # Search every item defined in PROVIDES
286 for recipe_provided in provides.split():
287 preferred_provider = 'PREFERRED_PROVIDER_' + recipe_provided
288 current_pprovider = rd.getVar(preferred_provider)
289 if current_pprovider and current_pprovider != recipe_name:
290 if args.fixed_setup:
291 #if we are inside the eSDK add the new PREFERRED_PROVIDER in the workspace layer.conf
292 layerconf_file = os.path.join(config.workspace_path, "conf", "layer.conf")
293 with open(layerconf_file, 'a') as f:
294 f.write('%s = "%s"\n' % (preferred_provider, recipe_name))
295 else:
296 logger.warn('Set \'%s\' in order to use the recipe' % preferred_provider)
297 break
298
279 _add_md5(config, recipename, appendfile) 299 _add_md5(config, recipename, appendfile)
280 300
281 logger.info('Recipe %s has been automatically created; further editing may be required to make it fully functional' % recipefile) 301 logger.info('Recipe %s has been automatically created; further editing may be required to make it fully functional' % recipefile)
@@ -1612,6 +1632,26 @@ def status(args, config, basepath, workspace):
1612def _reset(recipes, no_clean, config, basepath, workspace): 1632def _reset(recipes, no_clean, config, basepath, workspace):
1613 """Reset one or more recipes""" 1633 """Reset one or more recipes"""
1614 1634
1635 def clean_preferred_provider(pn, layerconf_path):
1636 """Remove PREFERRED_PROVIDER from layer.conf'"""
1637 import re
1638 layerconf_file = os.path.join(layerconf_path, 'conf', 'layer.conf')
1639 new_layerconf_file = os.path.join(layerconf_path, 'conf', '.layer.conf')
1640 pprovider_found = False
1641 with open(layerconf_file, 'r') as f:
1642 lines = f.readlines()
1643 with open(new_layerconf_file, 'a') as nf:
1644 for line in lines:
1645 pprovider_exp = r'^PREFERRED_PROVIDER_.*? = "' + pn + r'"$'
1646 if not re.match(pprovider_exp, line):
1647 nf.write(line)
1648 else:
1649 pprovider_found = True
1650 if pprovider_found:
1651 shutil.move(new_layerconf_file, layerconf_file)
1652 else:
1653 os.remove(new_layerconf_file)
1654
1615 if recipes and not no_clean: 1655 if recipes and not no_clean:
1616 if len(recipes) == 1: 1656 if len(recipes) == 1:
1617 logger.info('Cleaning sysroot for recipe %s...' % recipes[0]) 1657 logger.info('Cleaning sysroot for recipe %s...' % recipes[0])
@@ -1664,6 +1704,7 @@ def _reset(recipes, no_clean, config, basepath, workspace):
1664 # This is unlikely, but if it's empty we can just remove it 1704 # This is unlikely, but if it's empty we can just remove it
1665 os.rmdir(srctree) 1705 os.rmdir(srctree)
1666 1706
1707 clean_preferred_provider(pn, config.workspace_path)
1667 1708
1668def reset(args, config, basepath, workspace): 1709def reset(args, config, basepath, workspace):
1669 """Entry point for the devtool 'reset' subcommand""" 1710 """Entry point for the devtool 'reset' subcommand"""
@@ -1827,6 +1868,7 @@ def register_commands(subparsers, context):
1827 parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true') 1868 parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
1828 parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') 1869 parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
1829 parser_add.add_argument('--mirrors', help='Enable PREMIRRORS and MIRRORS for source tree fetching (disable by default).', action="store_true") 1870 parser_add.add_argument('--mirrors', help='Enable PREMIRRORS and MIRRORS for source tree fetching (disable by default).', action="store_true")
1871 parser_add.add_argument('--provides', '-p', help='Specify an alias for the item provided by the recipe. E.g. virtual/libgl')
1830 parser_add.set_defaults(func=add, fixed_setup=context.fixed_setup) 1872 parser_add.set_defaults(func=add, fixed_setup=context.fixed_setup)
1831 1873
1832 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe', 1874 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',