summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/plugins/imager/direct_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/plugins/imager/direct_plugin.py')
-rw-r--r--scripts/lib/mic/plugins/imager/direct_plugin.py107
1 files changed, 107 insertions, 0 deletions
diff --git a/scripts/lib/mic/plugins/imager/direct_plugin.py b/scripts/lib/mic/plugins/imager/direct_plugin.py
new file mode 100644
index 0000000000..fc7c10c3df
--- /dev/null
+++ b/scripts/lib/mic/plugins/imager/direct_plugin.py
@@ -0,0 +1,107 @@
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', based
22# loosely on the raw imager plugin from 'mic'
23#
24# AUTHORS
25# Tom Zanussi <tom.zanussi (at] linux.intel.com>
26#
27
28import os
29import shutil
30import re
31import tempfile
32
33from mic import chroot, msger
34from mic.utils import misc, fs_related, errors, runner, cmdln
35from mic.conf import configmgr
36from mic.plugin import pluginmgr
37from mic.utils.partitionedfs import PartitionedMount
38
39import mic.imager.direct as direct
40from mic.pluginbase import ImagerPlugin
41
42class DirectPlugin(ImagerPlugin):
43 name = 'direct'
44
45 @classmethod
46 def __rootfs_dir_to_dict(self, rootfs_dirs):
47 """
48 Gets a string that contain 'connection=dir' splitted by
49 space and return a dict
50 """
51 krootfs_dir = {}
52 for rootfs_dir in rootfs_dirs.split(' '):
53 k, v = rootfs_dir.split('=')
54 krootfs_dir[k] = v
55
56 return krootfs_dir
57
58 @classmethod
59 def do_create(self, subcmd, opts, *args):
60 """
61 Create direct image, called from creator as 'direct' cmd
62 """
63 if len(args) != 9:
64 raise errors.Usage("Extra arguments given")
65
66 staging_data_dir = args[0]
67 hdddir = args[1]
68 native_sysroot = args[2]
69 kernel_dir = args[3]
70 bootimg_dir = args[4]
71 rootfs_dir = args[5]
72
73 creatoropts = configmgr.create
74 ksconf = args[6]
75
76 image_output_dir = args[7]
77 oe_builddir = args[8]
78
79 krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
80
81 configmgr._ksconf = ksconf
82
83 creator = direct.DirectImageCreator(oe_builddir,
84 image_output_dir,
85 krootfs_dir,
86 bootimg_dir,
87 kernel_dir,
88 native_sysroot,
89 hdddir,
90 staging_data_dir,
91 creatoropts,
92 None,
93 None,
94 None)
95
96 try:
97 creator.mount(None, creatoropts["cachedir"])
98 creator.install()
99 creator.configure(creatoropts["repomd"])
100 creator.print_outimage_info()
101
102 except errors.CreatorError:
103 raise
104 finally:
105 creator.cleanup()
106
107 return 0