diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/image/engine.py | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/scripts/lib/image/engine.py b/scripts/lib/image/engine.py index 311737a5c0..3bda1bf205 100644 --- a/scripts/lib/image/engine.py +++ b/scripts/lib/image/engine.py | |||
| @@ -90,6 +90,20 @@ def find_artifacts(image_name): | |||
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts | 92 | CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts |
| 93 | SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR | ||
| 94 | |||
| 95 | def build_canned_image_list(dl): | ||
| 96 | layers_path = get_bitbake_var("BBLAYERS") | ||
| 97 | canned_wks_layer_dirs = [] | ||
| 98 | |||
| 99 | for layer_path in layers_path.split(): | ||
| 100 | path = os.path.join(layer_path, SCRIPTS_CANNED_IMAGE_DIR) | ||
| 101 | canned_wks_layer_dirs.append(path) | ||
| 102 | |||
| 103 | path = os.path.join(dl, CANNED_IMAGE_DIR) | ||
| 104 | canned_wks_layer_dirs.append(path) | ||
| 105 | |||
| 106 | return canned_wks_layer_dirs | ||
| 93 | 107 | ||
| 94 | def find_canned_image(scripts_path, wks_file): | 108 | def find_canned_image(scripts_path, wks_file): |
| 95 | """ | 109 | """ |
| @@ -97,15 +111,16 @@ def find_canned_image(scripts_path, wks_file): | |||
| 97 | 111 | ||
| 98 | Return False if not found | 112 | Return False if not found |
| 99 | """ | 113 | """ |
| 100 | canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR) | 114 | layers_canned_wks_dir = build_canned_image_list(scripts_path) |
| 101 | 115 | ||
| 102 | for root, dirs, files in os.walk(canned_wks_dir): | 116 | for canned_wks_dir in layers_canned_wks_dir: |
| 103 | for file in files: | 117 | for root, dirs, files in os.walk(canned_wks_dir): |
| 104 | if file.endswith("~") or file.endswith("#"): | 118 | for file in files: |
| 105 | continue | 119 | if file.endswith("~") or file.endswith("#"): |
| 106 | if file.endswith(".wks") and wks_file + ".wks" == file: | 120 | continue |
| 107 | fullpath = os.path.join(canned_wks_dir, file) | 121 | if file.endswith(".wks") and wks_file + ".wks" == file: |
| 108 | return fullpath | 122 | fullpath = os.path.join(canned_wks_dir, file) |
| 123 | return fullpath | ||
| 109 | return None | 124 | return None |
| 110 | 125 | ||
| 111 | 126 | ||
| @@ -113,32 +128,31 @@ def list_canned_images(scripts_path): | |||
| 113 | """ | 128 | """ |
| 114 | List the .wks files in the canned image dir, minus the extension. | 129 | List the .wks files in the canned image dir, minus the extension. |
| 115 | """ | 130 | """ |
| 116 | canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR) | 131 | layers_canned_wks_dir = build_canned_image_list(scripts_path) |
| 117 | 132 | ||
| 118 | for root, dirs, files in os.walk(canned_wks_dir): | 133 | for canned_wks_dir in layers_canned_wks_dir: |
| 119 | for file in files: | 134 | for root, dirs, files in os.walk(canned_wks_dir): |
| 120 | if file.endswith("~") or file.endswith("#"): | 135 | for file in files: |
| 121 | continue | 136 | if file.endswith("~") or file.endswith("#"): |
| 122 | if file.endswith(".wks"): | 137 | continue |
| 123 | fullpath = os.path.join(canned_wks_dir, file) | 138 | if file.endswith(".wks"): |
| 124 | f = open(fullpath, "r") | 139 | fullpath = os.path.join(canned_wks_dir, file) |
| 125 | lines = f.readlines() | 140 | f = open(fullpath, "r") |
| 126 | for line in lines: | 141 | lines = f.readlines() |
| 127 | desc = "" | 142 | for line in lines: |
| 128 | idx = line.find("short-description:") | 143 | desc = "" |
| 129 | if idx != -1: | 144 | idx = line.find("short-description:") |
| 130 | desc = line[idx + len("short-description:"):].strip() | 145 | if idx != -1: |
| 131 | break | 146 | desc = line[idx + len("short-description:"):].strip() |
| 132 | basename = os.path.splitext(file)[0] | 147 | break |
| 133 | print " %s\t\t%s" % (basename, desc) | 148 | basename = os.path.splitext(file)[0] |
| 149 | print " %s\t\t%s" % (basename.ljust(30), desc) | ||
| 134 | 150 | ||
| 135 | 151 | ||
| 136 | def list_canned_image_help(scripts_path, fullpath): | 152 | def list_canned_image_help(scripts_path, fullpath): |
| 137 | """ | 153 | """ |
| 138 | List the help and params in the specified canned image. | 154 | List the help and params in the specified canned image. |
| 139 | """ | 155 | """ |
| 140 | canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR) | ||
| 141 | |||
| 142 | f = open(fullpath, "r") | 156 | f = open(fullpath, "r") |
| 143 | lines = f.readlines() | 157 | lines = f.readlines() |
| 144 | found = False | 158 | found = False |
