summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-01-31 13:32:03 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-02 17:37:44 +0000
commit2d6f96048eb698f741b33c533b8eb15c19cc1f1d (patch)
tree8eab74694969f7f17aff4034ec2ca2b01dee1ecd
parent759c24c404509b9d415d6f05e316553503b376b4 (diff)
downloadpoky-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.py33
-rw-r--r--scripts/lib/wic/ksparser.py2
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py2
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py4
-rw-r--r--scripts/lib/wic/plugins/source/isoimage-isohybrid.py2
-rw-r--r--scripts/lib/wic/utils/misc.py56
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
32import sys 32import sys
33 33
34from wic import msger, creator 34from wic import msger, creator
35from wic.utils import misc
36from wic.plugin import pluginmgr 35from wic.plugin import pluginmgr
37from wic.utils.oe import misc 36from 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
229def 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
246def 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
30from argparse import ArgumentParser, ArgumentError, ArgumentTypeError 30from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
31 31
32from wic import msger 32from wic import msger
33from wic.engine import find_canned
33from wic.partition import Partition 34from wic.partition import Partition
34from wic.utils.misc import find_canned
35 35
36class KickStartError(Exception): 36class 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
28import shutil 28import shutil
29 29
30from wic import msger 30from wic import msger
31from wic.engine import get_custom_config
31from wic.pluginbase import SourcePlugin 32from wic.pluginbase import SourcePlugin
32from wic.utils.misc import get_custom_config
33from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ 33from 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
27import os 27import os
28 28
29from wic.utils.errors import ImageError
30from wic import msger 29from wic import msger
30from wic.engine import get_custom_config
31from wic.utils import runner 31from wic.utils import runner
32from wic.utils.misc import get_custom_config 32from wic.utils.errors import ImageError
33from wic.pluginbase import SourcePlugin 33from wic.pluginbase import SourcePlugin
34from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \ 34from 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
26import glob 26import glob
27 27
28from wic import msger 28from wic import msger
29from wic.engine import get_custom_config
29from wic.pluginbase import SourcePlugin 30from wic.pluginbase import SourcePlugin
30from wic.utils.misc import get_custom_config
31from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var 31from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var
32 32
33class IsoImagePlugin(SourcePlugin): 33class 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
18import os
19import time
20import wic.engine
21
22def 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
39def 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