We're trying to reduce install.py to a simpler, more straightfoward format where it's just a list of things that need to be done. We can get rid of some of the conditional checking by moving this code into payloads and having those payloads just provide blank overridden methods. --- pyanaconda/install.py | 30 ++---------------------- pyanaconda/packaging/__init__.py | 40 ++++++++++++++++++++++++++++++++ pyanaconda/packaging/livepayload.py | 3 +++ pyanaconda/packaging/rpmostreepayload.py | 3 +++ 4 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py index 2b6b8aa..4f83a15 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -37,7 +37,6 @@ from pyanaconda.ui.lib.entropy import wait_for_entropy from pyanaconda.kickstart import runPostScripts, runPreInstallScripts from pyanaconda.kexec import setup_kexec import logging -import blivet log = logging.getLogger("anaconda")
def _writeKS(ksdata): @@ -200,10 +199,7 @@ def doInstall(storage, payload, ksdata, instClass): wait_for_entropy=entropy_wait_clbk)
turnOnFilesystems(storage, mountOnly=flags.flags.dirInstall, callbacks=callbacks_reg) - write_storage_late = (flags.flags.livecdInstall or ksdata.ostreesetup.seen - or ksdata.method.method == "liveimg") - if not write_storage_late and not flags.flags.dirInstall: - storage.write() + payload.writeStorageEarly()
# Run %pre-install scripts with the filesystem mounted and no packages with progress_report(_("Running pre-installation scripts")): @@ -244,29 +240,7 @@ def doInstall(storage, payload, ksdata, instClass): payload.preInstall(packages=packages, groups=payload.languageGroups()) payload.install()
- if write_storage_late and not flags.flags.dirInstall: - if iutil.getSysroot() != iutil.getTargetPhysicalRoot(): - blivet.setSysroot(iutil.getTargetPhysicalRoot(), - iutil.getSysroot()) - - # Now that we have the FS layout in the target, umount - # things that were in the legacy sysroot, and put them in - # the target root, except for the physical /. First, - # unmount all target filesystems. - storage.umountFilesystems() - - # Explicitly mount the root on the physical sysroot - rootmnt = storage.mountpoints.get('/') - rootmnt.setup() - rootmnt.format.setup(options=rootmnt.format.options, chroot=iutil.getTargetPhysicalRoot()) - - payload.prepareMountTargets(storage) - - # Everything else goes in the target root, including /boot - # since the bootloader code will expect to find /boot - # inside the chroot. - storage.mountFilesystems(skipRoot=True) - storage.write() + payload.writeStorageLate()
# Do bootloader. if willInstallBootloader: diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index fd548cf..3371c76 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -69,6 +69,7 @@ from blivet.errors import StorageError import blivet.util import blivet.arch from blivet.platform import platform +from blivet import setSysroot
from pyanaconda.product import productName, productVersion USER_AGENT = "%s (anaconda)/%s" %(productName, productVersion) @@ -598,6 +599,45 @@ class Payload(object):
self._copyDriverDiskFiles()
+ def writeStorageEarly(self): + """Some packaging payloads require that the storage configuration be + written out before doing installation. Right now, this is basically + just the dnfpayload. Payloads should only implement one of these + methods by overriding the unneeded one with a pass. + """ + if self.data.method.method != "liveimg" and not flags.dirInstall: + self.storage.write() + + def writeStorageLate(self): + """Some packaging payloads require that the storage configuration be + written out after doing installation. Right now, this is basically + every payload except for dnf. Payloads should only implement one of + these methods by overriding the unneeded one with a pass. + """ + if self.data.method.method == "liveimg" and not flags.dirInstall: + if iutil.getSysroot() != iutil.getTargetPhysicalRoot(): + setSysroot(iutil.getTargetPhysicalRoot(), iutil.getSysroot()) + + # Now that we have the FS layout in the target, umount + # things that were in the legacy sysroot, and put them in + # the target root, except for the physical /. First, + # unmount all target filesystems. + self.storage.umountFilesystems() + + # Explicitly mount the root on the physical sysroot + rootmnt = storage.mountpoints.get('/') + rootmnt.setup() + rootmnt.format.setup(options=rootmnt.format.options, chroot=iutil.getTargetPhysicalRoot()) + + self.prepareMountTargets(self.storage) + + # Everything else goes in the target root, including /boot + # since the bootloader code will expect to find /boot + # inside the chroot. + self.storage.mountFilesystems(skipRoot=True) + + self.storage.write() + # Inherit abstract methods from Payload # pylint: disable=abstract-method class ImagePayload(Payload): diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py index fcccb7c..c0508a5 100644 --- a/pyanaconda/packaging/livepayload.py +++ b/pyanaconda/packaging/livepayload.py @@ -539,3 +539,6 @@ class LiveImageKSPayload(LiveImagePayload): # Strip out vmlinuz- from the names return sorted((n.split("/")[-1][8:] for n in names if "boot/vmlinuz-" in n), key=functools.cmp_to_key(versionCmp)) + + def writeStorageEarly(self): + pass diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py index d68eec0..80a54a2 100644 --- a/pyanaconda/packaging/rpmostreepayload.py +++ b/pyanaconda/packaging/rpmostreepayload.py @@ -299,3 +299,6 @@ class RPMOSTreePayload(ArchivePayload): set_kargs_args.extend(self.storage.bootloader.boot_args) set_kargs_args.append("root=" + self.storage.rootDevice.fstabSpec) self._safeExecWithRedirect("ostree", set_kargs_args, root=iutil.getSysroot()) + + def writeStorageEarly(self): + pass
On Thu, Jun 25, 2015 at 10:40:24AM -0400, Chris Lumens wrote:
We're trying to reduce install.py to a simpler, more straightfoward format where it's just a list of things that need to be done. We can get rid of some of the conditional checking by moving this code into payloads and having those payloads just provide blank overridden methods.
pyanaconda/install.py | 30 ++---------------------- pyanaconda/packaging/__init__.py | 40 ++++++++++++++++++++++++++++++++ pyanaconda/packaging/livepayload.py | 3 +++ pyanaconda/packaging/rpmostreepayload.py | 3 +++ 4 files changed, 48 insertions(+), 28 deletions(-)
Ack!
anaconda-patches@lists.fedorahosted.org