summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-01-14 14:12:54 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-18 11:47:05 +0000
commitc8272380ceed8dd56237995eecbaca5f4c9645dd (patch)
tree84a1127804fd2ee4e9c9e3cc5fe3967339117db2 /scripts/lib/wic
parentc15ea825e735b14dcf38ddf44a0a4aa7db611144 (diff)
downloadpoky-c8272380ceed8dd56237995eecbaca5f4c9645dd.tar.gz
wic: remove pykickstart code
Removed pykickstart-related code as it's replaced by new kickstart parser. (From OE-Core rev: 30bb1f3b6b832f9be691350581458c5fdaaaad70) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/__init__.py0
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/base.py466
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py20
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py216
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/commands/partition.py314
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/constants.py57
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/errors.py103
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py0
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/handlers/control.py46
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py24
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/ko.py37
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/options.py223
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/parser.py619
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/sections.py244
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/version.py168
-rw-r--r--scripts/lib/wic/kickstart/__init__.py129
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/__init__.py7
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/partition.py526
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/wicboot.py65
19 files changed, 0 insertions, 3264 deletions
diff --git a/scripts/lib/wic/3rdparty/pykickstart/__init__.py b/scripts/lib/wic/3rdparty/pykickstart/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/__init__.py
+++ /dev/null
diff --git a/scripts/lib/wic/3rdparty/pykickstart/base.py b/scripts/lib/wic/3rdparty/pykickstart/base.py
deleted file mode 100644
index e6c8f56f9d..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/base.py
+++ /dev/null
@@ -1,466 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 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#
20"""
21Base classes for creating commands and syntax version object.
22
23This module exports several important base classes:
24
25 BaseData - The base abstract class for all data objects. Data objects
26 are contained within a BaseHandler object.
27
28 BaseHandler - The base abstract class from which versioned kickstart
29 handler are derived. Subclasses of BaseHandler hold
30 BaseData and KickstartCommand objects.
31
32 DeprecatedCommand - An abstract subclass of KickstartCommand that should
33 be further subclassed by users of this module. When
34 a subclass is used, a warning message will be
35 printed.
36
37 KickstartCommand - The base abstract class for all kickstart commands.
38 Command objects are contained within a BaseHandler
39 object.
40"""
41import gettext
42gettext.textdomain("pykickstart")
43_ = lambda x: gettext.ldgettext("pykickstart", x)
44
45import types
46import warnings
47from pykickstart.errors import *
48from pykickstart.ko import *
49from pykickstart.parser import Packages
50from pykickstart.version import versionToString
51
52###
53### COMMANDS
54###
55class KickstartCommand(KickstartObject):
56 """The base class for all kickstart commands. This is an abstract class."""
57 removedKeywords = []
58 removedAttrs = []
59
60 def __init__(self, writePriority=0, *args, **kwargs):
61 """Create a new KickstartCommand instance. This method must be
62 provided by all subclasses, but subclasses must call
63 KickstartCommand.__init__ first. Instance attributes:
64
65 currentCmd -- The name of the command in the input file that
66 caused this handler to be run.
67 currentLine -- The current unprocessed line from the input file
68 that caused this handler to be run.
69 handler -- A reference to the BaseHandler subclass this
70 command is contained withing. This is needed to
71 allow referencing of Data objects.
72 lineno -- The current line number in the input file.
73 writePriority -- An integer specifying when this command should be
74 printed when iterating over all commands' __str__
75 methods. The higher the number, the later this
76 command will be written. All commands with the
77 same priority will be written alphabetically.
78 """
79
80 # We don't want people using this class by itself.
81 if self.__class__ is KickstartCommand:
82 raise TypeError, "KickstartCommand is an abstract class."
83
84 KickstartObject.__init__(self, *args, **kwargs)
85
86 self.writePriority = writePriority
87
88 # These will be set by the dispatcher.
89 self.currentCmd = ""
90 self.currentLine = ""
91 self.handler = None
92 self.lineno = 0
93
94 # If a subclass provides a removedKeywords list, remove all the
95 # members from the kwargs list before we start processing it. This
96 # ensures that subclasses don't continue to recognize arguments that
97 # were removed.
98 for arg in filter(kwargs.has_key, self.removedKeywords):
99 kwargs.pop(arg)
100
101 def __call__(self, *args, **kwargs):
102 """Set multiple attributes on a subclass of KickstartCommand at once
103 via keyword arguments. Valid attributes are anything specified in
104 a subclass, but unknown attributes will be ignored.
105 """
106 for (key, val) in kwargs.items():
107 # Ignore setting attributes that were removed in a subclass, as
108 # if they were unknown attributes.
109 if key in self.removedAttrs:
110 continue
111
112 if hasattr(self, key):
113 setattr(self, key, val)
114
115 def __str__(self):
116 """Return a string formatted for output to a kickstart file. This
117 method must be provided by all subclasses.
118 """
119 return KickstartObject.__str__(self)
120
121 def parse(self, args):
122 """Parse the list of args and set data on the KickstartCommand object.
123 This method must be provided by all subclasses.
124 """
125 raise TypeError, "parse() not implemented for KickstartCommand"
126
127 def apply(self, instroot="/"):
128 """Write out the configuration related to the KickstartCommand object.
129 Subclasses which do not provide this method will not have their
130 configuration written out.
131 """
132 return
133
134 def dataList(self):
135 """For commands that can occur multiple times in a single kickstart
136 file (like network, part, etc.), return the list that we should
137 append more data objects to.
138 """
139 return None
140
141 def deleteRemovedAttrs(self):
142 """Remove all attributes from self that are given in the removedAttrs
143 list. This method should be called from __init__ in a subclass,
144 but only after the superclass's __init__ method has been called.
145 """
146 for attr in filter(lambda k: hasattr(self, k), self.removedAttrs):
147 delattr(self, attr)
148
149 # Set the contents of the opts object (an instance of optparse.Values
150 # returned by parse_args) as attributes on the KickstartCommand object.
151 # It's useful to call this from KickstartCommand subclasses after parsing
152 # the arguments.
153 def _setToSelf(self, optParser, opts):
154 self._setToObj(optParser, opts, self)
155
156 # Sets the contents of the opts object (an instance of optparse.Values
157 # returned by parse_args) as attributes on the provided object obj. It's
158 # useful to call this from KickstartCommand subclasses that handle lists
159 # of objects (like partitions, network devices, etc.) and need to populate
160 # a Data object.
161 def _setToObj(self, optParser, opts, obj):
162 for key in filter (lambda k: getattr(opts, k) != None, optParser.keys()):
163 setattr(obj, key, getattr(opts, key))
164
165class DeprecatedCommand(KickstartCommand):
166 """Specify that a command is deprecated and no longer has any function.
167 Any command that is deprecated should be subclassed from this class,
168 only specifying an __init__ method that calls the superclass's __init__.
169 This is an abstract class.
170 """
171 def __init__(self, writePriority=None, *args, **kwargs):
172 # We don't want people using this class by itself.
173 if self.__class__ is KickstartCommand:
174 raise TypeError, "DeprecatedCommand is an abstract class."
175
176 # Create a new DeprecatedCommand instance.
177 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
178
179 def __str__(self):
180 """Placeholder since DeprecatedCommands don't work anymore."""
181 return ""
182
183 def parse(self, args):
184 """Print a warning message if the command is seen in the input file."""
185 mapping = {"lineno": self.lineno, "cmd": self.currentCmd}
186 warnings.warn(_("Ignoring deprecated command on line %(lineno)s: The %(cmd)s command has been deprecated and no longer has any effect. It may be removed from future releases, which will result in a fatal error from kickstart. Please modify your kickstart file to remove this command.") % mapping, DeprecationWarning)
187
188
189###
190### HANDLERS
191###
192class BaseHandler(KickstartObject):
193 """Each version of kickstart syntax is provided by a subclass of this
194 class. These subclasses are what users will interact with for parsing,
195 extracting data, and writing out kickstart files. This is an abstract
196 class.
197
198 version -- The version this syntax handler supports. This is set by
199 a class attribute of a BaseHandler subclass and is used to
200 set up the command dict. It is for read-only use.
201 """
202 version = None
203
204 def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
205 dataUpdates=None, *args, **kwargs):
206 """Create a new BaseHandler instance. This method must be provided by
207 all subclasses, but subclasses must call BaseHandler.__init__ first.
208
209 mapping -- A custom map from command strings to classes,
210 useful when creating your own handler with
211 special command objects. It is otherwise unused
212 and rarely needed. If you give this argument,
213 the mapping takes the place of the default one
214 and so must include all commands you want
215 recognized.
216 dataMapping -- This is the same as mapping, but for data
217 objects. All the same comments apply.
218 commandUpdates -- This is similar to mapping, but does not take
219 the place of the defaults entirely. Instead,
220 this mapping is applied after the defaults and
221 updates it with just the commands you want to
222 modify.
223 dataUpdates -- This is the same as commandUpdates, but for
224 data objects.
225
226
227 Instance attributes:
228
229 commands -- A mapping from a string command to a KickstartCommand
230 subclass object that handles it. Multiple strings can
231 map to the same object, but only one instance of the
232 command object should ever exist. Most users should
233 never have to deal with this directly, as it is
234 manipulated internally and called through dispatcher.
235 currentLine -- The current unprocessed line from the input file
236 that caused this handler to be run.
237 packages -- An instance of pykickstart.parser.Packages which
238 describes the packages section of the input file.
239 platform -- A string describing the hardware platform, which is
240 needed only by system-config-kickstart.
241 scripts -- A list of pykickstart.parser.Script instances, which is
242 populated by KickstartParser.addScript and describes the
243 %pre/%post/%traceback script section of the input file.
244 """
245
246 # We don't want people using this class by itself.
247 if self.__class__ is BaseHandler:
248 raise TypeError, "BaseHandler is an abstract class."
249
250 KickstartObject.__init__(self, *args, **kwargs)
251
252 # This isn't really a good place for these, but it's better than
253 # everything else I can think of.
254 self.scripts = []
255 self.packages = Packages()
256 self.platform = ""
257
258 # These will be set by the dispatcher.
259 self.commands = {}
260 self.currentLine = 0
261
262 # A dict keyed by an integer priority number, with each value being a
263 # list of KickstartCommand subclasses. This dict is maintained by
264 # registerCommand and used in __str__. No one else should be touching
265 # it.
266 self._writeOrder = {}
267
268 self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
269
270 def __str__(self):
271 """Return a string formatted for output to a kickstart file."""
272 retval = ""
273
274 if self.platform != "":
275 retval += "#platform=%s\n" % self.platform
276
277 retval += "#version=%s\n" % versionToString(self.version)
278
279 lst = self._writeOrder.keys()
280 lst.sort()
281
282 for prio in lst:
283 for obj in self._writeOrder[prio]:
284 retval += obj.__str__()
285
286 for script in self.scripts:
287 retval += script.__str__()
288
289 retval += self.packages.__str__()
290
291 return retval
292
293 def _insertSorted(self, lst, obj):
294 length = len(lst)
295 i = 0
296
297 while i < length:
298 # If the two classes have the same name, it's because we are
299 # overriding an existing class with one from a later kickstart
300 # version, so remove the old one in favor of the new one.
301 if obj.__class__.__name__ > lst[i].__class__.__name__:
302 i += 1
303 elif obj.__class__.__name__ == lst[i].__class__.__name__:
304 lst[i] = obj
305 return
306 elif obj.__class__.__name__ < lst[i].__class__.__name__:
307 break
308
309 if i >= length:
310 lst.append(obj)
311 else:
312 lst.insert(i, obj)
313
314 def _setCommand(self, cmdObj):
315 # Add an attribute on this version object. We need this to provide a
316 # way for clients to access the command objects. We also need to strip
317 # off the version part from the front of the name.
318 if cmdObj.__class__.__name__.find("_") != -1:
319 name = unicode(cmdObj.__class__.__name__.split("_", 1)[1])
320 else:
321 name = unicode(cmdObj.__class__.__name__).lower()
322
323 setattr(self, name.lower(), cmdObj)
324
325 # Also, add the object into the _writeOrder dict in the right place.
326 if cmdObj.writePriority is not None:
327 if self._writeOrder.has_key(cmdObj.writePriority):
328 self._insertSorted(self._writeOrder[cmdObj.writePriority], cmdObj)
329 else:
330 self._writeOrder[cmdObj.writePriority] = [cmdObj]
331
332 def _registerCommands(self, mapping=None, dataMapping=None, commandUpdates=None,
333 dataUpdates=None):
334 if mapping == {} or mapping == None:
335 from pykickstart.handlers.control import commandMap
336 cMap = commandMap[self.version]
337 else:
338 cMap = mapping
339
340 if dataMapping == {} or dataMapping == None:
341 from pykickstart.handlers.control import dataMap
342 dMap = dataMap[self.version]
343 else:
344 dMap = dataMapping
345
346 if type(commandUpdates) == types.DictType:
347 cMap.update(commandUpdates)
348
349 if type(dataUpdates) == types.DictType:
350 dMap.update(dataUpdates)
351
352 for (cmdName, cmdClass) in cMap.iteritems():
353 # First make sure we haven't instantiated this command handler
354 # already. If we have, we just need to make another mapping to
355 # it in self.commands.
356 cmdObj = None
357
358 for (key, val) in self.commands.iteritems():
359 if val.__class__.__name__ == cmdClass.__name__:
360 cmdObj = val
361 break
362
363 # If we didn't find an instance in self.commands, create one now.
364 if cmdObj == None:
365 cmdObj = cmdClass()
366 self._setCommand(cmdObj)
367
368 # Finally, add the mapping to the commands dict.
369 self.commands[cmdName] = cmdObj
370 self.commands[cmdName].handler = self
371
372 # We also need to create attributes for the various data objects.
373 # No checks here because dMap is a bijection. At least, that's what
374 # the comment says. Hope no one screws that up.
375 for (dataName, dataClass) in dMap.iteritems():
376 setattr(self, dataName, dataClass)
377
378 def dispatcher(self, args, lineno):
379 """Call the appropriate KickstartCommand handler for the current line
380 in the kickstart file. A handler for the current command should
381 be registered, though a handler of None is not an error. Returns
382 the data object returned by KickstartCommand.parse.
383
384 args -- A list of arguments to the current command
385 lineno -- The line number in the file, for error reporting
386 """
387 cmd = args[0]
388
389 if not self.commands.has_key(cmd):
390 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd))
391 elif self.commands[cmd] != None:
392 self.commands[cmd].currentCmd = cmd
393 self.commands[cmd].currentLine = self.currentLine
394 self.commands[cmd].lineno = lineno
395
396 # The parser returns the data object that was modified. This could
397 # be a BaseData subclass that should be put into a list, or it
398 # could be the command handler object itself.
399 obj = self.commands[cmd].parse(args[1:])
400 lst = self.commands[cmd].dataList()
401 if lst is not None:
402 lst.append(obj)
403
404 return obj
405
406 def maskAllExcept(self, lst):
407 """Set all entries in the commands dict to None, except the ones in
408 the lst. All other commands will not be processed.
409 """
410 self._writeOrder = {}
411
412 for (key, val) in self.commands.iteritems():
413 if not key in lst:
414 self.commands[key] = None
415
416 def hasCommand(self, cmd):
417 """Return true if there is a handler for the string cmd."""
418 return hasattr(self, cmd)
419
420
421###
422### DATA
423###
424class BaseData(KickstartObject):
425 """The base class for all data objects. This is an abstract class."""
426 removedKeywords = []
427 removedAttrs = []
428
429 def __init__(self, *args, **kwargs):
430 """Create a new BaseData instance.
431
432 lineno -- Line number in the ks-file where this object was defined
433 """
434
435 # We don't want people using this class by itself.
436 if self.__class__ is BaseData:
437 raise TypeError, "BaseData is an abstract class."
438
439 KickstartObject.__init__(self, *args, **kwargs)
440 self.lineno = 0
441
442 def __str__(self):
443 """Return a string formatted for output to a kickstart file."""
444 return ""
445
446 def __call__(self, *args, **kwargs):
447 """Set multiple attributes on a subclass of BaseData at once via
448 keyword arguments. Valid attributes are anything specified in a
449 subclass, but unknown attributes will be ignored.
450 """
451 for (key, val) in kwargs.items():
452 # Ignore setting attributes that were removed in a subclass, as
453 # if they were unknown attributes.
454 if key in self.removedAttrs:
455 continue
456
457 if hasattr(self, key):
458 setattr(self, key, val)
459
460 def deleteRemovedAttrs(self):
461 """Remove all attributes from self that are given in the removedAttrs
462 list. This method should be called from __init__ in a subclass,
463 but only after the superclass's __init__ method has been called.
464 """
465 for attr in filter(lambda k: hasattr(self, k), self.removedAttrs):
466 delattr(self, attr)
diff --git a/scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py b/scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py
deleted file mode 100644
index 2d94550935..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 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#
20import bootloader, partition
diff --git a/scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py b/scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py
deleted file mode 100644
index c2b552f689..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py
+++ /dev/null
@@ -1,216 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 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
23class FC3_Bootloader(KickstartCommand):
24 removedKeywords = KickstartCommand.removedKeywords
25 removedAttrs = KickstartCommand.removedAttrs
26
27 def __init__(self, writePriority=10, *args, **kwargs):
28 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
29 self.op = self._getParser()
30
31 self.driveorder = kwargs.get("driveorder", [])
32 self.appendLine = kwargs.get("appendLine", "")
33 self.forceLBA = kwargs.get("forceLBA", False)
34 self.linear = kwargs.get("linear", True)
35 self.location = kwargs.get("location", "")
36 self.md5pass = kwargs.get("md5pass", "")
37 self.password = kwargs.get("password", "")
38 self.upgrade = kwargs.get("upgrade", False)
39 self.useLilo = kwargs.get("useLilo", False)
40
41 self.deleteRemovedAttrs()
42
43 def _getArgsAsStr(self):
44 retval = ""
45
46 if self.appendLine != "":
47 retval += " --append=\"%s\"" % self.appendLine
48 if self.linear:
49 retval += " --linear"
50 if self.location:
51 retval += " --location=%s" % self.location
52 if hasattr(self, "forceLBA") and self.forceLBA:
53 retval += " --lba32"
54 if self.password != "":
55 retval += " --password=\"%s\"" % self.password
56 if self.md5pass != "":
57 retval += " --md5pass=\"%s\"" % self.md5pass
58 if self.upgrade:
59 retval += " --upgrade"
60 if self.useLilo:
61 retval += " --useLilo"
62 if len(self.driveorder) > 0:
63 retval += " --driveorder=\"%s\"" % ",".join(self.driveorder)
64
65 return retval
66
67 def __str__(self):
68 retval = KickstartCommand.__str__(self)
69
70 if self.location != "":
71 retval += "# System bootloader configuration\nbootloader"
72 retval += self._getArgsAsStr() + "\n"
73
74 return retval
75
76 def _getParser(self):
77 def driveorder_cb (option, opt_str, value, parser):
78 for d in value.split(','):
79 parser.values.ensure_value(option.dest, []).append(d)
80
81 op = KSOptionParser()
82 op.add_option("--append", dest="appendLine")
83 op.add_option("--linear", dest="linear", action="store_true",
84 default=True)
85 op.add_option("--nolinear", dest="linear", action="store_false")
86 op.add_option("--location", dest="location", type="choice",
87 default="mbr",
88 choices=["mbr", "partition", "none", "boot"])
89 op.add_option("--lba32", dest="forceLBA", action="store_true",
90 default=False)
91 op.add_option("--password", dest="password", default="")
92 op.add_option("--md5pass", dest="md5pass", default="")
93 op.add_option("--upgrade", dest="upgrade", action="store_true",
94 default=False)
95 op.add_option("--useLilo", dest="useLilo", action="store_true",
96 default=False)
97 op.add_option("--driveorder", dest="driveorder", action="callback",
98 callback=driveorder_cb, nargs=1, type="string")
99 return op
100
101 def parse(self, args):
102 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
103 self._setToSelf(self.op, opts)
104
105 if self.currentCmd == "lilo":
106 self.useLilo = True
107
108 return self
109
110class FC4_Bootloader(FC3_Bootloader):
111 removedKeywords = FC3_Bootloader.removedKeywords + ["linear", "useLilo"]
112 removedAttrs = FC3_Bootloader.removedAttrs + ["linear", "useLilo"]
113
114 def __init__(self, writePriority=10, *args, **kwargs):
115 FC3_Bootloader.__init__(self, writePriority, *args, **kwargs)
116
117 def _getArgsAsStr(self):
118 retval = ""
119 if self.appendLine != "":
120 retval += " --append=\"%s\"" % self.appendLine
121 if self.location:
122 retval += " --location=%s" % self.location
123 if hasattr(self, "forceLBA") and self.forceLBA:
124 retval += " --lba32"
125 if self.password != "":
126 retval += " --password=\"%s\"" % self.password
127 if self.md5pass != "":
128 retval += " --md5pass=\"%s\"" % self.md5pass
129 if self.upgrade:
130 retval += " --upgrade"
131 if len(self.driveorder) > 0:
132 retval += " --driveorder=\"%s\"" % ",".join(self.driveorder)
133 return retval
134
135 def _getParser(self):
136 op = FC3_Bootloader._getParser(self)
137 op.remove_option("--linear")
138 op.remove_option("--nolinear")
139 op.remove_option("--useLilo")
140 return op
141
142 def parse(self, args):
143 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
144 self._setToSelf(self.op, opts)
145 return self
146
147class F8_Bootloader(FC4_Bootloader):
148 removedKeywords = FC4_Bootloader.removedKeywords
149 removedAttrs = FC4_Bootloader.removedAttrs
150
151 def __init__(self, writePriority=10, *args, **kwargs):
152 FC4_Bootloader.__init__(self, writePriority, *args, **kwargs)
153
154 self.timeout = kwargs.get("timeout", None)
155 self.default = kwargs.get("default", "")
156
157 def _getArgsAsStr(self):
158 ret = FC4_Bootloader._getArgsAsStr(self)
159
160 if self.timeout is not None:
161 ret += " --timeout=%d" %(self.timeout,)
162 if self.default:
163 ret += " --default=%s" %(self.default,)
164
165 return ret
166
167 def _getParser(self):
168 op = FC4_Bootloader._getParser(self)
169 op.add_option("--timeout", dest="timeout", type="int")
170 op.add_option("--default", dest="default")
171 return op
172
173class F12_Bootloader(F8_Bootloader):
174 removedKeywords = F8_Bootloader.removedKeywords
175 removedAttrs = F8_Bootloader.removedAttrs
176
177 def _getParser(self):
178 op = F8_Bootloader._getParser(self)
179 op.add_option("--lba32", dest="forceLBA", deprecated=1, action="store_true")
180 return op
181
182class F14_Bootloader(F12_Bootloader):
183 removedKeywords = F12_Bootloader.removedKeywords + ["forceLBA"]
184 removedAttrs = F12_Bootloader.removedKeywords + ["forceLBA"]
185
186 def _getParser(self):
187 op = F12_Bootloader._getParser(self)
188 op.remove_option("--lba32")
189 return op
190
191class F15_Bootloader(F14_Bootloader):
192 removedKeywords = F14_Bootloader.removedKeywords
193 removedAttrs = F14_Bootloader.removedAttrs
194
195 def __init__(self, writePriority=10, *args, **kwargs):
196 F14_Bootloader.__init__(self, writePriority, *args, **kwargs)
197
198 self.isCrypted = kwargs.get("isCrypted", False)
199
200 def _getArgsAsStr(self):
201 ret = F14_Bootloader._getArgsAsStr(self)
202
203 if self.isCrypted:
204 ret += " --iscrypted"
205
206 return ret
207
208 def _getParser(self):
209 def password_cb(option, opt_str, value, parser):
210 parser.values.isCrypted = True
211 parser.values.password = value
212
213 op = F14_Bootloader._getParser(self)
214 op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False)
215 op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string")
216 return op
diff --git a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py b/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
deleted file mode 100644
index b564b1a7ab..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
+++ /dev/null
@@ -1,314 +0,0 @@
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.errors import *
22from pykickstart.options import *
23
24import gettext
25import warnings
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_PartData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.active = kwargs.get("active", False)
35 self.primOnly = kwargs.get("primOnly", False)
36 self.end = kwargs.get("end", 0)
37 self.fstype = kwargs.get("fstype", "")
38 self.grow = kwargs.get("grow", False)
39 self.maxSizeMB = kwargs.get("maxSizeMB", 0)
40 self.format = kwargs.get("format", True)
41 self.onbiosdisk = kwargs.get("onbiosdisk", "")
42 self.disk = kwargs.get("disk", "")
43 self.onPart = kwargs.get("onPart", "")
44 self.recommended = kwargs.get("recommended", False)
45 self.size = kwargs.get("size", None)
46 self.start = kwargs.get("start", 0)
47 self.mountpoint = kwargs.get("mountpoint", "")
48
49 def __eq__(self, y):
50 if self.mountpoint:
51 return self.mountpoint == y.mountpoint
52 else:
53 return False
54
55 def _getArgsAsStr(self):
56 retval = ""
57
58 if self.active:
59 retval += " --active"
60 if self.primOnly:
61 retval += " --asprimary"
62 if hasattr(self, "end") and self.end != 0:
63 retval += " --end=%s" % self.end
64 if self.fstype != "":
65 retval += " --fstype=\"%s\"" % self.fstype
66 if self.grow:
67 retval += " --grow"
68 if self.maxSizeMB > 0:
69 retval += " --maxsize=%d" % self.maxSizeMB
70 if not self.format:
71 retval += " --noformat"
72 if self.onbiosdisk != "":
73 retval += " --onbiosdisk=%s" % self.onbiosdisk
74 if self.disk != "":
75 retval += " --ondisk=%s" % self.disk
76 if self.onPart != "":
77 retval += " --onpart=%s" % self.onPart
78 if self.recommended:
79 retval += " --recommended"
80 if self.size and self.size != 0:
81 retval += " --size=%sk" % self.size
82 if hasattr(self, "start") and self.start != 0:
83 retval += " --start=%s" % self.start
84
85 return retval
86
87 def __str__(self):
88 retval = BaseData.__str__(self)
89 if self.mountpoint:
90 mountpoint_str = "%s" % self.mountpoint
91 else:
92 mountpoint_str = "(No mount point)"
93 retval += "part %s%s\n" % (mountpoint_str, self._getArgsAsStr())
94 return retval
95
96class FC4_PartData(FC3_PartData):
97 removedKeywords = FC3_PartData.removedKeywords
98 removedAttrs = FC3_PartData.removedAttrs
99
100 def __init__(self, *args, **kwargs):
101 FC3_PartData.__init__(self, *args, **kwargs)
102 self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
103 self.fsopts = kwargs.get("fsopts", "")
104 self.label = kwargs.get("label", "")
105
106 def _getArgsAsStr(self):
107 retval = FC3_PartData._getArgsAsStr(self)
108
109 if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0:
110 retval += " --bytes-per-inode=%d" % self.bytesPerInode
111 if self.fsopts != "":
112 retval += " --fsoptions=\"%s\"" % self.fsopts
113 if self.label != "":
114 retval += " --label=%s" % self.label
115
116 return retval
117
118class F9_PartData(FC4_PartData):
119 removedKeywords = FC4_PartData.removedKeywords + ["bytesPerInode"]
120 removedAttrs = FC4_PartData.removedAttrs + ["bytesPerInode"]
121
122 def __init__(self, *args, **kwargs):
123 FC4_PartData.__init__(self, *args, **kwargs)
124 self.deleteRemovedAttrs()
125
126 self.fsopts = kwargs.get("fsopts", "")
127 self.label = kwargs.get("label", "")
128 self.fsprofile = kwargs.get("fsprofile", "")
129 self.encrypted = kwargs.get("encrypted", False)
130 self.passphrase = kwargs.get("passphrase", "")
131
132 def _getArgsAsStr(self):
133 retval = FC4_PartData._getArgsAsStr(self)
134
135 if self.fsprofile != "":
136 retval += " --fsprofile=\"%s\"" % self.fsprofile
137 if self.encrypted:
138 retval += " --encrypted"
139
140 if self.passphrase != "":
141 retval += " --passphrase=\"%s\"" % self.passphrase
142
143 return retval
144
145class F11_PartData(F9_PartData):
146 removedKeywords = F9_PartData.removedKeywords + ["start", "end"]
147 removedAttrs = F9_PartData.removedAttrs + ["start", "end"]
148
149class F12_PartData(F11_PartData):
150 removedKeywords = F11_PartData.removedKeywords
151 removedAttrs = F11_PartData.removedAttrs
152
153 def __init__(self, *args, **kwargs):
154 F11_PartData.__init__(self, *args, **kwargs)
155
156 self.escrowcert = kwargs.get("escrowcert", "")
157 self.backuppassphrase = kwargs.get("backuppassphrase", False)
158
159 def _getArgsAsStr(self):
160 retval = F11_PartData._getArgsAsStr(self)
161
162 if self.encrypted and self.escrowcert != "":
163 retval += " --escrowcert=\"%s\"" % self.escrowcert
164
165 if self.backuppassphrase:
166 retval += " --backuppassphrase"
167
168 return retval
169
170F14_PartData = F12_PartData
171
172class FC3_Partition(KickstartCommand):
173 removedKeywords = KickstartCommand.removedKeywords
174 removedAttrs = KickstartCommand.removedAttrs
175
176 def __init__(self, writePriority=130, *args, **kwargs):
177 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
178 self.op = self._getParser()
179
180 self.partitions = kwargs.get("partitions", [])
181
182 def __str__(self):
183 retval = ""
184
185 for part in self.partitions:
186 retval += part.__str__()
187
188 if retval != "":
189 return "# Disk partitioning information\n" + retval
190 else:
191 return ""
192
193 def _getParser(self):
194 def part_cb (option, opt_str, value, parser):
195 if value.startswith("/dev/"):
196 parser.values.ensure_value(option.dest, value[5:])
197 else:
198 parser.values.ensure_value(option.dest, value)
199
200 op = KSOptionParser()
201 op.add_option("--active", dest="active", action="store_true",
202 default=False)
203 op.add_option("--asprimary", dest="primOnly", action="store_true",
204 default=False)
205 op.add_option("--end", dest="end", action="store", type="int",
206 nargs=1)
207 op.add_option("--fstype", "--type", dest="fstype")
208 op.add_option("--grow", dest="grow", action="store_true", default=False)
209 op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int",
210 nargs=1)
211 op.add_option("--noformat", dest="format", action="store_false",
212 default=True)
213 op.add_option("--onbiosdisk", dest="onbiosdisk")
214 op.add_option("--ondisk", "--ondrive", dest="disk")
215 op.add_option("--onpart", "--usepart", dest="onPart", action="callback",
216 callback=part_cb, nargs=1, type="string")
217 op.add_option("--recommended", dest="recommended", action="store_true",
218 default=False)
219 op.add_option("--size", dest="size", action="store", type="size",
220 nargs=1)
221 op.add_option("--start", dest="start", action="store", type="int",
222 nargs=1)
223 return op
224
225 def parse(self, args):
226 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
227
228 pd = self.handler.PartData()
229 self._setToObj(self.op, opts, pd)
230 pd.lineno = self.lineno
231 if extra:
232 pd.mountpoint = extra[0]
233 if pd in self.dataList():
234 warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint)
235 else:
236 pd.mountpoint = None
237
238 return pd
239
240 def dataList(self):
241 return self.partitions
242
243class FC4_Partition(FC3_Partition):
244 removedKeywords = FC3_Partition.removedKeywords
245 removedAttrs = FC3_Partition.removedAttrs
246
247 def __init__(self, writePriority=130, *args, **kwargs):
248 FC3_Partition.__init__(self, writePriority, *args, **kwargs)
249
250 def part_cb (option, opt_str, value, parser):
251 if value.startswith("/dev/"):
252 parser.values.ensure_value(option.dest, value[5:])
253 else:
254 parser.values.ensure_value(option.dest, value)
255
256 def _getParser(self):
257 op = FC3_Partition._getParser(self)
258 op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store",
259 type="int", nargs=1)
260 op.add_option("--fsoptions", dest="fsopts")
261 op.add_option("--label", dest="label")
262 return op
263
264class F9_Partition(FC4_Partition):
265 removedKeywords = FC4_Partition.removedKeywords
266 removedAttrs = FC4_Partition.removedAttrs
267
268 def __init__(self, writePriority=130, *args, **kwargs):
269 FC4_Partition.__init__(self, writePriority, *args, **kwargs)
270
271 def part_cb (option, opt_str, value, parser):
272 if value.startswith("/dev/"):
273 parser.values.ensure_value(option.dest, value[5:])
274 else:
275 parser.values.ensure_value(option.dest, value)
276
277 def _getParser(self):
278 op = FC4_Partition._getParser(self)
279 op.add_option("--bytes-per-inode", deprecated=1)
280 op.add_option("--fsprofile")
281 op.add_option("--encrypted", action="store_true", default=False)
282 op.add_option("--passphrase")
283 return op
284
285class F11_Partition(F9_Partition):
286 removedKeywords = F9_Partition.removedKeywords
287 removedAttrs = F9_Partition.removedAttrs
288
289 def _getParser(self):
290 op = F9_Partition._getParser(self)
291 op.add_option("--start", deprecated=1)
292 op.add_option("--end", deprecated=1)
293 return op
294
295class F12_Partition(F11_Partition):
296 removedKeywords = F11_Partition.removedKeywords
297 removedAttrs = F11_Partition.removedAttrs
298
299 def _getParser(self):
300 op = F11_Partition._getParser(self)
301 op.add_option("--escrowcert")
302 op.add_option("--backuppassphrase", action="store_true", default=False)
303 return op
304
305class F14_Partition(F12_Partition):
306 removedKeywords = F12_Partition.removedKeywords
307 removedAttrs = F12_Partition.removedAttrs
308
309 def _getParser(self):
310 op = F12_Partition._getParser(self)
311 op.remove_option("--bytes-per-inode")
312 op.remove_option("--start")
313 op.remove_option("--end")
314 return op
diff --git a/scripts/lib/wic/3rdparty/pykickstart/constants.py b/scripts/lib/wic/3rdparty/pykickstart/constants.py
deleted file mode 100644
index 5e12fc80ec..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/constants.py
+++ /dev/null
@@ -1,57 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005-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#
20CLEARPART_TYPE_LINUX = 0
21CLEARPART_TYPE_ALL = 1
22CLEARPART_TYPE_NONE = 2
23
24DISPLAY_MODE_CMDLINE = 0
25DISPLAY_MODE_GRAPHICAL = 1
26DISPLAY_MODE_TEXT = 2
27
28FIRSTBOOT_DEFAULT = 0
29FIRSTBOOT_SKIP = 1
30FIRSTBOOT_RECONFIG = 2
31
32KS_MISSING_PROMPT = 0
33KS_MISSING_IGNORE = 1
34
35SELINUX_DISABLED = 0
36SELINUX_ENFORCING = 1
37SELINUX_PERMISSIVE = 2
38
39KS_SCRIPT_PRE = 0
40KS_SCRIPT_POST = 1
41KS_SCRIPT_TRACEBACK = 2
42
43KS_WAIT = 0
44KS_REBOOT = 1
45KS_SHUTDOWN = 2
46
47KS_INSTKEY_SKIP = -99
48
49BOOTPROTO_DHCP = "dhcp"
50BOOTPROTO_BOOTP = "bootp"
51BOOTPROTO_STATIC = "static"
52BOOTPROTO_QUERY = "query"
53BOOTPROTO_IBFT = "ibft"
54
55GROUP_REQUIRED = 0
56GROUP_DEFAULT = 1
57GROUP_ALL = 2
diff --git a/scripts/lib/wic/3rdparty/pykickstart/errors.py b/scripts/lib/wic/3rdparty/pykickstart/errors.py
deleted file mode 100644
index a234d99d43..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/errors.py
+++ /dev/null
@@ -1,103 +0,0 @@
1#
2# errors.py: Kickstart error handling.
3#
4# Chris Lumens <clumens@redhat.com>
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#
20"""
21Error handling classes and functions.
22
23This module exports a single function:
24
25 formatErrorMsg - Properly formats an error message.
26
27It also exports several exception classes:
28
29 KickstartError - A generic exception class.
30
31 KickstartParseError - An exception for errors relating to parsing.
32
33 KickstartValueError - An exception for errors relating to option
34 processing.
35
36 KickstartVersionError - An exception for errors relating to unsupported
37 syntax versions.
38"""
39import gettext
40_ = lambda x: gettext.ldgettext("pykickstart", x)
41
42def formatErrorMsg(lineno, msg=""):
43 """Properly format the error message msg for inclusion in an exception."""
44 if msg != "":
45 mapping = {"lineno": lineno, "msg": msg}
46 return _("The following problem occurred on line %(lineno)s of the kickstart file:\n\n%(msg)s\n") % mapping
47 else:
48 return _("There was a problem reading from line %s of the kickstart file") % lineno
49
50class KickstartError(Exception):
51 """A generic exception class for unspecific error conditions."""
52 def __init__(self, val = ""):
53 """Create a new KickstartError exception instance with the descriptive
54 message val. val should be the return value of formatErrorMsg.
55 """
56 Exception.__init__(self)
57 self.value = val
58
59 def __str__ (self):
60 return self.value
61
62class KickstartParseError(KickstartError):
63 """An exception class for errors when processing the input file, such as
64 unknown options, commands, or sections.
65 """
66 def __init__(self, msg):
67 """Create a new KickstartParseError exception instance with the
68 descriptive message val. val should be the return value of
69 formatErrorMsg.
70 """
71 KickstartError.__init__(self, msg)
72
73 def __str__(self):
74 return self.value
75
76class KickstartValueError(KickstartError):
77 """An exception class for errors when processing arguments to commands,
78 such as too many arguments, too few arguments, or missing required
79 arguments.
80 """
81 def __init__(self, msg):
82 """Create a new KickstartValueError exception instance with the
83 descriptive message val. val should be the return value of
84 formatErrorMsg.
85 """
86 KickstartError.__init__(self, msg)
87
88 def __str__ (self):
89 return self.value
90
91class KickstartVersionError(KickstartError):
92 """An exception class for errors related to using an incorrect version of
93 kickstart syntax.
94 """
95 def __init__(self, msg):
96 """Create a new KickstartVersionError exception instance with the
97 descriptive message val. val should be the return value of
98 formatErrorMsg.
99 """
100 KickstartError.__init__(self, msg)
101
102 def __str__ (self):
103 return self.value
diff --git a/scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py b/scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py
+++ /dev/null
diff --git a/scripts/lib/wic/3rdparty/pykickstart/handlers/control.py b/scripts/lib/wic/3rdparty/pykickstart/handlers/control.py
deleted file mode 100644
index 8dc80d1ebe..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/handlers/control.py
+++ /dev/null
@@ -1,46 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2008, 2009, 2010 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.version import *
21from pykickstart.commands import *
22
23# This map is keyed on kickstart syntax version as provided by
24# pykickstart.version. Within each sub-dict is a mapping from command name
25# to the class that handles it. This is an onto mapping - that is, multiple
26# command names can map to the same class. However, the Handler will ensure
27# that only one instance of each class ever exists.
28commandMap = {
29 # based on f15
30 F16: {
31 "bootloader": bootloader.F15_Bootloader,
32 "part": partition.F14_Partition,
33 "partition": partition.F14_Partition,
34 },
35}
36
37# This map is keyed on kickstart syntax version as provided by
38# pykickstart.version. Within each sub-dict is a mapping from a data object
39# name to the class that provides it. This is a bijective mapping - that is,
40# each name maps to exactly one data class and all data classes have a name.
41# More than one instance of each class is allowed to exist, however.
42dataMap = {
43 F16: {
44 "PartData": partition.F14_PartData,
45 },
46}
diff --git a/scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py b/scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py
deleted file mode 100644
index 3c52f8d754..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py
+++ /dev/null
@@ -1,24 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2011 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.version import *
22
23class F16Handler(BaseHandler):
24 version = F16
diff --git a/scripts/lib/wic/3rdparty/pykickstart/ko.py b/scripts/lib/wic/3rdparty/pykickstart/ko.py
deleted file mode 100644
index 1350d19c70..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/ko.py
+++ /dev/null
@@ -1,37 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 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#
20"""
21Base classes for internal pykickstart use.
22
23The module exports the following important classes:
24
25 KickstartObject - The base class for all classes in pykickstart
26"""
27
28class KickstartObject(object):
29 """The base class for all other classes in pykickstart."""
30 def __init__(self, *args, **kwargs):
31 """Create a new KickstartObject instance. All other classes in
32 pykickstart should be derived from this one. Instance attributes:
33 """
34 pass
35
36 def __str__(self):
37 return ""
diff --git a/scripts/lib/wic/3rdparty/pykickstart/options.py b/scripts/lib/wic/3rdparty/pykickstart/options.py
deleted file mode 100644
index ebc23eda63..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/options.py
+++ /dev/null
@@ -1,223 +0,0 @@
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#
20"""
21Specialized option handling.
22
23This module exports two classes:
24
25 KSOptionParser - A specialized subclass of OptionParser to be used
26 in BaseHandler subclasses.
27
28 KSOption - A specialized subclass of Option.
29"""
30import warnings
31from copy import copy
32from optparse import *
33
34from constants import *
35from errors import *
36from version import *
37
38import gettext
39_ = lambda x: gettext.ldgettext("pykickstart", x)
40
41class KSOptionParser(OptionParser):
42 """A specialized subclass of optparse.OptionParser to handle extra option
43 attribute checking, work error reporting into the KickstartParseError
44 framework, and to turn off the default help.
45 """
46 def exit(self, status=0, msg=None):
47 pass
48
49 def error(self, msg):
50 if self.lineno != None:
51 raise KickstartParseError, formatErrorMsg(self.lineno, msg=msg)
52 else:
53 raise KickstartParseError, msg
54
55 def keys(self):
56 retval = []
57
58 for opt in self.option_list:
59 if opt not in retval:
60 retval.append(opt.dest)
61
62 return retval
63
64 def _init_parsing_state (self):
65 OptionParser._init_parsing_state(self)
66 self.option_seen = {}
67
68 def check_values (self, values, args):
69 def seen(self, option):
70 return self.option_seen.has_key(option)
71
72 def usedTooNew(self, option):
73 return option.introduced and option.introduced > self.version
74
75 def usedDeprecated(self, option):
76 return option.deprecated
77
78 def usedRemoved(self, option):
79 return option.removed and option.removed <= self.version
80
81 for option in filter(lambda o: isinstance(o, Option), self.option_list):
82 if option.required and not seen(self, option):
83 raise KickstartValueError, formatErrorMsg(self.lineno, _("Option %s is required") % option)
84 elif seen(self, option) and usedTooNew(self, option):
85 mapping = {"option": option, "intro": versionToString(option.introduced),
86 "version": versionToString(self.version)}
87 self.error(_("The %(option)s option was introduced in version %(intro)s, but you are using kickstart syntax version %(version)s.") % mapping)
88 elif seen(self, option) and usedRemoved(self, option):
89 mapping = {"option": option, "removed": versionToString(option.removed),
90 "version": versionToString(self.version)}
91
92 if option.removed == self.version:
93 self.error(_("The %(option)s option is no longer supported.") % mapping)
94 else:
95 self.error(_("The %(option)s option was removed in version %(removed)s, but you are using kickstart syntax version %(version)s.") % mapping)
96 elif seen(self, option) and usedDeprecated(self, option):
97 mapping = {"lineno": self.lineno, "option": option}
98 warnings.warn(_("Ignoring deprecated option on line %(lineno)s: The %(option)s option has been deprecated and no longer has any effect. It may be removed from future releases, which will result in a fatal error from kickstart. Please modify your kickstart file to remove this option.") % mapping, DeprecationWarning)
99
100 return (values, args)
101
102 def parse_args(self, *args, **kwargs):
103 if kwargs.has_key("lineno"):
104 self.lineno = kwargs.pop("lineno")
105
106 return OptionParser.parse_args(self, **kwargs)
107
108 def __init__(self, mapping=None, version=None):
109 """Create a new KSOptionParser instance. Each KickstartCommand
110 subclass should create one instance of KSOptionParser, providing
111 at least the lineno attribute. mapping and version are not required.
112 Instance attributes:
113
114 mapping -- A mapping from option strings to different values.
115 version -- The version of the kickstart syntax we are checking
116 against.
117 """
118 OptionParser.__init__(self, option_class=KSOption,
119 add_help_option=False,
120 conflict_handler="resolve")
121 if mapping is None:
122 self.map = {}
123 else:
124 self.map = mapping
125
126 self.lineno = None
127 self.option_seen = {}
128 self.version = version
129
130def _check_ksboolean(option, opt, value):
131 if value.lower() in ("on", "yes", "true", "1"):
132 return True
133 elif value.lower() in ("off", "no", "false", "0"):
134 return False
135 else:
136 mapping = {"opt": opt, "value": value}
137 raise OptionValueError(_("Option %(opt)s: invalid boolean value: %(value)r") % mapping)
138
139def _check_string(option, opt, value):
140 if len(value) > 2 and value.startswith("--"):
141 mapping = {"opt": opt, "value": value}
142 raise OptionValueError(_("Option %(opt)s: invalid string value: %(value)r") % mapping)
143 else:
144 return value
145
146def _check_size(option, opt, value):
147 # Former default was MB
148 if value.isdigit():
149 return int(value) * 1024L
150
151 mapping = {"opt": opt, "value": value}
152 if not value[:-1].isdigit():
153 raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
154
155 size = int(value[:-1])
156 if value.endswith("k") or value.endswith("K"):
157 return size
158 if value.endswith("M"):
159 return size * 1024L
160 if value.endswith("G"):
161 return size * 1024L * 1024L
162 raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
163
164# Creates a new Option class that supports several new attributes:
165# - required: any option with this attribute must be supplied or an exception
166# is thrown
167# - introduced: the kickstart syntax version that this option first appeared
168# in - an exception will be raised if the option is used and
169# the specified syntax version is less than the value of this
170# attribute
171# - deprecated: the kickstart syntax version that this option was deprecated
172# in - a DeprecationWarning will be thrown if the option is
173# used and the specified syntax version is greater than the
174# value of this attribute
175# - removed: the kickstart syntax version that this option was removed in - an
176# exception will be raised if the option is used and the specified
177# syntax version is greated than the value of this attribute
178# Also creates a new type:
179# - ksboolean: support various kinds of boolean values on an option
180# And two new actions:
181# - map : allows you to define an opt -> val mapping such that dest gets val
182# when opt is seen
183# - map_extend: allows you to define an opt -> [val1, ... valn] mapping such
184# that dest gets a list of vals built up when opt is seen
185class KSOption (Option):
186 ATTRS = Option.ATTRS + ['introduced', 'deprecated', 'removed', 'required']
187 ACTIONS = Option.ACTIONS + ("map", "map_extend",)
188 STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",)
189
190 TYPES = Option.TYPES + ("ksboolean", "string", "size")
191 TYPE_CHECKER = copy(Option.TYPE_CHECKER)
192 TYPE_CHECKER["ksboolean"] = _check_ksboolean
193 TYPE_CHECKER["string"] = _check_string
194 TYPE_CHECKER["size"] = _check_size
195
196 def _check_required(self):
197 if self.required and not self.takes_value():
198 raise OptionError(_("Required flag set for option that doesn't take a value"), self)
199
200 # Make sure _check_required() is called from the constructor!
201 CHECK_METHODS = Option.CHECK_METHODS + [_check_required]
202
203 def process (self, opt, value, values, parser):
204 Option.process(self, opt, value, values, parser)
205 parser.option_seen[self] = 1
206
207 # Override default take_action method to handle our custom actions.
208 def take_action(self, action, dest, opt, value, values, parser):
209 if action == "map":
210 values.ensure_value(dest, parser.map[opt.lstrip('-')])
211 elif action == "map_extend":
212 values.ensure_value(dest, []).extend(parser.map[opt.lstrip('-')])
213 else:
214 Option.take_action(self, action, dest, opt, value, values, parser)
215
216 def takes_value(self):
217 # Deprecated options don't take a value.
218 return Option.takes_value(self) and not self.deprecated
219
220 def __init__(self, *args, **kwargs):
221 self.deprecated = False
222 self.required = False
223 Option.__init__(self, *args, **kwargs)
diff --git a/scripts/lib/wic/3rdparty/pykickstart/parser.py b/scripts/lib/wic/3rdparty/pykickstart/parser.py
deleted file mode 100644
index 9c9674bf73..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/parser.py
+++ /dev/null
@@ -1,619 +0,0 @@
1#
2# parser.py: Kickstart file parser.
3#
4# Chris Lumens <clumens@redhat.com>
5#
6# Copyright 2005, 2006, 2007, 2008, 2011 Red Hat, Inc.
7#
8# This copyrighted material is made available to anyone wishing to use, modify,
9# copy, or redistribute it subject to the terms and conditions of the GNU
10# General Public License v.2. This program is distributed in the hope that it
11# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
12# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13# See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
18# trademarks that are incorporated in the source code or documentation are not
19# subject to the GNU General Public License and may only be used or replicated
20# with the express permission of Red Hat, Inc.
21#
22"""
23Main kickstart file processing module.
24
25This module exports several important classes:
26
27 Script - Representation of a single %pre, %post, or %traceback script.
28
29 Packages - Representation of the %packages section.
30
31 KickstartParser - The kickstart file parser state machine.
32"""
33
34from collections import Iterator
35import os
36import shlex
37import sys
38import tempfile
39from copy import copy
40from optparse import *
41
42import constants
43from errors import KickstartError, KickstartParseError, KickstartValueError, formatErrorMsg
44from ko import KickstartObject
45from sections import *
46import version
47
48import gettext
49_ = lambda x: gettext.ldgettext("pykickstart", x)
50
51STATE_END = "end"
52STATE_COMMANDS = "commands"
53
54ver = version.DEVEL
55
56
57class PutBackIterator(Iterator):
58 def __init__(self, iterable):
59 self._iterable = iter(iterable)
60 self._buf = None
61
62 def __iter__(self):
63 return self
64
65 def put(self, s):
66 self._buf = s
67
68 def next(self):
69 if self._buf:
70 retval = self._buf
71 self._buf = None
72 return retval
73 else:
74 return self._iterable.next()
75
76###
77### SCRIPT HANDLING
78###
79class Script(KickstartObject):
80 """A class representing a single kickstart script. If functionality beyond
81 just a data representation is needed (for example, a run method in
82 anaconda), Script may be subclassed. Although a run method is not
83 provided, most of the attributes of Script have to do with running the
84 script. Instances of Script are held in a list by the Version object.
85 """
86 def __init__(self, script, *args , **kwargs):
87 """Create a new Script instance. Instance attributes:
88
89 errorOnFail -- If execution of the script fails, should anaconda
90 stop, display an error, and then reboot without
91 running any other scripts?
92 inChroot -- Does the script execute in anaconda's chroot
93 environment or not?
94 interp -- The program that should be used to interpret this
95 script.
96 lineno -- The line number this script starts on.
97 logfile -- Where all messages from the script should be logged.
98 script -- A string containing all the lines of the script.
99 type -- The type of the script, which can be KS_SCRIPT_* from
100 pykickstart.constants.
101 """
102 KickstartObject.__init__(self, *args, **kwargs)
103 self.script = "".join(script)
104
105 self.interp = kwargs.get("interp", "/bin/sh")
106 self.inChroot = kwargs.get("inChroot", False)
107 self.lineno = kwargs.get("lineno", None)
108 self.logfile = kwargs.get("logfile", None)
109 self.errorOnFail = kwargs.get("errorOnFail", False)
110 self.type = kwargs.get("type", constants.KS_SCRIPT_PRE)
111
112 def __str__(self):
113 """Return a string formatted for output to a kickstart file."""
114 retval = ""
115
116 if self.type == constants.KS_SCRIPT_PRE:
117 retval += '\n%pre'
118 elif self.type == constants.KS_SCRIPT_POST:
119 retval += '\n%post'
120 elif self.type == constants.KS_SCRIPT_TRACEBACK:
121 retval += '\n%traceback'
122
123 if self.interp != "/bin/sh" and self.interp != "":
124 retval += " --interpreter=%s" % self.interp
125 if self.type == constants.KS_SCRIPT_POST and not self.inChroot:
126 retval += " --nochroot"
127 if self.logfile != None:
128 retval += " --logfile %s" % self.logfile
129 if self.errorOnFail:
130 retval += " --erroronfail"
131
132 if self.script.endswith("\n"):
133 if ver >= version.F8:
134 return retval + "\n%s%%end\n" % self.script
135 else:
136 return retval + "\n%s\n" % self.script
137 else:
138 if ver >= version.F8:
139 return retval + "\n%s\n%%end\n" % self.script
140 else:
141 return retval + "\n%s\n" % self.script
142
143
144##
145## PACKAGE HANDLING
146##
147class Group:
148 """A class representing a single group in the %packages section."""
149 def __init__(self, name="", include=constants.GROUP_DEFAULT):
150 """Create a new Group instance. Instance attributes:
151
152 name -- The group's identifier
153 include -- The level of how much of the group should be included.
154 Values can be GROUP_* from pykickstart.constants.
155 """
156 self.name = name
157 self.include = include
158
159 def __str__(self):
160 """Return a string formatted for output to a kickstart file."""
161 if self.include == constants.GROUP_REQUIRED:
162 return "@%s --nodefaults" % self.name
163 elif self.include == constants.GROUP_ALL:
164 return "@%s --optional" % self.name
165 else:
166 return "@%s" % self.name
167
168 def __cmp__(self, other):
169 if self.name < other.name:
170 return -1
171 elif self.name > other.name:
172 return 1
173 return 0
174
175class Packages(KickstartObject):
176 """A class representing the %packages section of the kickstart file."""
177 def __init__(self, *args, **kwargs):
178 """Create a new Packages instance. Instance attributes:
179
180 addBase -- Should the Base group be installed even if it is
181 not specified?
182 default -- Should the default package set be selected?
183 excludedList -- A list of all the packages marked for exclusion in
184 the %packages section, without the leading minus
185 symbol.
186 excludeDocs -- Should documentation in each package be excluded?
187 groupList -- A list of Group objects representing all the groups
188 specified in the %packages section. Names will be
189 stripped of the leading @ symbol.
190 excludedGroupList -- A list of Group objects representing all the
191 groups specified for removal in the %packages
192 section. Names will be stripped of the leading
193 -@ symbols.
194 handleMissing -- If unknown packages are specified in the %packages
195 section, should it be ignored or not? Values can
196 be KS_MISSING_* from pykickstart.constants.
197 packageList -- A list of all the packages specified in the
198 %packages section.
199 instLangs -- A list of languages to install.
200 """
201 KickstartObject.__init__(self, *args, **kwargs)
202
203 self.addBase = True
204 self.default = False
205 self.excludedList = []
206 self.excludedGroupList = []
207 self.excludeDocs = False
208 self.groupList = []
209 self.handleMissing = constants.KS_MISSING_PROMPT
210 self.packageList = []
211 self.instLangs = None
212
213 def __str__(self):
214 """Return a string formatted for output to a kickstart file."""
215 pkgs = ""
216
217 if not self.default:
218 grps = self.groupList
219 grps.sort()
220 for grp in grps:
221 pkgs += "%s\n" % grp.__str__()
222
223 p = self.packageList
224 p.sort()
225 for pkg in p:
226 pkgs += "%s\n" % pkg
227
228 grps = self.excludedGroupList
229 grps.sort()
230 for grp in grps:
231 pkgs += "-%s\n" % grp.__str__()
232
233 p = self.excludedList
234 p.sort()
235 for pkg in p:
236 pkgs += "-%s\n" % pkg
237
238 if pkgs == "":
239 return ""
240
241 retval = "\n%packages"
242
243 if self.default:
244 retval += " --default"
245 if self.excludeDocs:
246 retval += " --excludedocs"
247 if not self.addBase:
248 retval += " --nobase"
249 if self.handleMissing == constants.KS_MISSING_IGNORE:
250 retval += " --ignoremissing"
251 if self.instLangs:
252 retval += " --instLangs=%s" % self.instLangs
253
254 if ver >= version.F8:
255 return retval + "\n" + pkgs + "\n%end\n"
256 else:
257 return retval + "\n" + pkgs + "\n"
258
259 def _processGroup (self, line):
260 op = OptionParser()
261 op.add_option("--nodefaults", action="store_true", default=False)
262 op.add_option("--optional", action="store_true", default=False)
263
264 (opts, extra) = op.parse_args(args=line.split())
265
266 if opts.nodefaults and opts.optional:
267 raise KickstartValueError, _("Group cannot specify both --nodefaults and --optional")
268
269 # If the group name has spaces in it, we have to put it back together
270 # now.
271 grp = " ".join(extra)
272
273 if opts.nodefaults:
274 self.groupList.append(Group(name=grp, include=constants.GROUP_REQUIRED))
275 elif opts.optional:
276 self.groupList.append(Group(name=grp, include=constants.GROUP_ALL))
277 else:
278 self.groupList.append(Group(name=grp, include=constants.GROUP_DEFAULT))
279
280 def add (self, pkgList):
281 """Given a list of lines from the input file, strip off any leading
282 symbols and add the result to the appropriate list.
283 """
284 existingExcludedSet = set(self.excludedList)
285 existingPackageSet = set(self.packageList)
286 newExcludedSet = set()
287 newPackageSet = set()
288
289 excludedGroupList = []
290
291 for pkg in pkgList:
292 stripped = pkg.strip()
293
294 if stripped[0] == "@":
295 self._processGroup(stripped[1:])
296 elif stripped[0] == "-":
297 if stripped[1] == "@":
298 excludedGroupList.append(Group(name=stripped[2:]))
299 else:
300 newExcludedSet.add(stripped[1:])
301 else:
302 newPackageSet.add(stripped)
303
304 # Groups have to be excluded in two different ways (note: can't use
305 # sets here because we have to store objects):
306 excludedGroupNames = map(lambda g: g.name, excludedGroupList)
307
308 # First, an excluded group may be cancelling out a previously given
309 # one. This is often the case when using %include. So there we should
310 # just remove the group from the list.
311 self.groupList = filter(lambda g: g.name not in excludedGroupNames, self.groupList)
312
313 # Second, the package list could have included globs which are not
314 # processed by pykickstart. In that case we need to preserve a list of
315 # excluded groups so whatever tool doing package/group installation can
316 # take appropriate action.
317 self.excludedGroupList.extend(excludedGroupList)
318
319 existingPackageSet = (existingPackageSet - newExcludedSet) | newPackageSet
320 existingExcludedSet = (existingExcludedSet - existingPackageSet) | newExcludedSet
321
322 self.packageList = list(existingPackageSet)
323 self.excludedList = list(existingExcludedSet)
324
325
326###
327### PARSER
328###
329class KickstartParser:
330 """The kickstart file parser class as represented by a basic state
331 machine. To create a specialized parser, make a subclass and override
332 any of the methods you care about. Methods that don't need to do
333 anything may just pass. However, _stateMachine should never be
334 overridden.
335 """
336 def __init__ (self, handler, followIncludes=True, errorsAreFatal=True,
337 missingIncludeIsFatal=True):
338 """Create a new KickstartParser instance. Instance attributes:
339
340 errorsAreFatal -- Should errors cause processing to halt, or
341 just print a message to the screen? This
342 is most useful for writing syntax checkers
343 that may want to continue after an error is
344 encountered.
345 followIncludes -- If %include is seen, should the included
346 file be checked as well or skipped?
347 handler -- An instance of a BaseHandler subclass. If
348 None, the input file will still be parsed
349 but no data will be saved and no commands
350 will be executed.
351 missingIncludeIsFatal -- Should missing include files be fatal, even
352 if errorsAreFatal is False?
353 """
354 self.errorsAreFatal = errorsAreFatal
355 self.followIncludes = followIncludes
356 self.handler = handler
357 self.currentdir = {}
358 self.missingIncludeIsFatal = missingIncludeIsFatal
359
360 self._state = STATE_COMMANDS
361 self._includeDepth = 0
362 self._line = ""
363
364 self.version = self.handler.version
365
366 global ver
367 ver = self.version
368
369 self._sections = {}
370 self.setupSections()
371
372 def _reset(self):
373 """Reset the internal variables of the state machine for a new kickstart file."""
374 self._state = STATE_COMMANDS
375 self._includeDepth = 0
376
377 def getSection(self, s):
378 """Return a reference to the requested section (s must start with '%'s),
379 or raise KeyError if not found.
380 """
381 return self._sections[s]
382
383 def handleCommand (self, lineno, args):
384 """Given the list of command and arguments, call the Version's
385 dispatcher method to handle the command. Returns the command or
386 data object returned by the dispatcher. This method may be
387 overridden in a subclass if necessary.
388 """
389 if self.handler:
390 self.handler.currentCmd = args[0]
391 self.handler.currentLine = self._line
392 retval = self.handler.dispatcher(args, lineno)
393
394 return retval
395
396 def registerSection(self, obj):
397 """Given an instance of a Section subclass, register the new section
398 with the parser. Calling this method means the parser will
399 recognize your new section and dispatch into the given object to
400 handle it.
401 """
402 if not obj.sectionOpen:
403 raise TypeError, "no sectionOpen given for section %s" % obj
404
405 if not obj.sectionOpen.startswith("%"):
406 raise TypeError, "section %s tag does not start with a %%" % obj.sectionOpen
407
408 self._sections[obj.sectionOpen] = obj
409
410 def _finalize(self, obj):
411 """Called at the close of a kickstart section to take any required
412 actions. Internally, this is used to add scripts once we have the
413 whole body read.
414 """
415 obj.finalize()
416 self._state = STATE_COMMANDS
417
418 def _handleSpecialComments(self, line):
419 """Kickstart recognizes a couple special comments."""
420 if self._state != STATE_COMMANDS:
421 return
422
423 # Save the platform for s-c-kickstart.
424 if line[:10] == "#platform=":
425 self.handler.platform = self._line[11:]
426
427 def _readSection(self, lineIter, lineno):
428 obj = self._sections[self._state]
429
430 while True:
431 try:
432 line = lineIter.next()
433 if line == "":
434 # This section ends at the end of the file.
435 if self.version >= version.F8:
436 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
437
438 self._finalize(obj)
439 except StopIteration:
440 break
441
442 lineno += 1
443
444 # Throw away blank lines and comments, unless the section wants all
445 # lines.
446 if self._isBlankOrComment(line) and not obj.allLines:
447 continue
448
449 if line.startswith("%"):
450 args = shlex.split(line)
451
452 if args and args[0] == "%end":
453 # This is a properly terminated section.
454 self._finalize(obj)
455 break
456 elif args and args[0] == "%ksappend":
457 continue
458 elif args and (self._validState(args[0]) or args[0] in ["%include", "%ksappend"]):
459 # This is an unterminated section.
460 if self.version >= version.F8:
461 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
462
463 # Finish up. We do not process the header here because
464 # kicking back out to STATE_COMMANDS will ensure that happens.
465 lineIter.put(line)
466 lineno -= 1
467 self._finalize(obj)
468 break
469 else:
470 # This is just a line within a section. Pass it off to whatever
471 # section handles it.
472 obj.handleLine(line)
473
474 return lineno
475
476 def _validState(self, st):
477 """Is the given section tag one that has been registered with the parser?"""
478 return st in self._sections.keys()
479
480 def _tryFunc(self, fn):
481 """Call the provided function (which doesn't take any arguments) and
482 do the appropriate error handling. If errorsAreFatal is False, this
483 function will just print the exception and keep going.
484 """
485 try:
486 fn()
487 except Exception, msg:
488 if self.errorsAreFatal:
489 raise
490 else:
491 print msg
492
493 def _isBlankOrComment(self, line):
494 return line.isspace() or line == "" or line.lstrip()[0] == '#'
495
496 def _stateMachine(self, lineIter):
497 # For error reporting.
498 lineno = 0
499
500 while True:
501 # Get the next line out of the file, quitting if this is the last line.
502 try:
503 self._line = lineIter.next()
504 if self._line == "":
505 break
506 except StopIteration:
507 break
508
509 lineno += 1
510
511 # Eliminate blank lines, whitespace-only lines, and comments.
512 if self._isBlankOrComment(self._line):
513 self._handleSpecialComments(self._line)
514 continue
515
516 # Remove any end-of-line comments.
517 sanitized = self._line.split("#")[0]
518
519 # Then split the line.
520 args = shlex.split(sanitized.rstrip())
521
522 if args[0] == "%include":
523 # This case comes up primarily in ksvalidator.
524 if not self.followIncludes:
525 continue
526
527 if len(args) == 1 or not args[1]:
528 raise KickstartParseError, formatErrorMsg(lineno)
529
530 self._includeDepth += 1
531
532 try:
533 self.readKickstart(args[1], reset=False)
534 except KickstartError:
535 # Handle the include file being provided over the
536 # network in a %pre script. This case comes up in the
537 # early parsing in anaconda.
538 if self.missingIncludeIsFatal:
539 raise
540
541 self._includeDepth -= 1
542 continue
543
544 # Now on to the main event.
545 if self._state == STATE_COMMANDS:
546 if args[0] == "%ksappend":
547 # This is handled by the preprocess* functions, so continue.
548 continue
549 elif args[0][0] == '%':
550 # This is the beginning of a new section. Handle its header
551 # here.
552 newSection = args[0]
553 if not self._validState(newSection):
554 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection))
555
556 self._state = newSection
557 obj = self._sections[self._state]
558 self._tryFunc(lambda: obj.handleHeader(lineno, args))
559
560 # This will handle all section processing, kicking us back
561 # out to STATE_COMMANDS at the end with the current line
562 # being the next section header, etc.
563 lineno = self._readSection(lineIter, lineno)
564 else:
565 # This is a command in the command section. Dispatch to it.
566 self._tryFunc(lambda: self.handleCommand(lineno, args))
567 elif self._state == STATE_END:
568 break
569
570 def readKickstartFromString (self, s, reset=True):
571 """Process a kickstart file, provided as the string str."""
572 if reset:
573 self._reset()
574
575 # Add a "" to the end of the list so the string reader acts like the
576 # file reader and we only get StopIteration when we're after the final
577 # line of input.
578 i = PutBackIterator(s.splitlines(True) + [""])
579 self._stateMachine (i)
580
581 def readKickstart(self, f, reset=True):
582 """Process a kickstart file, given by the filename f."""
583 if reset:
584 self._reset()
585
586 # an %include might not specify a full path. if we don't try to figure
587 # out what the path should have been, then we're unable to find it
588 # requiring full path specification, though, sucks. so let's make
589 # the reading "smart" by keeping track of what the path is at each
590 # include depth.
591 if not os.path.exists(f):
592 if self.currentdir.has_key(self._includeDepth - 1):
593 if os.path.exists(os.path.join(self.currentdir[self._includeDepth - 1], f)):
594 f = os.path.join(self.currentdir[self._includeDepth - 1], f)
595
596 cd = os.path.dirname(f)
597 if not cd.startswith("/"):
598 cd = os.path.abspath(cd)
599 self.currentdir[self._includeDepth] = cd
600
601 try:
602 s = file(f).read()
603 except IOError, e:
604 raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
605
606 self.readKickstartFromString(s, reset=False)
607
608 def setupSections(self):
609 """Install the sections all kickstart files support. You may override
610 this method in a subclass, but should avoid doing so unless you know
611 what you're doing.
612 """
613 self._sections = {}
614
615 # Install the sections all kickstart files support.
616 self.registerSection(PreScriptSection(self.handler, dataObj=Script))
617 self.registerSection(PostScriptSection(self.handler, dataObj=Script))
618 self.registerSection(TracebackScriptSection(self.handler, dataObj=Script))
619 self.registerSection(PackageSection(self.handler))
diff --git a/scripts/lib/wic/3rdparty/pykickstart/sections.py b/scripts/lib/wic/3rdparty/pykickstart/sections.py
deleted file mode 100644
index 44df856b8d..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/sections.py
+++ /dev/null
@@ -1,244 +0,0 @@
1#
2# sections.py: Kickstart file sections.
3#
4# Chris Lumens <clumens@redhat.com>
5#
6# Copyright 2011 Red Hat, Inc.
7#
8# This copyrighted material is made available to anyone wishing to use, modify,
9# copy, or redistribute it subject to the terms and conditions of the GNU
10# General Public License v.2. This program is distributed in the hope that it
11# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
12# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13# See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
18# trademarks that are incorporated in the source code or documentation are not
19# subject to the GNU General Public License and may only be used or replicated
20# with the express permission of Red Hat, Inc.
21#
22"""
23This module exports the classes that define a section of a kickstart file. A
24section is a chunk of the file starting with a %tag and ending with a %end.
25Examples of sections include %packages, %pre, and %post.
26
27You may use this module to define your own custom sections which will be
28treated just the same as a predefined one by the kickstart parser. All that
29is necessary is to create a new subclass of Section and call
30parser.registerSection with an instance of your new class.
31"""
32from constants import *
33from options import KSOptionParser
34from version import *
35
36class Section(object):
37 """The base class for defining kickstart sections. You are free to
38 subclass this as appropriate.
39
40 Class attributes:
41
42 allLines -- Does this section require the parser to call handleLine
43 for every line in the section, even blanks and comments?
44 sectionOpen -- The string that denotes the start of this section. You
45 must start your tag with a percent sign.
46 timesSeen -- This attribute is for informational purposes only. It is
47 incremented every time handleHeader is called to keep
48 track of the number of times a section of this type is
49 seen.
50 """
51 allLines = False
52 sectionOpen = ""
53 timesSeen = 0
54
55 def __init__(self, handler, **kwargs):
56 """Create a new Script instance. At the least, you must pass in an
57 instance of a baseHandler subclass.
58
59 Valid kwargs:
60
61 dataObj --
62 """
63 self.handler = handler
64
65 self.version = self.handler.version
66
67 self.dataObj = kwargs.get("dataObj", None)
68
69 def finalize(self):
70 """This method is called when the %end tag for a section is seen. It
71 is not required to be provided.
72 """
73 pass
74
75 def handleLine(self, line):
76 """This method is called for every line of a section. Take whatever
77 action is appropriate. While this method is not required to be
78 provided, not providing it does not make a whole lot of sense.
79
80 Arguments:
81
82 line -- The complete line, with any trailing newline.
83 """
84 pass
85
86 def handleHeader(self, lineno, args):
87 """This method is called when the opening tag for a section is seen.
88 Not all sections will need this method, though all provided with
89 kickstart include one.
90
91 Arguments:
92
93 args -- A list of all strings passed as arguments to the section
94 opening tag.
95 """
96 self.timesSeen += 1
97
98class NullSection(Section):
99 """This defines a section that pykickstart will recognize but do nothing
100 with. If the parser runs across a %section that has no object registered,
101 it will raise an error. Sometimes, you may want to simply ignore those
102 sections instead. This class is useful for that purpose.
103 """
104 def __init__(self, *args, **kwargs):
105 """Create a new NullSection instance. You must pass a sectionOpen
106 parameter (including a leading '%') for the section you wish to
107 ignore.
108 """
109 Section.__init__(self, *args, **kwargs)
110 self.sectionOpen = kwargs.get("sectionOpen")
111
112class ScriptSection(Section):
113 allLines = True
114
115 def __init__(self, *args, **kwargs):
116 Section.__init__(self, *args, **kwargs)
117 self._script = {}
118 self._resetScript()
119
120 def _getParser(self):
121 op = KSOptionParser(self.version)
122 op.add_option("--erroronfail", dest="errorOnFail", action="store_true",
123 default=False)
124 op.add_option("--interpreter", dest="interpreter", default="/bin/sh")
125 op.add_option("--log", "--logfile", dest="log")
126 return op
127
128 def _resetScript(self):
129 self._script = {"interp": "/bin/sh", "log": None, "errorOnFail": False,
130 "lineno": None, "chroot": False, "body": []}
131
132 def handleLine(self, line):
133 self._script["body"].append(line)
134
135 def finalize(self):
136 if " ".join(self._script["body"]).strip() == "":
137 return
138
139 kwargs = {"interp": self._script["interp"],
140 "inChroot": self._script["chroot"],
141 "lineno": self._script["lineno"],
142 "logfile": self._script["log"],
143 "errorOnFail": self._script["errorOnFail"],
144 "type": self._script["type"]}
145
146 s = self.dataObj (self._script["body"], **kwargs)
147 self._resetScript()
148
149 if self.handler:
150 self.handler.scripts.append(s)
151
152 def handleHeader(self, lineno, args):
153 """Process the arguments to a %pre/%post/%traceback header for later
154 setting on a Script instance once the end of the script is found.
155 This method may be overridden in a subclass if necessary.
156 """
157 Section.handleHeader(self, lineno, args)
158 op = self._getParser()
159
160 (opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
161
162 self._script["interp"] = opts.interpreter
163 self._script["lineno"] = lineno
164 self._script["log"] = opts.log
165 self._script["errorOnFail"] = opts.errorOnFail
166 if hasattr(opts, "nochroot"):
167 self._script["chroot"] = not opts.nochroot
168
169class PreScriptSection(ScriptSection):
170 sectionOpen = "%pre"
171
172 def _resetScript(self):
173 ScriptSection._resetScript(self)
174 self._script["type"] = KS_SCRIPT_PRE
175
176class PostScriptSection(ScriptSection):
177 sectionOpen = "%post"
178
179 def _getParser(self):
180 op = ScriptSection._getParser(self)
181 op.add_option("--nochroot", dest="nochroot", action="store_true",
182 default=False)
183 return op
184
185 def _resetScript(self):
186 ScriptSection._resetScript(self)
187 self._script["chroot"] = True
188 self._script["type"] = KS_SCRIPT_POST
189
190class TracebackScriptSection(ScriptSection):
191 sectionOpen = "%traceback"
192
193 def _resetScript(self):
194 ScriptSection._resetScript(self)
195 self._script["type"] = KS_SCRIPT_TRACEBACK
196
197class PackageSection(Section):
198 sectionOpen = "%packages"
199
200 def handleLine(self, line):
201 if not self.handler:
202 return
203
204 (h, s, t) = line.partition('#')
205 line = h.rstrip()
206
207 self.handler.packages.add([line])
208
209 def handleHeader(self, lineno, args):
210 """Process the arguments to the %packages header and set attributes
211 on the Version's Packages instance appropriate. This method may be
212 overridden in a subclass if necessary.
213 """
214 Section.handleHeader(self, lineno, args)
215 op = KSOptionParser(version=self.version)
216 op.add_option("--excludedocs", dest="excludedocs", action="store_true",
217 default=False)
218 op.add_option("--ignoremissing", dest="ignoremissing",
219 action="store_true", default=False)
220 op.add_option("--nobase", dest="nobase", action="store_true",
221 default=False)
222 op.add_option("--ignoredeps", dest="resolveDeps", action="store_false",
223 deprecated=FC4, removed=F9)
224 op.add_option("--resolvedeps", dest="resolveDeps", action="store_true",
225 deprecated=FC4, removed=F9)
226 op.add_option("--default", dest="defaultPackages", action="store_true",
227 default=False, introduced=F7)
228 op.add_option("--instLangs", dest="instLangs", type="string",
229 default="", introduced=F9)
230
231 (opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
232
233 self.handler.packages.excludeDocs = opts.excludedocs
234 self.handler.packages.addBase = not opts.nobase
235 if opts.ignoremissing:
236 self.handler.packages.handleMissing = KS_MISSING_IGNORE
237 else:
238 self.handler.packages.handleMissing = KS_MISSING_PROMPT
239
240 if opts.defaultPackages:
241 self.handler.packages.default = True
242
243 if opts.instLangs:
244 self.handler.packages.instLangs = opts.instLangs
diff --git a/scripts/lib/wic/3rdparty/pykickstart/version.py b/scripts/lib/wic/3rdparty/pykickstart/version.py
deleted file mode 100644
index 8a8e6aad22..0000000000
--- a/scripts/lib/wic/3rdparty/pykickstart/version.py
+++ /dev/null
@@ -1,168 +0,0 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2006, 2007, 2008, 2009, 2010 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#
20"""
21Methods for working with kickstart versions.
22
23This module defines several symbolic constants that specify kickstart syntax
24versions. Each version corresponds roughly to one release of Red Hat Linux,
25Red Hat Enterprise Linux, or Fedora Core as these are where most syntax
26changes take place.
27
28This module also exports several functions:
29
30 makeVersion - Given a version number, return an instance of the
31 matching handler class.
32
33 returnClassForVersion - Given a version number, return the matching
34 handler class. This does not return an
35 instance of that class, however.
36
37 stringToVersion - Convert a string representation of a version number
38 into the symbolic constant.
39
40 versionToString - Perform the reverse mapping.
41
42 versionFromFile - Read a kickstart file and determine the version of
43 syntax it uses. This requires the kickstart file to
44 have a version= comment in it.
45"""
46import imputil, re, sys
47
48import gettext
49_ = lambda x: gettext.ldgettext("pykickstart", x)
50
51from pykickstart.errors import KickstartVersionError
52
53# Symbolic names for internal version numbers.
54RHEL3 = 900
55FC3 = 1000
56RHEL4 = 1100
57FC4 = 2000
58FC5 = 3000
59FC6 = 4000
60RHEL5 = 4100
61F7 = 5000
62F8 = 6000
63F9 = 7000
64F10 = 8000
65F11 = 9000
66F12 = 10000
67F13 = 11000
68RHEL6 = 11100
69F14 = 12000
70F15 = 13000
71F16 = 14000
72
73# This always points at the latest version and is the default.
74DEVEL = F16
75
76# A one-to-one mapping from string representations to version numbers.
77versionMap = {
78 "DEVEL": DEVEL,
79 "FC3": FC3, "FC4": FC4, "FC5": FC5, "FC6": FC6, "F7": F7, "F8": F8,
80 "F9": F9, "F10": F10, "F11": F11, "F12": F12, "F13": F13,
81 "F14": F14, "F15": F15, "F16": F16,
82 "RHEL3": RHEL3, "RHEL4": RHEL4, "RHEL5": RHEL5, "RHEL6": RHEL6
83}
84
85def stringToVersion(s):
86 """Convert string into one of the provided version constants. Raises
87 KickstartVersionError if string does not match anything.
88 """
89 # First try these short forms.
90 try:
91 return versionMap[s.upper()]
92 except KeyError:
93 pass
94
95 # Now try the Fedora versions.
96 m = re.match("^fedora.* (\d+)$", s, re.I)
97
98 if m and m.group(1):
99 if versionMap.has_key("FC" + m.group(1)):
100 return versionMap["FC" + m.group(1)]
101 elif versionMap.has_key("F" + m.group(1)):
102 return versionMap["F" + m.group(1)]
103 else:
104 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
105
106 # Now try the RHEL versions.
107 m = re.match("^red hat enterprise linux.* (\d+)([\.\d]*)$", s, re.I)
108
109 if m and m.group(1):
110 if versionMap.has_key("RHEL" + m.group(1)):
111 return versionMap["RHEL" + m.group(1)]
112 else:
113 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
114
115 # If nothing else worked, we're out of options.
116 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
117
118def versionToString(version, skipDevel=False):
119 """Convert version into a string representation of the version number.
120 This is the reverse operation of stringToVersion. Raises
121 KickstartVersionError if version does not match anything.
122 """
123 if not skipDevel and version == versionMap["DEVEL"]:
124 return "DEVEL"
125
126 for (key, val) in versionMap.iteritems():
127 if key == "DEVEL":
128 continue
129 elif val == version:
130 return key
131
132 raise KickstartVersionError(_("Unsupported version specified: %s") % version)
133
134def returnClassForVersion(version=DEVEL):
135 """Return the class of the syntax handler for version. version can be
136 either a string or the matching constant. Raises KickstartValueError
137 if version does not match anything.
138 """
139 try:
140 version = int(version)
141 module = "%s" % versionToString(version, skipDevel=True)
142 except ValueError:
143 module = "%s" % version
144 version = stringToVersion(version)
145
146 module = module.lower()
147
148 try:
149 import pykickstart.handlers
150 sys.path.extend(pykickstart.handlers.__path__)
151 found = imputil.imp.find_module(module)
152 loaded = imputil.imp.load_module(module, found[0], found[1], found[2])
153
154 for (k, v) in loaded.__dict__.iteritems():
155 if k.lower().endswith("%shandler" % module):
156 return v
157 except:
158 raise KickstartVersionError(_("Unsupported version specified: %s") % version)
159
160def makeVersion(version=DEVEL):
161 """Return a new instance of the syntax handler for version. version can be
162 either a string or the matching constant. This function is useful for
163 standalone programs which just need to handle a specific version of
164 kickstart syntax (as provided by a command line argument, for example)
165 and need to instantiate the correct object.
166 """
167 cl = returnClassForVersion(version)
168 return cl()
diff --git a/scripts/lib/wic/kickstart/__init__.py b/scripts/lib/wic/kickstart/__init__.py
deleted file mode 100644
index 79b39fbf3f..0000000000
--- a/scripts/lib/wic/kickstart/__init__.py
+++ /dev/null
@@ -1,129 +0,0 @@
1#!/usr/bin/env python -tt
2#
3# Copyright (c) 2007 Red Hat, Inc.
4# Copyright (c) 2009, 2010, 2011 Intel, Inc.
5#
6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the Free
8# Software Foundation; version 2 of the License
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13# for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc., 59
17# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19import os, sys, re
20import shutil
21import subprocess
22import string
23
24import pykickstart.sections as kssections
25import pykickstart.commands as kscommands
26import pykickstart.constants as ksconstants
27import pykickstart.errors as kserrors
28import pykickstart.parser as ksparser
29import pykickstart.version as ksversion
30from pykickstart.handlers.control import commandMap
31from pykickstart.handlers.control import dataMap
32
33from wic import msger
34from wic.utils import errors, misc, runner, fs_related as fs
35from custom_commands import wicboot, partition
36
37def read_kickstart(path):
38 """Parse a kickstart file and return a KickstartParser instance.
39
40 This is a simple utility function which takes a path to a kickstart file,
41 parses it and returns a pykickstart KickstartParser instance which can
42 be then passed to an ImageCreator constructor.
43
44 If an error occurs, a CreatorError exception is thrown.
45 """
46
47 #version = ksversion.makeVersion()
48 #ks = ksparser.KickstartParser(version)
49
50 using_version = ksversion.DEVEL
51 commandMap[using_version]["bootloader"] = wicboot.Wic_Bootloader
52 commandMap[using_version]["part"] = partition.Wic_Partition
53 commandMap[using_version]["partition"] = partition.Wic_Partition
54 dataMap[using_version]["PartData"] = partition.Wic_PartData
55 superclass = ksversion.returnClassForVersion(version=using_version)
56
57 class KSHandlers(superclass):
58 def __init__(self):
59 superclass.__init__(self, mapping=commandMap[using_version])
60
61 kickstart = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=True)
62
63 try:
64 kickstart.readKickstart(path)
65 except (kserrors.KickstartParseError, kserrors.KickstartError), err:
66 msger.warning("Errors occurred when parsing kickstart file: %s\n" % path)
67 msger.error("%s" % err)
68
69 return kickstart
70
71def get_image_size(kickstart, default=None):
72 __size = 0
73 for part in kickstart.handler.partition.partitions:
74 if part.mountpoint == "/" and part.size:
75 __size = part.size
76 if __size > 0:
77 return int(__size) * 1024L
78 else:
79 return default
80
81def get_image_fstype(kickstart, default=None):
82 for part in kickstart.handler.partition.partitions:
83 if part.mountpoint == "/" and part.fstype:
84 return part.fstype
85 return default
86
87def get_image_fsopts(kickstart, default=None):
88 for part in kickstart.handler.partition.partitions:
89 if part.mountpoint == "/" and part.fsopts:
90 return part.fsopts
91 return default
92
93def get_timeout(kickstart, default=None):
94 if not hasattr(kickstart.handler.bootloader, "timeout"):
95 return default
96 if kickstart.handler.bootloader.timeout is None:
97 return default
98 return int(kickstart.handler.bootloader.timeout)
99
100def get_bootloader_file(kickstart, default=None):
101 if not hasattr(kickstart.handler.bootloader, "configfile"):
102 return default
103 if kickstart.handler.bootloader.configfile is None:
104 return default
105 return kickstart.handler.bootloader.configfile
106
107def get_kernel_args(kickstart, default="ro rd.live.image"):
108 if not hasattr(kickstart.handler.bootloader, "appendLine"):
109 return default
110 if kickstart.handler.bootloader.appendLine is None:
111 return default
112 return "%s %s" %(default, kickstart.handler.bootloader.appendLine)
113
114def get_menu_args(kickstart, default=""):
115 if not hasattr(kickstart.handler.bootloader, "menus"):
116 return default
117 if kickstart.handler.bootloader.menus in (None, ""):
118 return default
119 return "%s" % kickstart.handler.bootloader.menus
120
121def get_default_kernel(kickstart, default=None):
122 if not hasattr(kickstart.handler.bootloader, "default"):
123 return default
124 if not kickstart.handler.bootloader.default:
125 return default
126 return kickstart.handler.bootloader.default
127
128def get_partitions(kickstart):
129 return kickstart.handler.partition.partitions
diff --git a/scripts/lib/wic/kickstart/custom_commands/__init__.py b/scripts/lib/wic/kickstart/custom_commands/__init__.py
deleted file mode 100644
index e4ae40622c..0000000000
--- a/scripts/lib/wic/kickstart/custom_commands/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
1from partition import Wic_Partition
2from partition import Wic_PartData
3
4__all__ = (
5 "Wic_Partition",
6 "Wic_PartData",
7)
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py
deleted file mode 100644
index babc006945..0000000000
--- a/scripts/lib/wic/kickstart/custom_commands/partition.py
+++ /dev/null
@@ -1,526 +0,0 @@
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 module provides the OpenEmbedded partition object definitions.
22#
23# AUTHORS
24# Tom Zanussi <tom.zanussi (at] linux.intel.com>
25#
26
27import os
28import tempfile
29import uuid
30from optparse import OptionValueError
31
32from pykickstart.commands.partition import FC4_PartData, FC4_Partition
33from wic.utils.oe.misc import msger, parse_sourceparams
34from wic.utils.oe.misc import exec_cmd, exec_native_cmd
35from wic.plugin import pluginmgr
36
37partition_methods = {
38 "do_stage_partition":None,
39 "do_prepare_partition":None,
40 "do_configure_partition":None,
41}
42
43class Wic_PartData(FC4_PartData):
44 removedKeywords = FC4_PartData.removedKeywords
45 removedAttrs = FC4_PartData.removedAttrs
46
47 def __init__(self, *args, **kwargs):
48 FC4_PartData.__init__(self, *args, **kwargs)
49 self.deleteRemovedAttrs()
50 self.align = kwargs.get("align", None)
51 self.extopts = kwargs.get("extopts", None)
52 self.part_type = kwargs.get("part_type", None)
53 self.source = kwargs.get("source", None)
54 self.sourceparams = kwargs.get("sourceparams", None)
55 self.rootfs = kwargs.get("rootfs-dir", None)
56 self.no_table = kwargs.get("no-table", False)
57 self.extra_space = kwargs.get("extra-space", "10M")
58 self.overhead_factor = kwargs.get("overhead-factor", 1.3)
59 self._use_uuid = False
60 self.uuid = kwargs.get("uuid", None)
61 self.use_uuid = kwargs.get("use-uuid", False)
62 self.source_file = ""
63 self.size = 0
64
65 def _getArgsAsStr(self):
66 retval = FC4_PartData._getArgsAsStr(self)
67
68 if self.align:
69 retval += " --align=%d" % self.align
70 if self.extopts:
71 retval += " --extoptions=%s" % self.extopts
72 if self.part_type:
73 retval += " --part-type=%s" % self.part_type
74 if self.source:
75 retval += " --source=%s" % self.source
76 if self.sourceparams:
77 retval += " --sourceparams=%s" % self.sourceparams
78 if self.rootfs:
79 retval += " --rootfs-dir=%s" % self.rootfs
80 if self.no_table:
81 retval += " --no-table"
82 if self.use_uuid:
83 retval += " --use-uuid"
84 if self.uuid:
85 retval += " --uuid=%s" % self.uuid
86 retval += " --extra-space=%s" % self.extra_space
87 retval += " --overhead-factor=%f" % self.overhead_factor
88
89 return retval
90
91 @property
92 def use_uuid(self):
93 return self._use_uuid
94
95 @use_uuid.setter
96 def use_uuid(self, value):
97 self._use_uuid = value
98 if value and not self.uuid:
99 self.uuid = str(uuid.uuid4())
100
101 def get_rootfs(self):
102 """
103 Acessor for rootfs dir
104 """
105 return self.rootfs
106
107 def set_rootfs(self, rootfs):
108 """
109 Acessor for actual rootfs dir, which must be set by source
110 plugins.
111 """
112 self.rootfs = rootfs
113
114 def get_size(self):
115 """
116 Accessor for partition size, 0 or --size before set_size().
117 """
118 return self.size
119
120 def set_size(self, size):
121 """
122 Accessor for actual partition size, which must be set by source
123 plugins.
124 """
125 self.size = size
126
127 def set_source_file(self, source_file):
128 """
129 Accessor for source_file, the location of the generated partition
130 image, which must be set by source plugins.
131 """
132 self.source_file = source_file
133
134 def get_extra_block_count(self, current_blocks):
135 """
136 The --size param is reflected in self.size (in kB), and we already
137 have current_blocks (1k) blocks, calculate and return the
138 number of (1k) blocks we need to add to get to --size, 0 if
139 we're already there or beyond.
140 """
141 msger.debug("Requested partition size for %s: %d" % \
142 (self.mountpoint, self.size))
143
144 if not self.size:
145 return 0
146
147 requested_blocks = self.size
148
149 msger.debug("Requested blocks %d, current_blocks %d" % \
150 (requested_blocks, current_blocks))
151
152 if requested_blocks > current_blocks:
153 return requested_blocks - current_blocks
154 else:
155 return 0
156
157 def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir,
158 kernel_dir, native_sysroot):
159 """
160 Prepare content for individual partitions, depending on
161 partition command parameters.
162 """
163 self.sourceparams_dict = {}
164
165 if self.sourceparams:
166 self.sourceparams_dict = parse_sourceparams(self.sourceparams)
167
168 if not self.source:
169 if not self.size:
170 msger.error("The %s partition has a size of zero. Please "
171 "specify a non-zero --size for that partition." % \
172 self.mountpoint)
173 if self.fstype and self.fstype == "swap":
174 self.prepare_swap_partition(cr_workdir, oe_builddir,
175 native_sysroot)
176 elif self.fstype:
177 rootfs = "%s/fs_%s.%s.%s" % (cr_workdir, self.label,
178 self.lineno, self.fstype)
179 if os.path.isfile(rootfs):
180 os.remove(rootfs)
181 for prefix in ("ext", "btrfs", "vfat", "squashfs"):
182 if self.fstype.startswith(prefix):
183 method = getattr(self,
184 "prepare_empty_partition_" + prefix)
185 method(rootfs, oe_builddir, native_sysroot)
186 self.source_file = rootfs
187 break
188 return
189
190 plugins = pluginmgr.get_source_plugins()
191
192 if self.source not in plugins:
193 msger.error("The '%s' --source specified for %s doesn't exist.\n\t"
194 "See 'wic list source-plugins' for a list of available"
195 " --sources.\n\tSee 'wic help source-plugins' for "
196 "details on adding a new source plugin." % \
197 (self.source, self.mountpoint))
198
199 self._source_methods = pluginmgr.get_source_plugin_methods(\
200 self.source, partition_methods)
201 self._source_methods["do_configure_partition"](self, self.sourceparams_dict,
202 creator, cr_workdir,
203 oe_builddir,
204 bootimg_dir,
205 kernel_dir,
206 native_sysroot)
207 self._source_methods["do_stage_partition"](self, self.sourceparams_dict,
208 creator, cr_workdir,
209 oe_builddir,
210 bootimg_dir, kernel_dir,
211 native_sysroot)
212 self._source_methods["do_prepare_partition"](self, self.sourceparams_dict,
213 creator, cr_workdir,
214 oe_builddir,
215 bootimg_dir, kernel_dir, rootfs_dir,
216 native_sysroot)
217
218 def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir,
219 rootfs_dir):
220 """
221 Handle an already-created partition e.g. xxx.ext3
222 """
223 rootfs = oe_builddir
224 du_cmd = "du -Lbks %s" % rootfs
225 out = exec_cmd(du_cmd)
226 rootfs_size = out.split()[0]
227
228 self.size = rootfs_size
229 self.source_file = rootfs
230
231 def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir,
232 native_sysroot):
233 """
234 Prepare content for a rootfs partition i.e. create a partition
235 and fill it from a /rootfs dir.
236
237 Currently handles ext2/3/4, btrfs and vfat.
238 """
239 p_prefix = os.environ.get("PSEUDO_PREFIX", "%s/usr" % native_sysroot)
240 p_localstatedir = os.environ.get("PSEUDO_LOCALSTATEDIR",
241 "%s/../pseudo" % rootfs_dir)
242 p_passwd = os.environ.get("PSEUDO_PASSWD", rootfs_dir)
243 p_nosymlinkexp = os.environ.get("PSEUDO_NOSYMLINKEXP", "1")
244 pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix
245 pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % p_localstatedir
246 pseudo += "export PSEUDO_PASSWD=%s;" % p_passwd
247 pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp
248 pseudo += "%s/usr/bin/pseudo " % native_sysroot
249
250 rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label,
251 self.lineno, self.fstype)
252 if os.path.isfile(rootfs):
253 os.remove(rootfs)
254
255 for prefix in ("ext", "btrfs", "vfat", "squashfs"):
256 if self.fstype.startswith(prefix):
257 method = getattr(self, "prepare_rootfs_" + prefix)
258 method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo)
259
260 self.source_file = rootfs
261
262 # get the rootfs size in the right units for kickstart (kB)
263 du_cmd = "du -Lbks %s" % rootfs
264 out = exec_cmd(du_cmd)
265 self.size = out.split()[0]
266
267 break
268
269 def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
270 native_sysroot, pseudo):
271 """
272 Prepare content for an ext2/3/4 rootfs partition.
273 """
274 du_cmd = "du -ks %s" % rootfs_dir
275 out = exec_cmd(du_cmd)
276 actual_rootfs_size = int(out.split()[0])
277
278 extra_blocks = self.get_extra_block_count(actual_rootfs_size)
279 if extra_blocks < self.extra_space:
280 extra_blocks = self.extra_space
281
282 rootfs_size = actual_rootfs_size + extra_blocks
283 rootfs_size *= self.overhead_factor
284
285 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
286 (extra_blocks, self.mountpoint, rootfs_size))
287
288 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
289 (rootfs, rootfs_size)
290 exec_cmd(dd_cmd)
291
292 extra_imagecmd = "-i 8192"
293
294 label_str = ""
295 if self.label:
296 label_str = "-L %s" % self.label
297
298 mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
299 (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
300 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
301
302 def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
303 native_sysroot, pseudo):
304 """
305 Prepare content for a btrfs rootfs partition.
306
307 Currently handles ext2/3/4 and btrfs.
308 """
309 du_cmd = "du -ks %s" % rootfs_dir
310 out = exec_cmd(du_cmd)
311 actual_rootfs_size = int(out.split()[0])
312
313 extra_blocks = self.get_extra_block_count(actual_rootfs_size)
314 if extra_blocks < self.extra_space:
315 extra_blocks = self.extra_space
316
317 rootfs_size = actual_rootfs_size + extra_blocks
318 rootfs_size *= self.overhead_factor
319
320 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
321 (extra_blocks, self.mountpoint, rootfs_size))
322
323 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
324 (rootfs, rootfs_size)
325 exec_cmd(dd_cmd)
326
327 label_str = ""
328 if self.label:
329 label_str = "-L %s" % self.label
330
331 mkfs_cmd = "mkfs.%s -b %d -r %s %s %s" % \
332 (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs)
333 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
334
335 def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir,
336 native_sysroot, pseudo):
337 """
338 Prepare content for a vfat rootfs partition.
339 """
340 du_cmd = "du -bks %s" % rootfs_dir
341 out = exec_cmd(du_cmd)
342 blocks = int(out.split()[0])
343
344 extra_blocks = self.get_extra_block_count(blocks)
345 if extra_blocks < self.extra_space:
346 extra_blocks = self.extra_space
347
348 blocks += extra_blocks
349
350 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
351 (extra_blocks, self.mountpoint, blocks))
352
353 # Ensure total sectors is an integral number of sectors per
354 # track or mcopy will complain. Sectors are 512 bytes, and we
355 # generate images with 32 sectors per track. This calculation
356 # is done in blocks, thus the mod by 16 instead of 32. Apply
357 # sector count fix only when needed.
358 if blocks % 16 != 0:
359 blocks += (16 - (blocks % 16))
360
361 label_str = "-n boot"
362 if self.label:
363 label_str = "-n %s" % self.label
364
365 dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, rootfs, blocks)
366 exec_native_cmd(dosfs_cmd, native_sysroot)
367
368 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
369 exec_native_cmd(mcopy_cmd, native_sysroot)
370
371 chmod_cmd = "chmod 644 %s" % rootfs
372 exec_cmd(chmod_cmd)
373
374 def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir,
375 native_sysroot, pseudo):
376 """
377 Prepare content for a squashfs rootfs partition.
378 """
379 squashfs_cmd = "mksquashfs %s %s -noappend" % \
380 (rootfs_dir, rootfs)
381 exec_native_cmd(squashfs_cmd, native_sysroot, pseudo=pseudo)
382
383 def prepare_empty_partition_ext(self, rootfs, oe_builddir,
384 native_sysroot):
385 """
386 Prepare an empty ext2/3/4 partition.
387 """
388 dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
389 (rootfs, self.size)
390 exec_cmd(dd_cmd)
391
392 extra_imagecmd = "-i 8192"
393
394 label_str = ""
395 if self.label:
396 label_str = "-L %s" % self.label
397
398 mkfs_cmd = "mkfs.%s -F %s %s %s" % \
399 (self.fstype, extra_imagecmd, label_str, rootfs)
400 exec_native_cmd(mkfs_cmd, native_sysroot)
401
402 def prepare_empty_partition_btrfs(self, rootfs, oe_builddir,
403 native_sysroot):
404 """
405 Prepare an empty btrfs partition.
406 """
407 dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
408 (rootfs, self.size)
409 exec_cmd(dd_cmd)
410
411 label_str = ""
412 if self.label:
413 label_str = "-L %s" % self.label
414
415 mkfs_cmd = "mkfs.%s -b %d %s %s" % \
416 (self.fstype, self.size * 1024, label_str, rootfs)
417 exec_native_cmd(mkfs_cmd, native_sysroot)
418
419 def prepare_empty_partition_vfat(self, rootfs, oe_builddir,
420 native_sysroot):
421 """
422 Prepare an empty vfat partition.
423 """
424 blocks = self.size
425
426 label_str = "-n boot"
427 if self.label:
428 label_str = "-n %s" % self.label
429
430 dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, rootfs, blocks)
431 exec_native_cmd(dosfs_cmd, native_sysroot)
432
433 chmod_cmd = "chmod 644 %s" % rootfs
434 exec_cmd(chmod_cmd)
435
436 def prepare_empty_partition_squashfs(self, cr_workdir, oe_builddir,
437 native_sysroot):
438 """
439 Prepare an empty squashfs partition.
440 """
441 msger.warning("Creating of an empty squashfs %s partition was attempted. " \
442 "Proceeding as requested." % self.mountpoint)
443
444 path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
445 os.path.isfile(path) and os.remove(path)
446
447 # it is not possible to create a squashfs without source data,
448 # thus prepare an empty temp dir that is used as source
449 tmpdir = tempfile.mkdtemp()
450
451 squashfs_cmd = "mksquashfs %s %s -noappend" % \
452 (tmpdir, path)
453 exec_native_cmd(squashfs_cmd, native_sysroot)
454
455 os.rmdir(tmpdir)
456
457 # get the rootfs size in the right units for kickstart (kB)
458 du_cmd = "du -Lbks %s" % path
459 out = exec_cmd(du_cmd)
460 fs_size = out.split()[0]
461
462 self.size = fs_size
463
464 def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
465 """
466 Prepare a swap partition.
467 """
468 path = "%s/fs.%s" % (cr_workdir, self.fstype)
469
470 dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
471 (path, self.size)
472 exec_cmd(dd_cmd)
473
474 import uuid
475 label_str = ""
476 if self.label:
477 label_str = "-L %s" % self.label
478 mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
479 exec_native_cmd(mkswap_cmd, native_sysroot)
480
481
482class Wic_Partition(FC4_Partition):
483 removedKeywords = FC4_Partition.removedKeywords
484 removedAttrs = FC4_Partition.removedAttrs
485
486 def _getParser(self):
487 def overhead_cb(option, opt_str, value, parser):
488 if value < 1:
489 raise OptionValueError("Option %s: invalid value: %r" % \
490 (option, value))
491 setattr(parser.values, option.dest, value)
492
493 parser = FC4_Partition._getParser(self)
494
495 # The alignment value is given in kBytes. e.g., value 8 means that
496 # the partition is aligned to start from 8096 byte boundary.
497 parser.add_option("--align", type="int", action="store", dest="align",
498 default=None)
499 parser.add_option("--extoptions", type="string", action="store", dest="extopts",
500 default=None)
501 parser.add_option("--part-type", type="string", action="store", dest="part_type",
502 default=None)
503 # use specified source file to fill the partition
504 # and calculate partition size
505 parser.add_option("--source", type="string", action="store",
506 dest="source", default=None)
507 # comma-separated list of param=value pairs
508 parser.add_option("--sourceparams", type="string", action="store",
509 dest="sourceparams", default=None)
510 # use specified rootfs path to fill the partition
511 parser.add_option("--rootfs-dir", type="string", action="store",
512 dest="rootfs", default=None)
513 # wether to add the partition in the partition table
514 parser.add_option("--no-table", dest="no_table", action="store_true",
515 default=False)
516 # extra space beyond the partition size
517 parser.add_option("--extra-space", dest="extra_space", action="store",
518 type="size", nargs=1, default="10M")
519 parser.add_option("--overhead-factor", dest="overhead_factor",
520 action="callback", callback=overhead_cb, type="float",
521 nargs=1, default=1.3)
522 parser.add_option("--use-uuid", dest="use_uuid", action="store_true",
523 default=False)
524 parser.add_option("--uuid")
525
526 return parser
diff --git a/scripts/lib/wic/kickstart/custom_commands/wicboot.py b/scripts/lib/wic/kickstart/custom_commands/wicboot.py
deleted file mode 100644
index eb17dab6e1..0000000000
--- a/scripts/lib/wic/kickstart/custom_commands/wicboot.py
+++ /dev/null
@@ -1,65 +0,0 @@
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) 2014, 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 module provides the OpenEmbedded bootloader object definitions.
22#
23# AUTHORS
24# Tom Zanussi <tom.zanussi (at] linux.intel.com>
25#
26from pykickstart.commands.bootloader import F8_Bootloader
27
28class Wic_Bootloader(F8_Bootloader):
29 def __init__(self, writePriority=10, appendLine="", driveorder=None,
30 forceLBA=False, location="", md5pass="", password="",
31 upgrade=False, menus=""):
32 F8_Bootloader.__init__(self, writePriority, appendLine, driveorder,
33 forceLBA, location, md5pass, password, upgrade)
34
35 self.menus = ""
36 self.ptable = "msdos"
37 self.source = ""
38 self.configfile = ""
39
40 def _getArgsAsStr(self):
41 retval = F8_Bootloader._getArgsAsStr(self)
42
43 if self.menus == "":
44 retval += " --menus=%s" %(self.menus,)
45 if self.ptable:
46 retval += " --ptable=\"%s\"" %(self.ptable,)
47 if self.source:
48 retval += " --source=%s" % self.source
49 if self.configfile:
50 retval += " --configfile=%s" % self.configfile
51
52 return retval
53
54 def _getParser(self):
55 parser = F8_Bootloader._getParser(self)
56 parser.add_option("--menus", dest="menus")
57 parser.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"),
58 default="msdos")
59 # use specified source plugin to implement bootloader-specific methods
60 parser.add_option("--source", type="string", action="store",
61 dest="source", default=None)
62 parser.add_option("--configfile", type="string", action="store",
63 dest="configfile", default=None)
64 return parser
65