diff options
-rwxr-xr-x | anaconda | 2 | ||||
-rw-r--r-- | backend.py | 7 | ||||
-rw-r--r-- | installclass.py | 3 | ||||
-rw-r--r-- | livecd.py | 72 | ||||
-rw-r--r-- | packages.py | 2 | ||||
-rw-r--r-- | yuminstall.py | 4 |
6 files changed, 45 insertions, 45 deletions
@@ -508,7 +508,7 @@ class Anaconda: def setBackend(self, instClass): b = instClass.getBackend() - self.backend = apply(b, (self.rootPath,)) + self.backend = apply(b, (self,)) def setMethodstr(self, methodstr): # Save the method string we are given from the loader for printing out diff --git a/backend.py b/backend.py index 7632f0de6..a1e11c072 100644 --- a/backend.py +++ b/backend.py @@ -31,11 +31,11 @@ log = logging.getLogger("anaconda") class AnacondaBackend: - def __init__(self, instPath): + def __init__(self, anaconda): """Abstract backend class all backends should inherit from this @param instPath: root path for the installation to occur""" - self.instPath = instPath + self.instPath = anaconda.rootPath self.instLog = None self.modeText = "" @@ -47,6 +47,9 @@ class AnacondaBackend: # FIXME: we should handle this a little more elegantly self.skipFormatRoot = False + def postAction(self, anaconda): + pass + def doPreSelection(self, intf, id, instPath): pass diff --git a/installclass.py b/installclass.py index 7efd6b9b9..bfc39c4ea 100644 --- a/installclass.py +++ b/installclass.py @@ -81,6 +81,9 @@ class BaseInstallClass(object): return _(self._description) % self._descriptionFields description = property(_get_description) + def postAction(self, anaconda): + anaconda.backend.postAction(anaconda) + def setBootloader(self, id, location=None, forceLBA=0, password=None, md5pass=None, appendLine="", driveorder = [], timeout=None): @@ -31,7 +31,6 @@ from flags import flags from constants import * import backend -import installmethod import isys import iutil @@ -87,14 +86,17 @@ def copytree(src, dst, symlinks=False, preserveOwner=False, if errors: raise Error, errors -class LiveCDImageMethod(installmethod.InstallMethod): - def __init__(self, method, rootpath, intf): - """@param method livecd://live-block-device""" - installmethod.InstallMethod.__init__(self, method, rootpath, intf) +class LiveCDCopyBackend(backend.AnacondaBackend): + def __init__(self, anaconda): + backend.AnacondaBackend.__init__(self, anaconda) + flags.livecdInstall = True + self.supportsUpgrades = False + self.supportsPackageSelection = False + self.skipFormatRoot = True - self.osimg = method[8:] + self.osimg = anaconda.methodstr[8:] if not stat.S_ISBLK(os.stat(self.osimg)[stat.ST_MODE]): - intf.messageWindow(_("Unable to find image"), + anaconda.intf.messageWindow(_("Unable to find image"), _("The given location isn't a valid %s " "live CD to use as an installation source.") %(productName,), type = "custom", @@ -102,7 +104,25 @@ class LiveCDImageMethod(installmethod.InstallMethod): custom_buttons=[_("Exit installer")]) sys.exit(0) - def unmountNonFstabDirs(self, anaconda): + def _getLiveBlockDevice(self): + return self.osimg + + def _getLiveSizeMB(self): + def parseField(output, field): + for line in output.split("\n"): + if line.startswith(field + ":"): + return line[len(field) + 1:].strip() + raise KeyError("Failed to find field '%s' in output" % field) + + output = subprocess.Popen(['/sbin/dumpe2fs', '-h', self.osimg], + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w') + ).communicate()[0] + blkcnt = int(parseField(output, "Block count")) + blksize = int(parseField(output, "Block size")) + return blkcnt * blksize / 1024 / 1024 + + def _unmountNonFstabDirs(self, anaconda): # unmount things that aren't listed in /etc/fstab. *sigh* dirs = ["/dev"] if flags.selinux: @@ -114,7 +134,7 @@ class LiveCDImageMethod(installmethod.InstallMethod): log.error("unable to unmount %s: %s" %(dir, e)) def postAction(self, anaconda): - self.unmountNonFstabDirs(anaconda) + self._unmountNonFstabDirs(anaconda) try: anaconda.id.fsset.umountFilesystems(anaconda.rootPath, swapoff = False) @@ -122,35 +142,9 @@ class LiveCDImageMethod(installmethod.InstallMethod): except Exception, e: log.error("Unable to unmount filesystems.") - def getLiveBlockDevice(self): - return self.osimg - - def getLiveSizeMB(self): - def parseField(output, field): - for line in output.split("\n"): - if line.startswith(field + ":"): - return line[len(field) + 1:].strip() - raise KeyError("Failed to find field '%s' in output" % field) - - output = subprocess.Popen(['/sbin/dumpe2fs', '-h', self.osimg], - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w') - ).communicate()[0] - blkcnt = int(parseField(output, "Block count")) - blksize = int(parseField(output, "Block size")) - return blkcnt * blksize / 1024 / 1024 - -class LiveCDCopyBackend(backend.AnacondaBackend): - def __init__(self, instPath): - backend.AnacondaBackend.__init__(self, instPath) - flags.livecdInstall = True - self.supportsUpgrades = False - self.supportsPackageSelection = False - self.skipFormatRoot = True - def doPreInstall(self, anaconda): if anaconda.dir == DISPATCH_BACK: - anaconda.method.unmountNonFstabDirs(anaconda) + self._unmountNonFstabDirs(anaconda) return anaconda.id.fsset.umountFilesystems(anaconda.rootPath, swapoff = False) @@ -165,7 +159,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): progress.set_label(_("Copying live image to hard drive.")) progress.processEvents() - osimg = anaconda.method.getLiveBlockDevice() # the real image + osimg = self._getLiveBlockDevice() # the real image osfd = os.open(osimg, os.O_RDONLY) r = anaconda.id.fsset.getEntryByMountPoint("/") @@ -173,7 +167,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): rootfd = os.open("/dev/" + rootfs, os.O_WRONLY) readamt = 1024 * 1024 * 8 # 8 megs at a time - size = float(anaconda.method.getLiveSizeMB() * 1024 * 1024) + size = float(self._getLiveSizeMB() * 1024 * 1024) copied = 0 while copied < size: buf = os.read(osfd, readamt) @@ -349,7 +343,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): # ensure there's enough space on the rootfs # FIXME: really, this should be in the general sanity checking, but # trying to weave that in is a little tricky at present. - ossize = anaconda.method.getLiveSizeMB() + ossize = self._getLiveSizeMB() slash = anaconda.id.partitions.getRequestByMountPoint("/") if slash and \ slash.getActualSize(anaconda.id.partitions, anaconda.id.diskset) < ossize: diff --git a/packages.py b/packages.py index 42dc12bd6..5dbec255b 100644 --- a/packages.py +++ b/packages.py @@ -40,7 +40,7 @@ import logging log = logging.getLogger("anaconda") def doPostAction(anaconda): - anaconda.id.instClass.postAction(anaconda, flags.serial) + anaconda.id.instClass.postAction(anaconda) def firstbootConfiguration(anaconda): if anaconda.id.firstboot == FIRSTBOOT_RECONFIG: diff --git a/yuminstall.py b/yuminstall.py index 9f8b53859..8e4672e88 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -711,8 +711,8 @@ class AnacondaYum(YumSorter): return False class YumBackend(AnacondaBackend): - def __init__ (self, instPath): - AnacondaBackend.__init__(self, instPath) + def __init__ (self, anaconda): + AnacondaBackend.__init__(self, anaconda) self.supportsPackageSelection = True def doInitialSetup(self, anaconda): |