Hi all,
the attached patches against anaconda and pykickstart add new option to the
upgrade command in kickstart.
upgrade [--root-device=/dev/sda2]
The purpose is to be able to automatically upgrade systems that are dual boot.
Specifying which is the root device makes upgrades more flexible.
The patches however do not resolve a bug (or a feature) where if you have
upgrade in your ks.cfg and do not specify the root device anaconda will mount
the first in the list:
363 # XXX handle going backwards
364 def upgradeMountFilesystems(anaconda):
365 # mount everything and turn on swap
366
367 if flags.setupFilesystems:
368 try:
369 mountRootPartition(anaconda, anaconda.id.upgradeRoot[0],
anaconda.id.fsset,
370 allowDirty = 0)
Please review the patches and send me your feedback.
Thanks,
Alexander.
upgrade.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/upgrade.py b/upgrade.py
index 4aee58c..d3d8fdf 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -132,6 +132,12 @@ def findRootParts(anaconda):
for (dev, fs, meta, label) in anaconda.id.rootParts:
anaconda.id.upgradeRoot.append( (dev, fs) )
+ # remove all except device from ks.cfg
+ if (anaconda.id.ksdata is not None) and anaconda.id.ksdata.upgrade and (anaconda.id.ksdata.upgrade.root_device is not None):
+ for (dev, fs) in anaconda.id.upgradeRoot:
+ if (anaconda.id.ksdata.upgrade.root_device != dev):
+ anaconda.id.upgradeRoot.remove( (dev, fs) )
+
if anaconda.id.rootParts is not None and len(anaconda.id.rootParts) > 0:
anaconda.dispatch.skipStep("findinstall", skip = 0)
if productName.find("Red Hat Enterprise Linux") == -1:
pykickstart/commands/upgrade.py | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/pykickstart/commands/upgrade.py b/pykickstart/commands/upgrade.py
index b7dba86..8510fbe 100644
--- a/pykickstart/commands/upgrade.py
+++ b/pykickstart/commands/upgrade.py
@@ -30,20 +30,37 @@ class FC3_Upgrade(KickstartCommand):
def __init__(self, writePriority=0, *args, **kwargs):
KickstartCommand.__init__(self, writePriority, *args, **kwargs)
+ self.op = self._getParser()
+
self.upgrade = kwargs.get("upgrade", None)
+ self.root_device = kwargs.get("root_device", None)
def __str__(self):
if self.upgrade is None:
- return ""
+ retval=""
if self.upgrade:
- return "# Upgrade existing installation\nupgrade\n"
+ if (self.root_device is not None):
+ retval="# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device
+ else:
+ retval="# Upgrade existing installation\nupgrade\n"
else:
- return "# Install OS instead of upgrade\ninstall\n"
+ retval="# Install OS instead of upgrade\ninstall\n"
+
+ return retval
+
+ def _getParser(self):
+ op = KSOptionParser(lineno=self.lineno)
+ op.add_option("--root-device", dest="root_device")
+ return op
def parse(self, args):
- if len(args) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
+ (opts, extra) = self.op.parse_args(args=args)
+
+ if (opts.root_device is not None) and (opts.root_device == ""):
+ raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))
+ else:
+ self.root_device = opts.root_device
if self.currentCmd == "upgrade":
self.upgrade = True
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list