summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/recipeutils.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-07-14 09:04:25 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-20 10:28:49 +0100
commitd62fd7711d508a4bd926e46a235d2511401f543d (patch)
tree9968d72a87dc9176a45a7c2b596a2b71404f6753 /meta/lib/oe/recipeutils.py
parent10a5af5eb4f928abe1fe12e63520f656b682d55d (diff)
downloadpoky-d62fd7711d508a4bd926e46a235d2511401f543d.tar.gz
devtool: add finish subcommand
Add a subcommand which will "finish" the work on a recipe. This is effectively the same as update-recipe followed by reset, except that the destination layer is required and it will do the right thing depending on the situation - if the recipe file itself is in the workspace (e.g. as a result of devtool add), the recipe file and any associated files will be moved to the destination layer; or if the destination layer is the one containing the original recipe, the recipe will be overwritten; otherwise a bbappend will be created to apply the changes. In all cases the layer path can be loosely specified - it could be a layer name, or a partial path into a recipe. In the case of upgrades, devtool finish will also take care of deleting the old recipe. This avoids the user having to figure out the correct actions when they're done - they just do "devtool finish recipename layername" and it saves their work and then removes the recipe from the workspace. Addresses [YOCTO #8594]. (From OE-Core rev: fa550fcb9333d59b28fc0e4aebde888831410f5c) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/recipeutils.py')
-rw-r--r--meta/lib/oe/recipeutils.py57
1 files changed, 56 insertions, 1 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index b8d481aeb8..0e7abf833b 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -2,7 +2,7 @@
2# 2#
3# Some code borrowed from the OE layer index 3# Some code borrowed from the OE layer index
4# 4#
5# Copyright (C) 2013-2015 Intel Corporation 5# Copyright (C) 2013-2016 Intel Corporation
6# 6#
7 7
8import sys 8import sys
@@ -15,6 +15,7 @@ from . import utils
15import shutil 15import shutil
16import re 16import re
17import fnmatch 17import fnmatch
18import glob
18from collections import OrderedDict, defaultdict 19from collections import OrderedDict, defaultdict
19 20
20 21
@@ -450,6 +451,60 @@ def validate_pn(pn):
450 return '' 451 return ''
451 452
452 453
454def get_bbfile_path(d, destdir, extrapathhint=None):
455 """
456 Determine the correct path for a recipe within a layer
457 Parameters:
458 d: Recipe-specific datastore
459 destdir: destination directory. Can be the path to the base of the layer or a
460 partial path somewhere within the layer.
461 extrapathhint: a path relative to the base of the layer to try
462 """
463 import bb.cookerdata
464
465 destdir = os.path.abspath(destdir)
466 destlayerdir = find_layerdir(destdir)
467
468 # Parse the specified layer's layer.conf file directly, in case the layer isn't in bblayers.conf
469 confdata = d.createCopy()
470 confdata.setVar('BBFILES', '')
471 confdata.setVar('LAYERDIR', destlayerdir)
472 destlayerconf = os.path.join(destlayerdir, "conf", "layer.conf")
473 confdata = bb.cookerdata.parse_config_file(destlayerconf, confdata)
474 pn = d.getVar('PN', True)
475
476 bbfilespecs = (confdata.getVar('BBFILES', True) or '').split()
477 if destdir == destlayerdir:
478 for bbfilespec in bbfilespecs:
479 if not bbfilespec.endswith('.bbappend'):
480 for match in glob.glob(bbfilespec):
481 splitext = os.path.splitext(os.path.basename(match))
482 if splitext[1] == '.bb':
483 mpn = splitext[0].split('_')[0]
484 if mpn == pn:
485 return os.path.dirname(match)
486
487 # Try to make up a path that matches BBFILES
488 # this is a little crude, but better than nothing
489 bpn = d.getVar('BPN', True)
490 recipefn = os.path.basename(d.getVar('FILE', True))
491 pathoptions = [destdir]
492 if extrapathhint:
493 pathoptions.append(os.path.join(destdir, extrapathhint))
494 if destdir == destlayerdir:
495 pathoptions.append(os.path.join(destdir, 'recipes-%s' % bpn, bpn))
496 pathoptions.append(os.path.join(destdir, 'recipes', bpn))
497 pathoptions.append(os.path.join(destdir, bpn))
498 elif not destdir.endswith(('/' + pn, '/' + bpn)):
499 pathoptions.append(os.path.join(destdir, bpn))
500 closepath = ''
501 for pathoption in pathoptions:
502 bbfilepath = os.path.join(pathoption, 'test.bb')
503 for bbfilespec in bbfilespecs:
504 if fnmatch.fnmatchcase(bbfilepath, bbfilespec):
505 return pathoption
506 return None
507
453def get_bbappend_path(d, destlayerdir, wildcardver=False): 508def get_bbappend_path(d, destlayerdir, wildcardver=False):
454 """Determine how a bbappend for a recipe should be named and located within another layer""" 509 """Determine how a bbappend for a recipe should be named and located within another layer"""
455 510