diff options
Diffstat (limited to 'meta/lib/oe/recipeutils.py')
| -rw-r--r-- | meta/lib/oe/recipeutils.py | 57 |
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 | ||
| 8 | import sys | 8 | import sys |
| @@ -15,6 +15,7 @@ from . import utils | |||
| 15 | import shutil | 15 | import shutil |
| 16 | import re | 16 | import re |
| 17 | import fnmatch | 17 | import fnmatch |
| 18 | import glob | ||
| 18 | from collections import OrderedDict, defaultdict | 19 | from collections import OrderedDict, defaultdict |
| 19 | 20 | ||
| 20 | 21 | ||
| @@ -450,6 +451,60 @@ def validate_pn(pn): | |||
| 450 | return '' | 451 | return '' |
| 451 | 452 | ||
| 452 | 453 | ||
| 454 | def 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 | |||
| 453 | def get_bbappend_path(d, destlayerdir, wildcardver=False): | 508 | def 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 | ||
