Re: [PATCH 1/4] Have class FSSet store a pointer to the anaconda object.

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Disregard for now.  Updated version coming up.

On Tue, 1 Sep 2009, David Cantrell wrote:

FSSet already uses the anaconda object for a variety of tasks, so store
a pointer to it in FSSet.  Will need this for the modification to the
rootDevice property.
---
livecd.py           |    2 +-
packages.py         |    7 +++----
rescue.py           |    2 +-
storage/__init__.py |   36 ++++++++++++++++++------------------
upgrade.py          |    4 ++--
yuminstall.py       |    2 +-
6 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/livecd.py b/livecd.py
index 9d60efc..da33663 100644
--- a/livecd.py
+++ b/livecd.py
@@ -227,7 +227,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
        self._resizeRootfs(anaconda, wait)

        # remount filesystems
-        anaconda.id.storage.fsset.mountFilesystems(anaconda)
+        anaconda.id.storage.fsset.mountFilesystems()

        # restore the label of / to what we think it is
        rootDevice = anaconda.id.storage.fsset.rootDevice
diff --git a/packages.py b/packages.py
index dda98c4..0ee710e 100644
--- a/packages.py
+++ b/packages.py
@@ -193,9 +193,8 @@ def turnOnFilesystems(anaconda):
                sys.exit(1)

        if not anaconda.id.upgrade:
-            anaconda.id.storage.fsset.turnOnSwap(anaconda)
-            anaconda.id.storage.fsset.mountFilesystems(anaconda,
-                                                       raiseErrors=False,
+            anaconda.id.storage.fsset.turnOnSwap()
+            anaconda.id.storage.fsset.mountFilesystems(raiseErrors=False,
                                                       readOnly=False,
                                                       skipRoot=anaconda.backend.skipFormatRoot)
        else:
@@ -203,7 +202,7 @@ def turnOnFilesystems(anaconda):
                # we should write out a new fstab with the migrated fstype
                shutil.copyfile("%s/etc/fstab" % anaconda.rootPath,
                                "%s/etc/fstab.anaconda" % anaconda.rootPath)
-                anaconda.id.storage.fsset.write(anaconda.rootPath)
+                anaconda.id.storage.fsset.write()

            # and make sure /dev is mounted so we can read the bootloader
            bindMountDevDirectory(anaconda.rootPath)
diff --git a/rescue.py b/rescue.py
index 9dafec0..772d9c6 100644
--- a/rescue.py
+++ b/rescue.py
@@ -366,7 +366,7 @@ def runRescue(anaconda, instClass):
                # now turn on swap
                if not readOnly:
                    try:
-                        anaconda.id.storage.fsset.turnOnSwap(anaconda)
+                        anaconda.id.storage.fsset.turnOnSwap()
                    except:
                        log.error("Error enabling swap")

diff --git a/storage/__init__.py b/storage/__init__.py
index 2fc35aa..3c3a243 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -224,7 +224,7 @@ class Storage(object):
                                     passphrase=self.encryptionPassphrase,
                                     luksDict=self.__luksDevs,
                                     iscsi=self.iscsi)
-        self.fsset = FSSet(self.devicetree)
+        self.fsset = FSSet(self.devicetree, self.anaconda)

    def doIt(self):
        self.devicetree.processActions()
@@ -291,7 +291,7 @@ class Storage(object):
                                     luksDict=self.__luksDevs,
                                     iscsi=self.iscsi)
        self.devicetree.populate()
-        self.fsset = FSSet(self.devicetree)
+        self.fsset = FSSet(self.devicetree, self.anaconda)
        self.anaconda.id.rootParts = None
        self.anaconda.id.upgradeRoot = None
        w.pop()
@@ -915,7 +915,7 @@ class Storage(object):
        return False

    def write(self, instPath):
-        self.fsset.write(instPath)
+        self.fsset.write(instPath=instPath)
        self.iscsi.write(instPath, self.anaconda)
        self.fcoe.write(instPath, self.anaconda)
        self.zfcp.write(instPath)
@@ -1119,7 +1119,7 @@ def mountExistingSystem(anaconda, rootEnt,
            return -1

    if flags.setupFilesystems:
-        fsset.mountFilesystems(anaconda, readOnly=readOnly, skipRoot=True)
+        fsset.mountFilesystems(readOnly=readOnly, skipRoot=True)


class BlkidTab(object):
@@ -1267,8 +1267,9 @@ def get_containing_device(path, devicetree):

class FSSet(object):
    """ A class to represent a set of filesystems. """
-    def __init__(self, devicetree):
+    def __init__(self, devicetree, anaconda):
        self.devicetree = devicetree
+        self.anaconda = anaconda
        self.cryptTab = None
        self.blkidTab = None
        self.origFStab = None
@@ -1540,11 +1541,11 @@ class FSSet(object):
                                        options)
        return mtab

-    def turnOnSwap(self, anaconda, upgrading=None):
+    def turnOnSwap(self, upgrading=None):
        for device in self.swapDevices:
            if isinstance(device, FileDevice):
                # set up FileDevices' parents now that they are accessible
