summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.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/driverdisk.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/driverdisk.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py184
1 files changed, 184 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
new file mode 100644
index 0000000000..82a58c0e28
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
@@ -0,0 +1,184 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 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
24_ = lambda x: gettext.ldgettext("pykickstart", x)
25
26class FC3_DriverDiskData(BaseData):
27 removedKeywords = BaseData.removedKeywords
28 removedAttrs = BaseData.removedAttrs
29
30 def __init__(self, writePriority=0, *args, **kwargs):
31 BaseData.__init__(self, *args, **kwargs)
32
33 self.partition = kwargs.get("partition", "")
34 self.source = kwargs.get("source", "")
35 self.type = kwargs.get("type", "")
36
37 def _getArgsAsStr(self):
38 retval = ""
39
40 if self.partition:
41 retval += "%s" % self.partition
42
43 if hasattr(self, "type") and self.type:
44 retval += " --type=%s" % self.type
45 elif self.source:
46 retval += "--source=%s" % self.source
47 return retval
48
49 def __str__(self):
50 retval = BaseData.__str__(self)
51 retval += "driverdisk %s\n" % self._getArgsAsStr()
52 return retval
53
54class FC4_DriverDiskData(FC3_DriverDiskData):
55 removedKeywords = FC3_DriverDiskData.removedKeywords
56 removedAttrs = FC3_DriverDiskData.removedAttrs
57
58 def __init__(self, writePriority=0, *args, **kwargs):
59 FC3_DriverDiskData.__init__(self, *args, **kwargs)
60 self.deleteRemovedAttrs()
61
62 self.biospart = kwargs.get("biospart", "")
63
64 def _getArgsAsStr(self):
65 retval = ""
66
67 if self.partition:
68 retval += "%s" % self.partition
69
70 if hasattr(self, "type") and self.type:
71 retval += " --type=%s" % self.type
72 elif self.source:
73 retval += "--source=%s" % self.source
74 elif self.biospart:
75 retval += "--biospart=%s" % self.biospart
76
77 return retval
78
79class F12_DriverDiskData(FC4_DriverDiskData):
80 removedKeywords = FC4_DriverDiskData.removedKeywords + ["type"]
81 removedAttrs = FC4_DriverDiskData.removedAttrs + ["type"]
82
83 def __init__(self, *args, **kwargs):
84 FC4_DriverDiskData.__init__(self, *args, **kwargs)
85 self.deleteRemovedAttrs()
86
87F14_DriverDiskData = F12_DriverDiskData
88
89class FC3_DriverDisk(KickstartCommand):
90 removedKeywords = KickstartCommand.removedKeywords
91 removedAttrs = KickstartCommand.removedAttrs
92
93 def __init__(self, writePriority=0, *args, **kwargs):
94 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
95 self.op = self._getParser()
96
97 self.driverdiskList = kwargs.get("driverdiskList", [])
98
99 def __str__(self):
100 retval = ""
101 for dd in self.driverdiskList:
102 retval += dd.__str__()
103
104 return retval
105
106 def _getParser(self):
107 op = KSOptionParser()
108 op.add_option("--source")
109 op.add_option("--type")
110 return op
111
112 def parse(self, args):
113 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
114
115 if len(extra) > 1:
116 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
117
118 if len(extra) == 1 and opts.source:
119 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
120
121 if not extra and not opts.source:
122 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))
123
124 ddd = self.handler.DriverDiskData()
125 self._setToObj(self.op, opts, ddd)
126 ddd.lineno = self.lineno
127 if len(extra) == 1:
128 ddd.partition = extra[0]
129
130 return ddd
131
132 def dataList(self):
133 return self.driverdiskList
134
135class FC4_DriverDisk(FC3_DriverDisk):
136 removedKeywords = FC3_DriverDisk.removedKeywords
137 removedAttrs = FC3_DriverDisk.removedKeywords
138
139 def _getParser(self):
140 op = FC3_DriverDisk._getParser(self)
141 op.add_option("--biospart")
142 return op
143
144 def parse(self, args):
145 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
146
147 if len(extra) > 1:
148 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
149
150 if len(extra) == 1 and opts.source:
151 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
152 elif len(extra) == 1 and opts.biospart:
153 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command."))
154 elif opts.source and opts.biospart:
155 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command."))
156
157 if not extra and not opts.source and not opts.biospart:
158 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command."))
159
160 ddd = self.handler.DriverDiskData()
161 self._setToObj(self.op, opts, ddd)
162 ddd.lineno = self.lineno
163 if len(extra) == 1:
164 ddd.partition = extra[0]
165
166 return ddd
167
168class F12_DriverDisk(FC4_DriverDisk):
169 removedKeywords = FC4_DriverDisk.removedKeywords
170 removedAttrs = FC4_DriverDisk.removedKeywords
171
172 def _getParser(self):
173 op = FC4_DriverDisk._getParser(self)
174 op.add_option("--type", deprecated=1)
175 return op
176
177class F14_DriverDisk(F12_DriverDisk):
178 removedKeywords = F12_DriverDisk.removedKeywords
179 removedAttrs = F12_DriverDisk.removedKeywords
180
181 def _getParser(self):
182 op = F12_DriverDisk._getParser(self)
183 op.remove_option("--type")
184 return op