Re: [PATCH] Add --root-device to upgrade in ks.cfg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeremy Katz wrote:

This makes sense, but we probably want to be a little bit more flexible. In addition to specifying the device name, UUID or LABEL should be usable also. Especially as we continue to de-emphasize device naming due to its somewhat unpredictable nature.


Good afternoon,
here's take two at this. No need to change pykickstart again, we just change the meaning to:

upgrade [--root-device=DEV] where

DEV=/dev/sda1               or
DEV=UUID=abcd-fdeb-....     or
DEV=LABEL=/


Anaconda will try to match the supplied parameter to the device name, label or UUID. If we succeed then this is the device we're looking for.

Thanks,
Alexander.
 upgrade.py |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/upgrade.py b/upgrade.py
index 4aee58c..2fb6ef6 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -128,9 +128,29 @@ def findRootParts(anaconda):
     if anaconda.id.rootParts is None:
         anaconda.id.rootParts = findExistingRoots(anaconda)
 
+    root_device = None
+    # ks.cfg can pass device as raw device, label or uuid
+    if (anaconda.id.ksdata is not None) and anaconda.id.ksdata.upgrade and (anaconda.id.ksdata.upgrade.root_device is not None):
+        root_device=anaconda.id.ksdata.upgrade.root_device
+
+        if root_device.startswith("LABEL="):
+           root_device = root_device[6:]
+
+        if root_device.startswith("UUID="):
+           root_device = root_device[5:]
+
+        # strip both kind of quotes. we can pass UUID="ID"
+        root_device = root_device.strip('"')
+        root_device = root_device.strip("'")
+
     anaconda.id.upgradeRoot = []
     for (dev, fs, meta, label) in anaconda.id.rootParts:
-        anaconda.id.upgradeRoot.append( (dev, fs) )
+        if (root_device is not None):
+            uuid = isys.readFSUuid(dev)
+            if (root_device == dev) or (root_device == label) or (root_device == uuid):                
+                anaconda.id.upgradeRoot.append( (dev, fs) )
+        else:
+            anaconda.id.upgradeRoot.append( (dev, fs) )
 
     if anaconda.id.rootParts is not None and len(anaconda.id.rootParts) > 0:
         anaconda.dispatch.skipStep("findinstall", skip = 0)
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux