2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007 Red Hat, Inc.
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.
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.
20 from pykickstart.base import *
21 from pykickstart.errors import *
22 from pykickstart.options import *
25 _ = lambda x: gettext.ldgettext("pykickstart", x)
27 class FC3_Upgrade(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.upgrade = kwargs.get("upgrade", None)
34 self.op = self._getParser()
37 retval = KickstartCommand.__str__(self)
39 if self.upgrade is None:
43 retval += "# Upgrade existing installation\nupgrade\n"
45 retval += "# Install OS instead of upgrade\ninstall\n"
53 def parse(self, args):
54 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
57 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
59 if self.currentCmd == "upgrade":
66 class F11_Upgrade(FC3_Upgrade):
67 removedKeywords = FC3_Upgrade.removedKeywords
68 removedAttrs = FC3_Upgrade.removedAttrs
70 def __init__(self, writePriority=0, *args, **kwargs):
71 FC3_Upgrade.__init__(self, writePriority, *args, **kwargs)
73 self.op = self._getParser()
74 self.root_device = kwargs.get("root_device", None)
77 if self.upgrade and (self.root_device is not None):
78 retval = KickstartCommand.__str__(self)
79 retval += "# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device
81 retval = FC3_Upgrade.__str__(self)
87 op.add_option("--root-device", dest="root_device")
90 def parse(self, args):
91 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
94 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
96 if (opts.root_device is not None) and (opts.root_device == ""):
97 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))
99 self.root_device = opts.root_device
101 if self.currentCmd == "upgrade":