diff options
| author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2013-10-04 09:37:38 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-10-04 16:07:46 +0100 |
| commit | 104166c804e9068d85ccdaa887a33df72c8aeb85 (patch) | |
| tree | 58d5eaa13f00f764ba6def4d85228a33ddbe37f2 /scripts/lib/bsp/kernel.py | |
| parent | bdfd716b7b66419d589d87457fad1528f894c3bb (diff) | |
| download | poky-104166c804e9068d85ccdaa887a33df72c8aeb85.tar.gz | |
yocto-kernel: Use variable-substituted BBLAYERS
The current find_bblayers() code finds and parses the BBLAYERS
variable manually, and therefore doesn't handle variable substitution,
which causes problems if used.
This change makes find_bblayers() use the variable-substituted
BBLAYERS instead.
Fixes [YOCTO #5106]
(From meta-yocto rev: 1629ac04e909143dc2c275c256094cb44c6cc43c)
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/bsp/kernel.py')
| -rw-r--r-- | scripts/lib/bsp/kernel.py | 93 |
1 files changed, 38 insertions, 55 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index 1971e9009b..5696ca77fb 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py | |||
| @@ -35,7 +35,7 @@ import subprocess | |||
| 35 | from engine import create_context | 35 | from engine import create_context |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | def find_bblayers(scripts_path): | 38 | def find_bblayers(): |
| 39 | """ | 39 | """ |
| 40 | Find and return a sanitized list of the layers found in BBLAYERS. | 40 | Find and return a sanitized list of the layers found in BBLAYERS. |
| 41 | """ | 41 | """ |
| @@ -48,67 +48,50 @@ def find_bblayers(scripts_path): | |||
| 48 | 48 | ||
| 49 | layers = [] | 49 | layers = [] |
| 50 | 50 | ||
| 51 | f = open(bblayers_conf, "r") | 51 | bitbake_env_cmd = "bitbake -e" |
| 52 | lines = f.readlines() | 52 | bitbake_env_lines = subprocess.Popen(bitbake_env_cmd, shell=True, |
| 53 | bblayers_lines = [] | 53 | stdout=subprocess.PIPE).stdout.read() |
| 54 | in_bblayers = False | 54 | |
| 55 | for line in lines: | 55 | if not bitbake_env_lines: |
| 56 | line = line.strip() | 56 | print "Couldn't get '%s' output, exiting." % bitbake_env_cmd |
| 57 | tokens = line.split() | ||
| 58 | if len(tokens) > 0 and tokens[0] == 'BBLAYERS': | ||
| 59 | bblayers_lines.append(line) | ||
| 60 | in_bblayers = True | ||
| 61 | quotes = line.strip().count('"') | ||
| 62 | if quotes > 1: | ||
| 63 | in_bblayers = False | ||
| 64 | continue | ||
| 65 | if in_bblayers: | ||
| 66 | bblayers_lines.append(line) | ||
| 67 | if line.strip().endswith("\""): | ||
| 68 | in_bblayers = False | ||
| 69 | |||
| 70 | for i, line in enumerate(bblayers_lines): | ||
| 71 | if line.strip().endswith("\\"): | ||
| 72 | bblayers_lines[i] = line.strip().replace('\\', '') | ||
| 73 | |||
| 74 | bblayers_line = " ".join(bblayers_lines) | ||
| 75 | |||
| 76 | openquote = '' | ||
| 77 | for c in bblayers_line: | ||
| 78 | if c == '\"' or c == '\'': | ||
| 79 | if openquote: | ||
| 80 | if c != openquote: | ||
| 81 | print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf | ||
| 82 | sys.exit(1) | ||
| 83 | else: | ||
| 84 | openquote = '' | ||
| 85 | else: | ||
| 86 | openquote = c | ||
| 87 | |||
| 88 | if openquote: | ||
| 89 | print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf | ||
| 90 | sys.exit(1) | 57 | sys.exit(1) |
| 91 | 58 | ||
| 92 | bblayers_line = bblayers_line.strip().replace('\"', '') | 59 | for line in bitbake_env_lines.split('\n'): |
| 93 | bblayers_line = bblayers_line.strip().replace('\'', '') | 60 | bblayers = get_line_val(line, "BBLAYERS") |
| 61 | if (bblayers): | ||
| 62 | break | ||
| 63 | |||
| 64 | if not bblayers: | ||
| 65 | print "Couldn't find BBLAYERS in 'bitbake -e' output, exiting." % \ | ||
| 66 | bitbake_env_cmd | ||
| 67 | sys.exit(1) | ||
| 94 | 68 | ||
| 95 | raw_layers = bblayers_line.split() | 69 | raw_layers = bblayers.split() |
| 96 | 70 | ||
| 97 | for layer in raw_layers: | 71 | for layer in raw_layers: |
| 98 | if layer == 'BBLAYERS' or '=' in layer: | 72 | if layer == 'BBLAYERS' or '=' in layer: |
| 99 | continue | 73 | continue |
| 100 | layers.append(layer) | 74 | layers.append(layer) |
| 101 | 75 | ||
| 102 | f.close() | ||
| 103 | |||
| 104 | return layers | 76 | return layers |
| 105 | 77 | ||
| 106 | 78 | ||
| 107 | def find_meta_layer(scripts_path): | 79 | def get_line_val(line, key): |
| 80 | """ | ||
| 81 | Extract the value from the VAR="val" string | ||
| 82 | """ | ||
| 83 | if line.startswith(key + "="): | ||
| 84 | stripped_line = line.split('=')[1] | ||
| 85 | stripped_line = stripped_line.replace('\"', '') | ||
| 86 | return stripped_line | ||
| 87 | return None | ||
| 88 | |||
| 89 | |||
| 90 | def find_meta_layer(): | ||
| 108 | """ | 91 | """ |
| 109 | Find and return the meta layer in BBLAYERS. | 92 | Find and return the meta layer in BBLAYERS. |
| 110 | """ | 93 | """ |
| 111 | layers = find_bblayers(scripts_path) | 94 | layers = find_bblayers() |
| 112 | 95 | ||
| 113 | for layer in layers: | 96 | for layer in layers: |
| 114 | if layer.endswith("meta"): | 97 | if layer.endswith("meta"): |
| @@ -117,11 +100,11 @@ def find_meta_layer(scripts_path): | |||
| 117 | return None | 100 | return None |
| 118 | 101 | ||
| 119 | 102 | ||
| 120 | def find_bsp_layer(scripts_path, machine): | 103 | def find_bsp_layer(machine): |
| 121 | """ | 104 | """ |
| 122 | Find and return a machine's BSP layer in BBLAYERS. | 105 | Find and return a machine's BSP layer in BBLAYERS. |
| 123 | """ | 106 | """ |
| 124 | layers = find_bblayers(scripts_path) | 107 | layers = find_bblayers() |
| 125 | 108 | ||
| 126 | for layer in layers: | 109 | for layer in layers: |
| 127 | if layer.endswith(machine): | 110 | if layer.endswith(machine): |
| @@ -154,7 +137,7 @@ def open_user_file(scripts_path, machine, userfile, mode): | |||
| 154 | 137 | ||
| 155 | The caller is responsible for closing the file returned. | 138 | The caller is responsible for closing the file returned. |
| 156 | """ | 139 | """ |
| 157 | layer = find_bsp_layer(scripts_path, machine) | 140 | layer = find_bsp_layer(machine) |
| 158 | linuxdir = os.path.join(layer, "recipes-kernel/linux") | 141 | linuxdir = os.path.join(layer, "recipes-kernel/linux") |
| 159 | linuxdir_list = os.listdir(linuxdir) | 142 | linuxdir_list = os.listdir(linuxdir) |
| 160 | for fileobj in linuxdir_list: | 143 | for fileobj in linuxdir_list: |
| @@ -309,7 +292,7 @@ def find_filesdir(scripts_path, machine): | |||
| 309 | (could be in files/, linux-yocto-custom/, etc). Returns the name | 292 | (could be in files/, linux-yocto-custom/, etc). Returns the name |
| 310 | of the files dir if found, None otherwise. | 293 | of the files dir if found, None otherwise. |
| 311 | """ | 294 | """ |
| 312 | layer = find_bsp_layer(scripts_path, machine) | 295 | layer = find_bsp_layer(machine) |
| 313 | filesdir = None | 296 | filesdir = None |
| 314 | linuxdir = os.path.join(layer, "recipes-kernel/linux") | 297 | linuxdir = os.path.join(layer, "recipes-kernel/linux") |
| 315 | linuxdir_list = os.listdir(linuxdir) | 298 | linuxdir_list = os.listdir(linuxdir) |
| @@ -474,7 +457,7 @@ def kernel_contents_changed(scripts_path, machine): | |||
| 474 | Do what we need to do to notify the system that the kernel | 457 | Do what we need to do to notify the system that the kernel |
| 475 | recipe's contents have changed. | 458 | recipe's contents have changed. |
| 476 | """ | 459 | """ |
| 477 | layer = find_bsp_layer(scripts_path, machine) | 460 | layer = find_bsp_layer(machine) |
| 478 | 461 | ||
| 479 | kernel = find_current_kernel(layer, machine) | 462 | kernel = find_current_kernel(layer, machine) |
| 480 | if not kernel: | 463 | if not kernel: |
| @@ -561,7 +544,7 @@ def find_giturl(context): | |||
| 561 | filebase = context["filename"] | 544 | filebase = context["filename"] |
| 562 | scripts_path = context["scripts_path"] | 545 | scripts_path = context["scripts_path"] |
| 563 | 546 | ||
| 564 | meta_layer = find_meta_layer(scripts_path) | 547 | meta_layer = find_meta_layer() |
| 565 | 548 | ||
| 566 | kerndir = os.path.join(meta_layer, "recipes-kernel/linux") | 549 | kerndir = os.path.join(meta_layer, "recipes-kernel/linux") |
| 567 | bbglob = os.path.join(kerndir, "*.bb") | 550 | bbglob = os.path.join(kerndir, "*.bb") |
| @@ -739,7 +722,7 @@ def yocto_kernel_available_features_list(scripts_path, machine): | |||
| 739 | Display the list of all the kernel features available for use in | 722 | Display the list of all the kernel features available for use in |
| 740 | BSPs, as gathered from the set of feature sources. | 723 | BSPs, as gathered from the set of feature sources. |
| 741 | """ | 724 | """ |
| 742 | layer = find_bsp_layer(scripts_path, machine) | 725 | layer = find_bsp_layer(machine) |
| 743 | kernel = find_current_kernel(layer, machine) | 726 | kernel = find_current_kernel(layer, machine) |
| 744 | if not kernel: | 727 | if not kernel: |
| 745 | print "Couldn't determine the kernel for this BSP, exiting." | 728 | print "Couldn't determine the kernel for this BSP, exiting." |
| @@ -813,7 +796,7 @@ def yocto_kernel_feature_describe(scripts_path, machine, feature): | |||
| 813 | Display the description of a specific kernel feature available for | 796 | Display the description of a specific kernel feature available for |
| 814 | use in a BSP. | 797 | use in a BSP. |
| 815 | """ | 798 | """ |
| 816 | layer = find_bsp_layer(scripts_path, machine) | 799 | layer = find_bsp_layer(machine) |
| 817 | 800 | ||
| 818 | kernel = find_current_kernel(layer, machine) | 801 | kernel = find_current_kernel(layer, machine) |
| 819 | if not kernel: | 802 | if not kernel: |
