From fafcceb8103dfcf74f0f50279e88ae7e05e3b01e Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Wed, 27 Aug 2008 14:31:38 -0400 Subject: Don't copy the install.img over in single media cases (#216167). The only reason we copy the install.img over to the hard drive is because we need to free up the CD/DVD device for switching media. If we don't need to do that, then there's no reason to do the copy. --- backend.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ yuminstall.py | 68 +++++++---------------------------------------------------- 2 files changed, 64 insertions(+), 60 deletions(-) diff --git a/backend.py b/backend.py index 14848b5c5..e515bba00 100644 --- a/backend.py +++ b/backend.py @@ -54,6 +54,8 @@ class AnacondaBackend: # FIXME: we should handle this a little more elegantly self.skipFormatRoot = False + self._loopbackFile = None + def postAction(self, anaconda): pass @@ -128,6 +130,60 @@ class AnacondaBackend: else: self.modeText = _("Installing %s\n") + def mountInstallImage(self, anaconda, installimg): + if not flags.setupFilesystems: + return + + if self._loopbackFile and os.path.exists(self._loopbackFile): + return + + # If we've booted off the first CD/DVD (so, not the boot.iso) then + # copy the install.img to the filesystem and switch loopback devices + # to there. Otherwise we won't be able to unmount and swap media. + if not self.anaconda.mediaDevice or not os.path.exists(installimg): + return + + self._loopbackFile = "%s%s/rhinstall-install.img" % (self.anaconda.rootPath, + anaconda.id.fsset.filesystemSpace(self.anaconda.rootPath)[0][0]) + + try: + win = self.anaconda.intf.waitWindow(_("Copying File"), + _("Transferring install image to hard drive...")) + shutil.copyfile(installimg, self._loopbackFile) + win.pop() + except Exception, e: + if win: + win.pop() + + log.critical("error transferring install.img: %s" %(e,)) + + if isinstance(e, IOError) and e.errno == 5: + msg = _("An error occurred transferring the install image " + "to your hard drive. This is probably due to " + "bad media.") + else: + msg = _("An error occurred transferring the install image " + "to your hard drive. You are probably out of disk " + "space.") + + self.anaconda.intf.messageWindow(_("Error"), msg) + try: + os.unlink(self._loopbackFile) + except: + pass + + return 1 + + isys.lochangefd("/dev/loop0", self._loopbackFile) + isys.umount("/mnt/stage2") + + def removeInstallImage(self): + if self._loopbackFile: + try: + os.unlink(self._loopbackFile) + except SystemError: + pass + def kernelVersionList(self, rootPath="/"): return [] diff --git a/yuminstall.py b/yuminstall.py index 7446318ff..354dc9c63 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -278,7 +278,6 @@ class AnacondaYum(YumSorter): def __init__(self, anaconda): YumSorter.__init__(self) self.anaconda = anaconda - self._loopbackFile = None self._timestamp = None # Only needed for hard drive and nfsiso installs. @@ -328,54 +327,6 @@ class AnacondaYum(YumSorter): self.updates = [] self.localPackages = [] - def systemMounted(self, fsset, chroot): - if not flags.setupFilesystems: - return - - if self._loopbackFile and os.path.exists(self._loopbackFile): - return - - # If we've booted off the first CD/DVD (so, not the boot.iso) then - # copy the install.img to the filesystem and switch loopback devices - # to there. Otherwise we won't be able to unmount and swap media. - stage2img = "%s/images/install.img" % self.tree - if not self.anaconda.mediaDevice or not os.path.exists(stage2img): - return - - self._loopbackFile = "%s%s/rhinstall-install.img" % (chroot, - fsset.filesystemSpace(chroot)[0][0]) - - try: - win = self.anaconda.intf.waitWindow(_("Copying File"), - _("Transferring install image to hard drive...")) - shutil.copyfile(stage2img, self._loopbackFile) - win.pop() - except Exception, e: - if win: - win.pop() - - log.critical("error transferring install.img: %s" %(e,)) - - if isinstance(e, IOError) and e.errno == 5: - msg = _("An error occurred transferring the install image " - "to your hard drive. This is probably due to " - "bad media.") - else: - msg = _("An error occurred transferring the install image " - "to your hard drive. You are probably out of disk " - "space.") - - self.anaconda.intf.messageWindow(_("Error"), msg) - try: - os.unlink(self._loopbackFile) - except: - pass - - return 1 - - isys.lochangefd("/dev/loop0", self._loopbackFile) - isys.umount("/mnt/stage2") - def _switchCD(self, discnum): if os.access("%s/.discinfo" % self.tree, os.R_OK): f = open("%s/.discinfo" % self.tree) @@ -795,6 +746,13 @@ class AnacondaYum(YumSorter): self.tsInfo.reqmedia[0] = None mkeys = self.tsInfo.reqmedia.keys() mkeys.sort(mediasort) + + if len(mkeys) > 1: + stage2img = "%s/images/install.img" % self.tree + if self.anaconda.backend.mountInstallImage(self.anaconda, stage2img) + self.anaconda.id.fsset.unmountFilesystems(self.anaconda.rootPath) + return DISPATCH_BACK + for i in mkeys: self.tsInfo.curmedia = i if i > 0: @@ -1002,11 +960,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon except Exception, e: log.debug("Error setting up media repository: %s" %(e,)) - if self.ayum._loopbackFile: - try: - os.unlink(self.ayum._loopbackFile) - except SystemError: - pass + anaconda.backend.removeInstallImage() def doInitialSetup(self, anaconda): if anaconda.dir == DISPATCH_BACK: @@ -1019,12 +973,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon iutil.writeRpmPlatform() self.ayum = AnacondaYum(anaconda) - if self.ayum.systemMounted (anaconda.id.fsset, anaconda.rootPath): - anaconda.id.fsset.umountFilesystems(anaconda.rootPath) - return DISPATCH_BACK - else: - return DISPATCH_FORWARD - def doGroupSetup(self): # FIXME: this is a pretty ugly hack to make it so that we don't lose # groups being selected (#237708) -- cgit