summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/device.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2013-08-24 15:31:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-01 22:56:03 +0100
commit9fc88f96d40b17c90bac53b90045a87b2d2cff84 (patch)
tree63010e5aabf895697655baf89bd668d6752b3f97 /scripts/lib/mic/3rdparty/pykickstart/commands/device.py
parent53a1d9a788fd9f970af980da2ab975cca60685c4 (diff)
downloadpoky-9fc88f96d40b17c90bac53b90045a87b2d2cff84.tar.gz
wic: Add mic w/pykickstart
This is the starting point for the implemention described in [YOCTO 3847] which came to the conclusion that it would make sense to use kickstart syntax to implement image creation in OpenEmbedded. I subsequently realized that there was an existing tool that already implemented image creation using kickstart syntax, the Tizen/Meego mic tool. As such, it made sense to use that as a starting point - this commit essentially just copies the relevant Python code from the MIC tool to the scripts/lib dir, where it can be accessed by the previously created wic tool. Most of this will be removed or renamed by later commits, since we're initially focusing on partitioning only. Care should be taken so that we can easily add back any additional functionality should we decide later to expand the tool, though (we may also want to contribute our local changes to the mic tool to the Tizen project if it makes sense, and therefore should avoid gratuitous changes to the original code if possible). Added the /mic subdir from Tizen mic repo as a starting point: git clone git://review.tizen.org/tools/mic.git For reference, the top commit: commit 20164175ddc234a17b8a12c33d04b012347b1530 Author: Gui Chen <gui.chen@intel.com> Date: Sun Jun 30 22:32:16 2013 -0400 bump up to 0.19.2 Also added the /plugins subdir, moved to under the /mic subdir (to match the default plugin_dir location in mic.conf.in, which was renamed to yocto-image.conf (moved and renamed by later patches) and put into /scripts. (From OE-Core rev: 31f0360f1fd4ebc9dfcaed42d1c50d2448b4632e) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/device.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/device.py125
1 files changed, 125 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/device.py b/scripts/lib/mic/3rdparty/pykickstart/commands/device.py
new file mode 100644
index 0000000000..321410e2e2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/device.py
@@ -0,0 +1,125 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24import warnings
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F8_DeviceData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.moduleName = kwargs.get("moduleName", "")
34 self.moduleOpts = kwargs.get("moduleOpts", "")
35
36 def __eq__(self, y):
37 return self.moduleName == y.moduleName
38
39 def __str__(self):
40 retval = BaseData.__str__(self)
41
42 if self.moduleName != "":
43 retval += "device %s" % self.moduleName
44
45 if self.moduleOpts != "":
46 retval += " --opts=\"%s\"" % self.moduleOpts
47
48 return retval + "\n"
49
50class FC3_Device(KickstartCommand):
51 removedKeywords = KickstartCommand.removedKeywords
52 removedAttrs = KickstartCommand.removedAttrs
53
54 def __init__(self, writePriority=0, *args, **kwargs):
55 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
56 self.op = self._getParser()
57
58 self.type = kwargs.get("type", "")
59 self.moduleName = kwargs.get("moduleName", "")
60 self.moduleOpts = kwargs.get("moduleOpts", "")
61
62 def __eq__(self, y):
63 return self.moduleName == y.moduleName
64
65 def __str__(self):
66 retval = KickstartCommand.__str__(self)
67
68 if self.moduleName != "":
69 retval += "device %s %s" % (self.type, self.moduleName)
70
71 if self.moduleOpts != "":
72 retval += " --opts=\"%s\"" % self.moduleOpts
73
74 return retval + "\n"
75
76 def _getParser(self):
77 op = KSOptionParser()
78 op.add_option("--opts", dest="moduleOpts", default="")
79 return op
80
81 def parse(self, args):
82 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
83
84 if len(extra) != 2:
85 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name"))
86
87 self.moduleOpts = opts.moduleOpts
88 self.type = extra[0]
89 self.moduleName = extra[1]
90 return self
91
92class F8_Device(FC3_Device):
93 removedKeywords = FC3_Device.removedKeywords
94 removedAttrs = FC3_Device.removedAttrs
95
96 def __init__(self, writePriority=0, *args, **kwargs):
97 FC3_Device.__init__(self, writePriority, *args, **kwargs)
98 self.deviceList = kwargs.get("deviceList", [])
99
100 def __str__(self):
101 retval = ""
102 for device in self.deviceList:
103 retval += device.__str__()
104
105 return retval
106
107 def parse(self, args):
108 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
109
110 if len(extra) != 1:
111 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))
112
113 dd = F8_DeviceData()
114 self._setToObj(self.op, opts, dd)
115 dd.lineno = self.lineno
116 dd.moduleName = extra[0]
117
118 # Check for duplicates in the data list.
119 if dd in self.dataList():
120 warnings.warn(_("A module with the name %s has already been defined.") % dd.moduleName)
121
122 return dd
123
124 def dataList(self):
125 return self.deviceList