summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2007-12-04 19:41:01 -0500
committerChris Lumens <clumens@redhat.com>2007-12-05 10:30:45 -0500
commit52a9331a20f82fd6f3aef18492fd2af61f830bdf (patch)
tree9e577d962cc2f01656e681c8705080bbfad0759c
parentf6e2614efd36df057897cafe3e49bc0957f60376 (diff)
downloadanaconda-52a9331a20f82fd6f3aef18492fd2af61f830bdf.tar.gz
anaconda-52a9331a20f82fd6f3aef18492fd2af61f830bdf.tar.xz
anaconda-52a9331a20f82fd6f3aef18492fd2af61f830bdf.zip
Remove base InstallMethod class and harddrive.py and urlinstall.py files.
This commit removes the base InstallMethod class without removing the users in other files, so obviously this commit cannot stand alone. installmethod.py and image.py at the very least still need significant changes.
-rw-r--r--harddrive.py153
-rw-r--r--installclass.py3
-rw-r--r--installmethod.py83
-rw-r--r--urlinstall.py133
4 files changed, 18 insertions, 354 deletions
diff --git a/harddrive.py b/harddrive.py
deleted file mode 100644
index 1a0921d3d..000000000
--- a/harddrive.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#
-# harddrive.py - Install method for hard drive installs
-#
-# Copyright 1999-2007 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# General Public License.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-from image import findIsoImages, ImageInstallMethod
-import shutil
-import os
-import sys
-import isys
-import string
-from rhpl.translate import _, cat, N_
-from constants import *
-
-import logging
-log = logging.getLogger("anaconda")
-
-# Install from one or more iso images
-class HardDriveInstallMethod(ImageInstallMethod):
- def getMethodUri(self):
- return "file://%s" % self.tree
-
- # mounts disc image cdNum under self.tree
- def mountMedia(self, cdNum):
- if self.mediaIsMounted:
- raise SystemError, "trying to mount already-mounted iso image!"
-
- self.mountDirectory()
-
- retry = True
- while retry:
- try:
- isoImage = self.isoDir + '/' + self.path + '/' + self.discImages[cdNum]
-
- isys.losetup("/dev/loop3", isoImage, readOnly = 1)
-
- isys.mount("/dev/loop3", self.tree, fstype = 'iso9660', readOnly = 1);
- self.mediaIsMounted = cdNum
-
- retry = False
- except:
- ans = self.messageWindow( _("Missing ISO 9660 Image"),
- _("The installer has tried to mount "
- "image #%s, but cannot find it on "
- "the hard drive.\n\n"
- "Please copy this image to the "
- "drive and click Retry. Click Exit "
- " to abort the installation.")
- % (cdNum,), type="custom",
- custom_icon="warning",
- custom_buttons=[_("_Exit"),
- _("_Retry")])
- if ans == 0:
- sys.exit(0)
- elif ans == 1:
- self.discImages = findIsoImages(self.isoPath, self.messageWindow)
-
- def umountMedia(self):
- if self.mediaIsMounted:
- isys.umount(self.tree)
- isys.unlosetup("/dev/loop3")
- self.umountDirectory()
- self.mediaIsMounted = 0
-
- # This mounts the directory containing the iso images, and places the
- # mount point in self.isoDir. It's only used directly by __init__;
- # everything else goes through switchMedia
- def mountDirectory(self):
- if (self.isoDirIsMounted):
- raise SystemError, "trying to mount already-mounted image!"
-
- f = open("/proc/mounts", "r")
- l = f.readlines()
- f.close()
-
- for line in l:
- s = string.split(line)
- if s[0] == "/dev/" + self.device:
- self.isoDir = s[1] + "/"
- return
-
- try:
- isys.mount(self.device, "/tmp/isodir", fstype = self.fstype)
- except SystemError, msg:
- log.error("couldn't mount ISO source directory: %s" % msg)
- self.messageWindow(_("Couldn't Mount ISO Source"),
- _("An error occurred mounting the source "
- "device %s. This may happen if your ISO "
- "images are located on an advanced storage "
- "device like LVM or RAID, or if there was a "
- "problem mounting a partition. Click exit "
- "to abort the installation.")
- % (self.device,), type="custom",
- custom_icon="error",
- custom_buttons=[_("_Exit")])
- sys.exit(0)
-
-
- self.isoDir = "/tmp/isodir/"
- self.isoDirIsMounted = 1
-
- def umountDirectory(self):
- if self.isoDirIsMounted:
- isys.umount(self.isoDir)
- self.isoDirIsMounted = 0
-
- def switchMedia(self, mediano, filename=""):
- if mediano != self.mediaIsMounted:
- log.info("switching from iso %s to %s for %s" % (self.mediaIsMounted, mediano, filename))
- self.umountMedia()
- self.mountMedia(mediano)
-
- def systemMounted(self, fsset, mntPoint):
- self.switchMedia(1)
-
- def filesDone(self):
- # we're trying to unmount the source image at the end. if it
- # fails, we'll reboot soon enough anyway
- try:
- self.umountMedia()
- except:
- log.warning("unable to unmount media")
-
- def __init__(self, method, rootPath, intf):
- """@param method hd://device:fstype:/path"""
- method = method[5:]
- (device, fstype, path) = method.split(":", 3)
- device = method[0:method.index(":")]
-
- ImageInstallMethod.__init__(self, method, rootPath, intf)
-
- self.device = device
- self.path = path
- self.fstype = fstype
- self.isoDirIsMounted = 0
- self.mediaIsMounted = 0
- self.messageWindow = intf.messageWindow
- self.currentMedia = []
- self.tree = "/tmp/isomedia/"
-
- # Mount the partition containing the ISO images just long enough for
- # us to build up a list of all the path names.
- self.mountDirectory()
- self.discImages = findIsoImages(self.isoDir + '/' + self.path, self.messageWindow)
- self.umountDirectory()
diff --git a/installclass.py b/installclass.py
index ffca2a451..d6a8806fa 100644
--- a/installclass.py
+++ b/installclass.py
@@ -81,9 +81,6 @@ class BaseInstallClass(object):
return _(self._description) % self._descriptionFields
description = property(_get_description)
- def postAction(self, anaconda, serial):
- anaconda.method.postAction(anaconda)
-
def setBootloader(self, id, location=None, forceLBA=0, password=None,
md5pass=None, appendLine="", driveorder = [],
timeout=None):
diff --git a/installmethod.py b/installmethod.py
index 368b018c0..9eb7d32e1 100644
--- a/installmethod.py
+++ b/installmethod.py
@@ -11,79 +11,32 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-import os
-import string
+import os, shutil, string
from constants import *
import logging
log = logging.getLogger("anaconda")
-import isys
+import isys, product
-## The base installation method class.
-# This is an abstract class that defines the methods that make up an
-# installation method. This class should not be used except as the superclass
-# for a specific method. Most methods in this class should be redefined by
-# subclasses, though things like mountCD, unmountCD, ejectCD, and the cleanup
-# methods may not need to be redefined. By default, most methods pass.
-class InstallMethod:
- ## Perform method-specific actions to mount any installation media.
- # @param fsset An instance of FileSystemSet.
- # @param mntPoint The root of the filesystem to mount the media onto.
- def systemMounted(self, fsset, mntPoint):
- pass
-
- ## Method-specific cleanup function to be called at the end of installation.
- # @see doMethodComplete
- # @see postAction
- def filesDone(self):
- pass
-
- ## The constructor.
- # @param method The --method= parameter passed to anaconda from loader.
- # @param rootpath The --rootpath= parameter passed to anaconda from loader.
- # @param intf An instance of the InstallInterface class.
- def __init__(self, method, rootpath, intf):
- self.rootPath = rootpath
- self.intf = intf
- self.tree = None
-
- ## Get the base URI for the method.
- # @return The base URI for this installation method.
- def getMethodUri(self):
- pass
-
- ## Unmount any CD media.
- def unmountCD(self):
- pass
-
- ## Switch CDs.
- # @param mediano The CD media number to switch to.
- # @param filename The file to be read that requires switching media.
- def switchMedia(self, mediano, filename=""):
- pass
-
- ## Method to be run at the very end of installation.
- #
- # This method is run very late. It's the last step to be run before
- # showing the completion screen. Only use this if you really know what
- # you're doing.
- # @param anaconda An instance of the Anaconda class.
- # @see filesDone
- # @see doMethodComplete
- def postAction(self, anaconda):
+def doMethodComplete(anaconda):
+ try:
+ isys.umount(anaconda.backend.ayum.tree)
+ except Exception:
pass
-## Do method-specific cleanups.
-#
-# This occurs very late and is mainly used for unmounting media and ejecting
-# the CD. If we're on a kickstart install, don't eject the CD since there's
-# a kickstart command to do that.
-# @param anaconda An instance of the Anaconda class.
-# @see InstallMethod::postAction
-# @see InstallMethod::filesDone
-def doMethodComplete(anaconda):
- anaconda.method.filesDone()
+ if anaconda.methodstr.startswith("cdrom://"):
+ try:
+ shutil.copyfile("%s/media.repo" % anaconda.backend.ayum.tree,
+ "%s/etc/yum.repos.d/%s-install-media.repo" %(anaconda.rootPath, productName))
+ except Exception, e:
+ log.debug("Error copying media.repo: %s" %(e,))
+
+ if anaconda.backend.ayum._loopbackFile:
+ try:
+ os.unlink(anaconda.backend.ayum._loopbackFile)
+ except SystemError:
+ pass
if not anaconda.isKickstart:
isys.ejectCdrom(anaconda.method.device, makeDevice=1)
diff --git a/urlinstall.py b/urlinstall.py
deleted file mode 100644
index e4bc2a261..000000000
--- a/urlinstall.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#
-# urlinstall.py - URL based install source method
-#
-# Erik Troan <ewt@redhat.com>
-#
-# Copyright 1999-2007 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-from installmethod import InstallMethod
-import os
-import time
-import shutil
-import string
-import socket
-import urlparse
-import urlgrabber.grabber as grabber
-import isys
-
-from snack import *
-from constants import *
-
-from rhpl.translate import _
-
-import logging
-log = logging.getLogger("anaconda")
-
-class UrlInstallMethod(InstallMethod):
-
- def systemMounted(self, fsset, chroot):
- if self.tree is None:
- return
- if not os.path.exists("%s/images/stage2.img" %(self.tree,)):
- log.debug("Not copying stage2.img as we can't find it")
- return
-
- self.loopbackFile = "%s%s%s" % (chroot,
- fsset.filesystemSpace(chroot)[0][0],
- "/rhinstall-stage2.img")
-
- try:
- win = self.waitWindow (_("Copying File"),
- _("Transferring install image to hard drive..."))
- shutil.copyfile("%s/images/stage2.img" % (self.tree,),
- self.loopbackFile)
- win.pop()
- except Exception, e:
- if win:
- win.pop()
-
- log.critical("error transferring stage2.img: %s" %(e,))
- self.messageWindow(_("Error"),
- _("An error occurred transferring the install image "
- "to your hard drive. You are probably out of disk "
- "space."))
- os.unlink(self.loopbackFile)
- return 1
-
- isys.lochangefd("/dev/loop0", self.loopbackFile)
-
- def getMethodUri(self):
- return self.baseUrl
-
- def unmountCD(self):
- if not self.tree:
- return
-
- done = 0
- while done == 0:
- try:
- isys.umount("/mnt/source")
- break
- except Exception, e:
- log.error("exception in unmountCD: %s" %(e,))
- self.messageWindow(_("Error"),
- _("An error occurred unmounting the disc. "
- "Please make sure you're not accessing "
- "%s from the shell on tty2 "
- "and then click OK to retry.")
- % ("/mnt/source",))
-
- def filesDone(self):
- # we're trying to unmount the CD here. if it fails, oh well,
- # they'll reboot soon enough I guess :)
- try:
- isys.umount("/mnt/source")
- except Exception:
- pass
-
- if not self.loopbackFile: return
-
- try:
- # this isn't the exact right place, but it's close enough
- os.unlink(self.loopbackFile)
- except SystemError:
- pass
-
- def __init__(self, url, rootPath, intf):
- InstallMethod.__init__(self, url, rootPath, intf)
-
- (scheme, netloc, path, query, fragid) = urlparse.urlsplit(url)
-
- try:
- socket.inet_pton(socket.AF_INET6, netloc)
- netloc = '[' + netloc + ']'
- except:
- pass
-
- # encoding fun so that we can handle absolute paths
- if scheme == "ftp" and path and path.startswith("//"):
- path = "/%2F" + path[1:]
-
- self.baseUrl = urlparse.urlunsplit((scheme,netloc,path,query,fragid))
- self.pkgUrl = self.baseUrl
-
- self.currentMedia = []
-
- self.messageWindow = intf.messageWindow
- self.progressWindow = intf.progressWindow
- self.waitWindow = intf.waitWindow
- self.loopbackFile = None
- self.tree = "/mnt/source"
- for path in ("/tmp/ramfs/stage2.img", "/tmp/ramfs/minstg2.img"):
- if os.access(path, os.R_OK):
- # we used a remote stage2. no need to worry about ejecting CDs
- self.tree = None
- break