diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/bsp/kernel.py | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index a953372e8f..0b7e69bcb9 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py | |||
@@ -133,6 +133,30 @@ def gen_choices_str(choices): | |||
133 | return choices_str | 133 | return choices_str |
134 | 134 | ||
135 | 135 | ||
136 | def open_user_file(scripts_path, machine, userfile, mode): | ||
137 | """ | ||
138 | Find one of the user files (user-config.cfg, user-patches.scc) | ||
139 | associated with the machine (could be in files/, | ||
140 | linux-yocto-custom/, etc). Returns the open file if found, None | ||
141 | otherwise. | ||
142 | |||
143 | The caller is responsible for closing the file returned. | ||
144 | """ | ||
145 | layer = find_bsp_layer(scripts_path, machine) | ||
146 | linuxdir = os.path.join(layer, "recipes-kernel/linux") | ||
147 | linuxdir_list = os.listdir(linuxdir) | ||
148 | for fileobj in linuxdir_list: | ||
149 | fileobj_path = os.path.join(linuxdir, fileobj) | ||
150 | if os.path.isdir(fileobj_path): | ||
151 | userfile_name = os.path.join(fileobj_path, userfile) | ||
152 | try: | ||
153 | f = open(userfile_name, mode) | ||
154 | return f | ||
155 | except IOError: | ||
156 | continue | ||
157 | return None | ||
158 | |||
159 | |||
136 | def read_config_items(scripts_path, machine): | 160 | def read_config_items(scripts_path, machine): |
137 | """ | 161 | """ |
138 | Find and return a list of config items (CONFIG_XXX) in a machine's | 162 | Find and return a list of config items (CONFIG_XXX) in a machine's |
@@ -140,10 +164,7 @@ def read_config_items(scripts_path, machine): | |||
140 | """ | 164 | """ |
141 | config_items = [] | 165 | config_items = [] |
142 | 166 | ||
143 | layer = find_bsp_layer(scripts_path, machine) | 167 | f = open_user_file(scripts_path, machine, "user-config.cfg", "r") |
144 | cfg = os.path.join(layer, "recipes-kernel/linux/files/user-config.cfg") | ||
145 | |||
146 | f = open(cfg, "r") | ||
147 | lines = f.readlines() | 168 | lines = f.readlines() |
148 | for line in lines: | 169 | for line in lines: |
149 | s = line.strip() | 170 | s = line.strip() |
@@ -159,10 +180,7 @@ def write_config_items(scripts_path, machine, config_items): | |||
159 | Write (replace) the list of config items (CONFIG_XXX) in a | 180 | Write (replace) the list of config items (CONFIG_XXX) in a |
160 | machine's user-defined config fragment [user-config.cfg]. | 181 | machine's user-defined config fragment [user-config.cfg]. |
161 | """ | 182 | """ |
162 | layer = find_bsp_layer(scripts_path, machine) | 183 | f = open_user_file(scripts_path, machine, "user-config.cfg", "w") |
163 | cfg = os.path.join(layer, "recipes-kernel/linux/files/user-config.cfg") | ||
164 | |||
165 | f = open(cfg, "w") | ||
166 | for item in config_items: | 184 | for item in config_items: |
167 | f.write(item + "\n") | 185 | f.write(item + "\n") |
168 | f.close() | 186 | f.close() |
@@ -377,10 +395,7 @@ def read_patch_items(scripts_path, machine): | |||
377 | """ | 395 | """ |
378 | patch_items = [] | 396 | patch_items = [] |
379 | 397 | ||
380 | layer = find_bsp_layer(scripts_path, machine) | 398 | f = open_user_file(scripts_path, machine, "user-patches.scc", "r") |
381 | patches = os.path.join(layer, "recipes-kernel/linux/files/user-patches.scc") | ||
382 | |||
383 | f = open(patches, "r") | ||
384 | lines = f.readlines() | 399 | lines = f.readlines() |
385 | for line in lines: | 400 | for line in lines: |
386 | s = line.strip() | 401 | s = line.strip() |
@@ -399,11 +414,7 @@ def write_patch_items(scripts_path, machine, patch_items): | |||
399 | Write (replace) the list of patches in a machine's user-defined | 414 | Write (replace) the list of patches in a machine's user-defined |
400 | patch list [user-patches.scc]. | 415 | patch list [user-patches.scc]. |
401 | """ | 416 | """ |
402 | layer = find_bsp_layer(scripts_path, machine) | 417 | f = open_user_file(scripts_path, machine, "user-patches.scc", "w") |
403 | |||
404 | patches = os.path.join(layer, "recipes-kernel/linux/files/user-patches.scc") | ||
405 | |||
406 | f = open(patches, "w") | ||
407 | for item in patch_items: | 418 | for item in patch_items: |
408 | pass | 419 | pass |
409 | # this currently breaks do_patch, but is really what we want | 420 | # this currently breaks do_patch, but is really what we want |