diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-01-31 13:32:03 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-02 17:37:44 +0000 |
commit | 2d6f96048eb698f741b33c533b8eb15c19cc1f1d (patch) | |
tree | 8eab74694969f7f17aff4034ec2ca2b01dee1ecd | |
parent | 759c24c404509b9d415d6f05e316553503b376b4 (diff) | |
download | poky-2d6f96048eb698f741b33c533b8eb15c19cc1f1d.tar.gz |
wic: move 2 APIs to wic.engine
Moved find_canned and get_custom_config APIs to engine module.
Removed empty wic.utils.misc module.
[YOCTO #10619]
(From OE-Core rev: 10e9afac46575d3f557b7cb505daa31ce9ce85fa)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/wic/engine.py | 33 | ||||
-rw-r--r-- | scripts/lib/wic/ksparser.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 4 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/utils/misc.py | 56 |
6 files changed, 37 insertions, 62 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 2adef2f99f..4abea87273 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -32,7 +32,6 @@ import os | |||
32 | import sys | 32 | import sys |
33 | 33 | ||
34 | from wic import msger, creator | 34 | from wic import msger, creator |
35 | from wic.utils import misc | ||
36 | from wic.plugin import pluginmgr | 35 | from wic.plugin import pluginmgr |
37 | from wic.utils.oe import misc | 36 | from wic.utils.oe import misc |
38 | 37 | ||
@@ -226,3 +225,35 @@ def wic_list(args, scripts_path): | |||
226 | return True | 225 | return True |
227 | 226 | ||
228 | return False | 227 | return False |
228 | |||
229 | def find_canned(scripts_path, file_name): | ||
230 | """ | ||
231 | Find a file either by its path or by name in the canned files dir. | ||
232 | |||
233 | Return None if not found | ||
234 | """ | ||
235 | if os.path.exists(file_name): | ||
236 | return file_name | ||
237 | |||
238 | layers_canned_wks_dir = build_canned_image_list(scripts_path) | ||
239 | for canned_wks_dir in layers_canned_wks_dir: | ||
240 | for root, dirs, files in os.walk(canned_wks_dir): | ||
241 | for fname in files: | ||
242 | if fname == file_name: | ||
243 | fullpath = os.path.join(canned_wks_dir, fname) | ||
244 | return fullpath | ||
245 | |||
246 | def get_custom_config(boot_file): | ||
247 | """ | ||
248 | Get the custom configuration to be used for the bootloader. | ||
249 | |||
250 | Return None if the file can't be found. | ||
251 | """ | ||
252 | # Get the scripts path of poky | ||
253 | scripts_path = os.path.abspath("%s/../.." % os.path.dirname(__file__)) | ||
254 | |||
255 | cfg_file = find_canned(scripts_path, boot_file) | ||
256 | if cfg_file: | ||
257 | with open(cfg_file, "r") as f: | ||
258 | config = f.read() | ||
259 | return config | ||
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index 62c490274a..41d3cc667f 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py | |||
@@ -30,8 +30,8 @@ import shlex | |||
30 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 30 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError |
31 | 31 | ||
32 | from wic import msger | 32 | from wic import msger |
33 | from wic.engine import find_canned | ||
33 | from wic.partition import Partition | 34 | from wic.partition import Partition |
34 | from wic.utils.misc import find_canned | ||
35 | 35 | ||
36 | class KickStartError(Exception): | 36 | class KickStartError(Exception): |
37 | """Custom exception.""" | 37 | """Custom exception.""" |
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 74a1557f91..28b941ed41 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -28,8 +28,8 @@ import os | |||
28 | import shutil | 28 | import shutil |
29 | 29 | ||
30 | from wic import msger | 30 | from wic import msger |
31 | from wic.engine import get_custom_config | ||
31 | from wic.pluginbase import SourcePlugin | 32 | from wic.pluginbase import SourcePlugin |
32 | from wic.utils.misc import get_custom_config | ||
33 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ | 33 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ |
34 | BOOTDD_EXTRA_SPACE | 34 | BOOTDD_EXTRA_SPACE |
35 | 35 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index cff8aec059..283b8340b2 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py | |||
@@ -26,10 +26,10 @@ | |||
26 | 26 | ||
27 | import os | 27 | import os |
28 | 28 | ||
29 | from wic.utils.errors import ImageError | ||
30 | from wic import msger | 29 | from wic import msger |
30 | from wic.engine import get_custom_config | ||
31 | from wic.utils import runner | 31 | from wic.utils import runner |
32 | from wic.utils.misc import get_custom_config | 32 | from wic.utils.errors import ImageError |
33 | from wic.pluginbase import SourcePlugin | 33 | from wic.pluginbase import SourcePlugin |
34 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \ | 34 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \ |
35 | get_bitbake_var, BOOTDD_EXTRA_SPACE | 35 | get_bitbake_var, BOOTDD_EXTRA_SPACE |
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py index bceaa84398..4979d8e0bf 100644 --- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py +++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py | |||
@@ -26,8 +26,8 @@ import shutil | |||
26 | import glob | 26 | import glob |
27 | 27 | ||
28 | from wic import msger | 28 | from wic import msger |
29 | from wic.engine import get_custom_config | ||
29 | from wic.pluginbase import SourcePlugin | 30 | from wic.pluginbase import SourcePlugin |
30 | from wic.utils.misc import get_custom_config | ||
31 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var | 31 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var |
32 | 32 | ||
33 | class IsoImagePlugin(SourcePlugin): | 33 | class IsoImagePlugin(SourcePlugin): |
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py deleted file mode 100644 index 7d09f6fc26..0000000000 --- a/scripts/lib/wic/utils/misc.py +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | #!/usr/bin/env python -tt | ||
2 | # | ||
3 | # Copyright (c) 2010, 2011 Intel Inc. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify it | ||
6 | # under the terms of the GNU General Public License as published by the Free | ||
7 | # Software Foundation; version 2 of the License | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | # for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License along | ||
15 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
16 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | |||
18 | import os | ||
19 | import time | ||
20 | import wic.engine | ||
21 | |||
22 | def find_canned(scripts_path, file_name): | ||
23 | """ | ||
24 | Find a file either by its path or by name in the canned files dir. | ||
25 | |||
26 | Return None if not found | ||
27 | """ | ||
28 | if os.path.exists(file_name): | ||
29 | return file_name | ||
30 | |||
31 | layers_canned_wks_dir = wic.engine.build_canned_image_list(scripts_path) | ||
32 | for canned_wks_dir in layers_canned_wks_dir: | ||
33 | for root, dirs, files in os.walk(canned_wks_dir): | ||
34 | for fname in files: | ||
35 | if fname == file_name: | ||
36 | fullpath = os.path.join(canned_wks_dir, fname) | ||
37 | return fullpath | ||
38 | |||
39 | def get_custom_config(boot_file): | ||
40 | """ | ||
41 | Get the custom configuration to be used for the bootloader. | ||
42 | |||
43 | Return None if the file can't be found. | ||
44 | """ | ||
45 | scripts_path = os.path.abspath(os.path.dirname(__file__)) | ||
46 | # Get the scripts path of poky | ||
47 | for x in range(0, 3): | ||
48 | scripts_path = os.path.dirname(scripts_path) | ||
49 | |||
50 | cfg_file = find_canned(scripts_path, boot_file) | ||
51 | if cfg_file: | ||
52 | with open(cfg_file, "r") as f: | ||
53 | config = f.read() | ||
54 | return config | ||
55 | |||
56 | return None | ||