summaryrefslogtreecommitdiffstats
path: root/livecd.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2007-12-05 11:22:56 -0500
committerChris Lumens <clumens@redhat.com>2007-12-05 11:22:56 -0500
commit62422eb0857472f90bde2b3b1b0e1dd5dfda4d97 (patch)
treec8cf59ec3ac4b411be91b4aa5e3ef6c1cf1dc155 /livecd.py
parent7c6cc6cbaf10ca6ecbd7a1a9980383491b2ea2bf (diff)
downloadanaconda-62422eb0857472f90bde2b3b1b0e1dd5dfda4d97.tar.gz
anaconda-62422eb0857472f90bde2b3b1b0e1dd5dfda4d97.tar.xz
anaconda-62422eb0857472f90bde2b3b1b0e1dd5dfda4d97.zip
Fix up the livecd to no longer use an InstallMethod.
Diffstat (limited to 'livecd.py')
-rw-r--r--livecd.py72
1 files changed, 33 insertions, 39 deletions
diff --git a/livecd.py b/livecd.py
index 0e41e6086..368e6af3a 100644
--- a/livecd.py
+++ b/livecd.py
@@ -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: