FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Studio User

 
 
LinkBack Thread Tools
 
Old 12-05-2007, 02:49 AM
Chris Lumens
 
Default 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.
---
harddrive.py | 153 ------------------------------------------------------
installclass.py | 3 -
installmethod.py | 83 ++++++-----------------------
urlinstall.py | 133 -----------------------------------------------
4 files changed, 18 insertions(+), 354 deletions(-)
delete mode 100644 harddrive.py
delete mode 100644 urlinstall.py

diff --git a/harddrive.py b/harddrive.py
deleted file mode 100644
index 1a0921d..0000000
--- 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.

"
- "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 ffca2a4..d6a8806 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 368b018..9eb7d32 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:ostAction
-# @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 e4bc2a2..0000000
--- 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,frag id))
- 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
--
1.5.3.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 07:10 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org