aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
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 21:59:57 +0100
commitadeea2fe6895898a5e6006e798898f0f5dabd890 (patch)
treee1a0bc98b425bb4808934bec9dd00ebb60c58a79 /scripts/lib/devtool/standard.py
parent541b14c58132e8460a762617889bd5e3d736c1a4 (diff)
downloadopenembedded-core-contrib-adeea2fe6895898a5e6006e798898f0f5dabd890.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] Signed-off-by: Juan M Cruz Alcaraz <juan.m.cruz.alcaraz@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-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):
extracmdopts += ' --srcrev %s' % args.srcrev
if args.srcbranch:
extracmdopts += ' --srcbranch %s' % args.srcbranch
+ if args.provides:
+ extracmdopts += ' --provides %s' % args.provides
tempdir = tempfile.mkdtemp(prefix='devtool')
try:
@@ -276,6 +278,24 @@ def add(args, config, basepath, workspace):
f.write(' done\n')
f.write('}\n')
+ # Check if the new layer provides recipes whose priorities have been
+ # overriden by PREFERRED_PROVIDER.
+ recipe_name = rd.getVar('PN')
+ provides = rd.getVar('PROVIDES')
+ # Search every item defined in PROVIDES
+ for recipe_provided in provides.split():
+ preferred_provider = 'PREFERRED_PROVIDER_' + recipe_provided
+ current_pprovider = rd.getVar(preferred_provider)
+ if current_pprovider and current_pprovider != recipe_name:
+ if args.fixed_setup:
+ #if we are inside the eSDK add the new PREFERRED_PROVIDER in the workspace layer.conf
+ layerconf_file = os.path.join(config.workspace_path, "conf", "layer.conf")
+ with open(layerconf_file, 'a') as f:
+ f.write('%s = "%s"\n' % (preferred_provider, recipe_name))
+ else:
+ logger.warn('Set \'%s\' in order to use the recipe' % preferred_provider)
+ break
+
_add_md5(config, recipename, appendfile)
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):
def _reset(recipes, no_clean, config, basepath, workspace):
"""Reset one or more recipes"""
+ def clean_preferred_provider(pn, layerconf_path):
+ """Remove PREFERRED_PROVIDER from layer.conf'"""
+ import re
+ layerconf_file = os.path.join(layerconf_path, 'conf', 'layer.conf')
+ new_layerconf_file = os.path.join(layerconf_path, 'conf', '.layer.conf')
+ pprovider_found = False
+ with open(layerconf_file, 'r') as f:
+ lines = f.readlines()
+ with open(new_layerconf_file, 'a') as nf:
+ for line in lines:
+ pprovider_exp = r'^PREFERRED_PROVIDER_.*? = "' + pn + r'"$'
+ if not re.match(pprovider_exp, line):
+ nf.write(line)
+ else:
+ pprovider_found = True
+ if pprovider_found:
+ shutil.move(new_layerconf_file, layerconf_file)
+ else:
+ os.remove(new_layerconf_file)
+
if recipes and not no_clean:
if len(recipes) == 1:
logger.info('Cleaning sysroot for recipe %s...' % recipes[0])
@@ -1664,6 +1704,7 @@ def _reset(recipes, no_clean, config, basepath, workspace):
# This is unlikely, but if it's empty we can just remove it
os.rmdir(srctree)
+ clean_preferred_provider(pn, config.workspace_path)
def reset(args, config, basepath, workspace):
"""Entry point for the devtool 'reset' subcommand"""
@@ -1827,6 +1868,7 @@ def register_commands(subparsers, context):
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')
parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
parser_add.add_argument('--mirrors', help='Enable PREMIRRORS and MIRRORS for source tree fetching (disable by default).', action="store_true")
+ parser_add.add_argument('--provides', '-p', help='Specify an alias for the item provided by the recipe. E.g. virtual/libgl')
parser_add.set_defaults(func=add, fixed_setup=context.fixed_setup)
parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',