-                targetDir = "%s/%s" % (anaconda.rootPath, device.path)
+                targetDir = "%s/%s" % (self.anaconda.rootPath, device.path)
                parent = get_containing_device(targetDir, self.devicetree)
                if not parent:
                    log.error("cannot determine which device contains "
@@ -1559,7 +1560,7 @@ class FSSet(object):
                device.setup()
                device.format.setup()
            except SuspendError:
-                if anaconda.intf:
+                if self.anaconda.intf:
                    if upgrading:
                        msg = _("The swap device:\n\n     %s\n\n"
                                "in your /etc/fstab file is currently in "
@@ -1578,10 +1579,10 @@ class FSSet(object):
                                "to format all swap devices.") \
                              % device.path

-                    anaconda.intf.messageWindow(_("Error"), msg)
+                    self.anaconda.intf.messageWindow(_("Error"), msg)
                sys.exit(0)
            except DeviceError as (msg, path):
-                if anaconda.intf:
+                if self.anaconda.intf:
                    if upgrading:
                        err = _("Error enabling swap device %s: %s\n\n"
                                "The /etc/fstab on your upgrade partition "
@@ -1594,12 +1595,11 @@ class FSSet(object):
                                "device has not been initialized.\n\n"
                                "Press OK to exit the installer.") % \
                              (path, msg)
-                    anaconda.intf.messageWindow(_("Error"), err)
+                    self.anaconda.intf.messageWindow(_("Error"), err)
                sys.exit(0)

-    def mountFilesystems(self, anaconda, raiseErrors=None, readOnly=None,
-                         skipRoot=False):
-        intf = anaconda.intf
+    def mountFilesystems(self, raiseErrors=None, readOnly=None, skipRoot=False):
+        intf = self.anaconda.intf
        devices = self.mountpoints.values() + self.swapDevices
        devices.extend([self.dev, self.devshm, self.devpts, self.sysfs, self.proc])
        devices.sort(key=lambda d: getattr(d.format, "mountpoint", None))
@@ -1621,7 +1621,7 @@ class FSSet(object):
                #
                # -- bind formats' device and mountpoint are always both
                #    under the chroot. no exceptions. none, damn it.
-                targetDir = "%s/%s" % (anaconda.rootPath, device.path)
+                targetDir = "%s/%s" % (self.anaconda.rootPath, device.path)
                parent = get_containing_device(targetDir, self.devicetree)
                if not parent:
                    log.error("cannot determine which device contains "
@@ -1643,7 +1643,7 @@ class FSSet(object):

            try:
                device.format.setup(options=options,
-                                    chroot=anaconda.rootPath)
+                                    chroot=self.anaconda.rootPath)
            except OSError as e:
                if intf:
                    if e.errno == errno.EEXIST:
@@ -1745,7 +1745,7 @@ class FSSet(object):
        # nasty, nasty
        self.devicetree._addDevice(dev)

-    def mkDevRoot(self, instPath):
+    def mkDevRoot(self, instPath=self.anaconda.rootPath):
        root = self.rootDevice
        dev = "%s/%s" % (instPath, root.path)
        if not os.path.exists("%s/dev/root" %(instPath,)) and os.path.exists(dev):
@@ -1781,7 +1781,7 @@ class FSSet(object):

        return migratable

-    def write(self, instPath):
+    def write(self, instPath=self.anaconda.rootPath):
        """ write out all config files based on the set of filesystems """
        # /etc/fstab
        fstab_path = os.path.normpath("%s/etc/fstab" % instPath)
diff --git a/upgrade.py b/upgrade.py
index 826419c..7123df4 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -256,8 +256,8 @@ def upgradeMountFilesystems(anaconda):

        anaconda.id.storage.fsset.parseFSTab(chroot=anaconda.rootPath)
    if flags.setupFilesystems:
-        anaconda.id.storage.fsset.turnOnSwap(anaconda, upgrading=True)
-        anaconda.id.storage.fsset.mkDevRoot(anaconda.rootPath)
+        anaconda.id.storage.fsset.turnOnSwap(upgrading=True)
+        anaconda.id.storage.fsset.mkDevRoot()

    # Move /etc/rpm/platform out of the way.
    if os.path.exists(anaconda.rootPath + "/etc/rpm/platform"):
diff --git a/yuminstall.py b/yuminstall.py
index 20a3085..adaadc3 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -1476,7 +1476,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon

        # write out the fstab
        if not upgrade:
-            anaconda.id.storage.fsset.write(anaconda.rootPath)
+            anaconda.id.storage.fsset.write()
            # rootpath mode doesn't have this file around
            if os.access("/etc/modprobe.d/anaconda.conf", os.R_OK):
                shutil.copyfile("/etc/modprobe.d/anaconda.conf",


- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqdsJoACgkQ5hsjjIy1VkmxLQCg3qdeMZFUsTn1AN4rHhxwHQW9
bZcAoJ5fyULV8tyzFR9gK3lQp5TAMuY3
=fIfh
-----END PGP SIGNATURE-----

_______________________________________________
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