summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/imager/direct_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/imager/direct_plugin.py')
-rw-r--r--scripts/lib/wic/plugins/imager/direct_plugin.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py
new file mode 100644
index 0000000000..5601c3f1c9
--- /dev/null
+++ b/scripts/lib/wic/plugins/imager/direct_plugin.py
@@ -0,0 +1,98 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# Copyright (c) 2013, Intel Corporation.
5# All rights reserved.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#
20# DESCRIPTION
21# This implements the 'direct' imager plugin class for 'wic'
22#
23# AUTHORS
24# Tom Zanussi <tom.zanussi (at] linux.intel.com>
25#
26
27import os
28import shutil
29import re
30import tempfile
31
32from wic import msger
33from wic.utils import misc, fs_related, errors, runner, cmdln
34from wic.conf import configmgr
35from wic.plugin import pluginmgr
36
37import wic.imager.direct as direct
38from wic.pluginbase import ImagerPlugin
39
40class DirectPlugin(ImagerPlugin):
41 name = 'direct'
42
43 @classmethod
44 def __rootfs_dir_to_dict(self, rootfs_dirs):
45 """
46 Gets a string that contain 'connection=dir' splitted by
47 space and return a dict
48 """
49 krootfs_dir = {}
50 for rootfs_dir in rootfs_dirs.split(' '):
51 k, v = rootfs_dir.split('=')
52 krootfs_dir[k] = v
53
54 return krootfs_dir
55
56 @classmethod
57 def do_create(self, subcmd, opts, *args):
58 """
59 Create direct image, called from creator as 'direct' cmd
60 """
61 if len(args) != 7:
62 raise errors.Usage("Extra arguments given")
63
64 native_sysroot = args[0]
65 kernel_dir = args[1]
66 bootimg_dir = args[2]
67 rootfs_dir = args[3]
68
69 creatoropts = configmgr.create
70 ksconf = args[4]
71
72 image_output_dir = args[5]
73 oe_builddir = args[6]
74
75 krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
76
77 configmgr._ksconf = ksconf
78
79 creator = direct.DirectImageCreator(oe_builddir,
80 image_output_dir,
81 krootfs_dir,
82 bootimg_dir,
83 kernel_dir,
84 native_sysroot,
85 creatoropts)
86
87 try:
88 creator.create()
89 creator.assemble()
90 creator.finalize()
91 creator.print_outimage_info()
92
93 except errors.CreatorError:
94 raise
95 finally:
96 creator.cleanup()
97
98 return 0