diff options
author | Erik Troan <ewt@redhat.com> | 2001-06-21 23:16:16 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2001-06-21 23:16:16 +0000 |
commit | f538a06abc4c32b01c8633afd51ee709c3deefcd (patch) | |
tree | 58dc8182d5143266f5a88148e906f34cf3e52fa8 | |
parent | 7b2529cb17fd1f82e4fbe02af7ccc38553ec97e8 (diff) | |
download | anaconda-f538a06abc4c32b01c8633afd51ee709c3deefcd.tar.gz anaconda-f538a06abc4c32b01c8633afd51ee709c3deefcd.tar.xz anaconda-f538a06abc4c32b01c8633afd51ee709c3deefcd.zip |
get floppy code working again
-rwxr-xr-x | anaconda | 5 | ||||
-rw-r--r-- | dispatch.py | 5 | ||||
-rw-r--r-- | exception.py | 2 | ||||
-rw-r--r-- | floppy.py | 100 | ||||
-rw-r--r-- | instdata.py | 3 | ||||
-rw-r--r-- | iutil.py | 99 |
6 files changed, 110 insertions, 104 deletions
@@ -218,6 +218,7 @@ import instdata import videocard import monitor import mouse +import floppy # handle traceonly and exit if traceOnly: @@ -483,7 +484,9 @@ if method: print "unknown install method:", method sys.exit(1) -id = instClass.installDataClass(extraModules) +floppyDevice = floppy.probeFloppyDevice() + +id = instClass.installDataClass(extraModules, floppyDevice) if mousehw: id.setMouse(mousehw) diff --git a/dispatch.py b/dispatch.py index 25341e91f..bdcb64c7b 100644 --- a/dispatch.py +++ b/dispatch.py @@ -19,7 +19,7 @@ from packages import readPackages, checkDependencies, doInstall from packages import handleX11Packages, writeConfiguration, writeXConfiguration from packages import writeKSConfiguration, turnOnFilesystems from packages import queryUpgradeContinue -from iutil import makeBootdisk +from floppy import makeBootdisk from bootloader import partitioningComplete, writeBootloader from flags import flags @@ -84,7 +84,8 @@ installSteps = [ ( "writexconfig", writeXConfiguration, ("id", "instPath")), ( "writeksconfig", writeKSConfiguration, ("id", "instPath")), ( "bootdisk", ("dir", "dispatch") ), - ( "makebootdisk", makeBootdisk, ("intf",) ), + ( "makebootdisk", makeBootdisk, ("intf", "id.floppyDevice", + "id.hdList", "instPath") ), ( "complete", () ), ( "reconfigcomplete", () ) ] diff --git a/exception.py b/exception.py index 1594b11cb..9f0bcbd29 100644 --- a/exception.py +++ b/exception.py @@ -27,7 +27,7 @@ def handleException( id, intf, (type, value, tb)): intf.__del__ () os.kill(os.getpid(), signal.SIGKILL) - device = iutil.getFloppyDevice() + device = id.floppyDevice file = "/tmp/floppy" try: isys.makeDevInode(device, file) diff --git a/floppy.py b/floppy.py new file mode 100644 index 000000000..c8be0b096 --- /dev/null +++ b/floppy.py @@ -0,0 +1,100 @@ +import isys +import errno +import iutil +from log import log +import re +import os +from flags import flags + +def probeFloppyDevice(): + fdDevice = "fd0" + if iutil.getArch() == "sparc": + try: + f = open(fdDevice, "r") + except IOError, (errnum, msg): + if errno.errorcode[errnum] == 'ENXIO': + fdDevice = "fd1" + else: + f.close() + elif iutil.getArch() == "alpha": + pass + elif iutil.getArch() == "i386" or iutil.getArch() == "ia64": + # Look for the first IDE floppy device + drives = isys.floppyDriveDict() + if not drives: + log("no IDE floppy devices found") + return fdDevice + + floppyDrive = drives.keys()[0] + # need to go through and find if there is an LS-120 + for dev in drives.keys(): + if re.compile(".*[Ll][Ss]-120.*").search(drives[dev]): + floppyDrive = dev + + # No IDE floppy's -- we're fine w/ /dev/fd0 + if not floppyDrive: return fdDevice + + if iutil.getArch() == "ia64": + fdDevice = floppyDrive + log("anaconda floppy device is %s", fdDevice) + return fdDevice + + # Look in syslog for a real fd0 (which would take precedence) + try: + f = open("/tmp/syslog", "r") + except IOError: + try: + f = open("/var/log/dmesg", "r") + except IOError: + return fdDevice + + for line in f.readlines(): + # chop off the loglevel (which init's syslog leaves behind) + line = line[3:] + match = "Floppy drive(s): " + if match == line[:len(match)]: + # Good enough + floppyDrive = "fd0" + break + + fdDevice = floppyDrive + else: + raise SystemError, "cannot determine floppy device for this arch" + + log("anaconda floppy device is %s", fdDevice) + + return fdDevice + +def makeBootdisk (intf, floppyDevice, hdList, instPath): + if flags.test: + return dispatch.DISPATCH_NOOP + + # this is faster then waiting on mkbootdisk to fail + device = floppyDevice + file = "/tmp/floppy" + isys.makeDevInode(device, file) + try: + fd = os.open(file, os.O_RDONLY) + except: + return dispatch.DISPATCH_BACK + os.close(fd) + + kernel = hdList['kernel'] + kernelTag = "-%s-%s" % (kernel[rpm.RPMTAG_VERSION], + kernel[rpm.RPMTAG_RELEASE]) + + w = intf.waitWindow (_("Creating"), _("Creating boot disk...")) + rc = iutil.execWithRedirect("/sbin/mkbootdisk", + [ "/sbin/mkbootdisk", + "--noprompt", + "--device", + "/dev/" + floppyDevice, + kernelTag[1:] ], + stdout = '/dev/tty5', stderr = '/dev/tty5', + searchPath = 1, root = instPath) + w.pop() + + if rc: + import dispatch + return dispatch.DISPATCH_BACK + diff --git a/instdata.py b/instdata.py index fa19390c0..c8c092f94 100644 --- a/instdata.py +++ b/instdata.py @@ -129,7 +129,7 @@ class InstallData: # - def __init__(self, extraModules): + def __init__(self, extraModules, floppyDevice): self.instLanguage = language.InstallTimeLanguage() self.keyboard = kbd.Keyboard() @@ -138,6 +138,7 @@ class InstallData: self.videocard = None self.xconfig = None self.extraModules = extraModules + self.floppyDevice = floppyDevice self.fsset = fsset.FileSystemSet() self.reset() @@ -3,73 +3,12 @@ import os.path from log import log memoryOverhead = 0 -floppyDevice = None def setMemoryOverhead(amount): global memoryOverhead memoryOverhead = amount -def SetFdDevice(): - global floppyDevice - - if floppyDevice: - return floppydevice - - floppyDevice = "fd0" - if iutil.getArch() == "sparc": - try: - f = open(floppyDevice, "r") - except IOError, (errnum, msg): - if errno.errorcode[errnum] == 'ENXIO': - floppyDevice = "fd1" - else: - f.close() - elif iutil.getArch() == "alpha": - pass - elif iutil.getArch() == "i386" or iutil.getArch() == "ia64": - # Look for the first IDE floppy device - drives = isys.floppyDriveDict() - if not drives: - log("no IDE floppy devices found") - return 0 - - floppyDrive = drives.keys()[0] - # need to go through and find if there is an LS-120 - for dev in drives.keys(): - if re.compile(".*[Ll][Ss]-120.*").search(drives[dev]): - floppyDrive = dev - - # No IDE floppy's -- we're fine w/ /dev/fd0 - if not floppyDrive: return - - if iutil.getArch() == "ia64": - floppyDevice = floppyDrive - log("anaconda floppy device is %s", floppyDevice) - return - - # Look in syslog for a real fd0 (which would take precedence) - try: - f = open("/tmp/syslog", "r") - except IOError: - return - for line in f.readlines(): - # chop off the loglevel (which init's syslog leaves behind) - line = line[3:] - match = "Floppy drive(s): " - if match == line[:len(match)]: - # Good enough - floppyDrive = "fd0" - break - - floppyDevice = floppyDrive - else: - raise SystemError, "cannot determine floppy device for this arch" - - log("anaconda floppy device is %s", floppyDevice) - - return floppyDevice - def getArch (): arch = os.uname ()[4] if (len (arch) == 4 and arch[0] == 'i' and @@ -443,41 +382,3 @@ class InstSyslog: os.kill (self.pid, 15) os.wait (self.pid) -# XXX this doesn't work! -# -# funky, but importing dispatch at the top of iutil breaks things!?! -def makeBootdisk (intf): - # this is faster then waiting on mkbootdisk to fail - - import dispatch - return dispatch.DISPATCH_NOOP - - device = floppyDevice - file = "/tmp/floppy" - isys.makeDevInode(device, file) - try: - fd = os.open(file, os.O_RDONLY) - except: - import dispatch - return dispatch.DISPATCH_BACK - os.close(fd) - - kernel = self.hdList['kernel'] - kernelTag = "-%s-%s" % (kernel[rpm.RPMTAG_VERSION], - kernel[rpm.RPMTAG_RELEASE]) - - w = self.intf.waitWindow (_("Creating"), _("Creating boot disk...")) - rc = iutil.execWithRedirect("/sbin/mkbootdisk", - [ "/sbin/mkbootdisk", - "--noprompt", - "--device", - "/dev/" + floppyDevice, - kernelTag[1:] ], - stdout = '/dev/tty5', stderr = '/dev/tty5', - searchPath = 1, root = self.instPath) - w.pop() - - if rc: - import dispatch - return dispatch.DISPATCH_BACK - |