diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rwxr-xr-x | anaconda | 10 | ||||
-rw-r--r-- | partedUtils.py | 35 | ||||
-rw-r--r-- | rescue.py | 52 | ||||
-rw-r--r-- | upgrade.py | 12 |
5 files changed, 70 insertions, 51 deletions
@@ -1,3 +1,15 @@ +2006-05-17 Chris Lumens <clumens@redhat.com> + + * anaconda: Fix runRescue to use anaconda class. + * rescue.py: Likewise. + + * upgrade.py (findExistingRoots): Fix code path to use anaconda + class. + + * partedUtils.py (DiskSet.findExistingRootPartitions): Don't try to + mount protected partitions when looking for an installed system on + upgrade. + 2006-05-17 David Cantrell <dcantrell@redhat.com> * installclass.py: Removed steps that don't exist anymore. @@ -547,6 +547,7 @@ class Anaconda: self.rootPath = None self.dispatch = None self.isKickstart = False + self.rescue_mount = True def setDispatch(self): self.dispatch = dispatch.Dispatcher(self) @@ -647,6 +648,10 @@ if __name__ == "__main__": setupLoggingFromOpts(opts) + anaconda.rootPath = opts.rootPath + # Default is to prompt to mount the installed system. + anaconda.rescue_mount = not opts.rescue_nomount + if opts.method and opts.method[0] == '@': expandFTPMethod(opts) @@ -692,8 +697,8 @@ if __name__ == "__main__": import rescue, instdata - rescueid = instdata.InstallData([], "fd0", opts.method, opts.display_mode) - rescue.runRescue(opts.rootPath, not opts.rescue_nomount, rescueid) + anaconda.id = instdata.InstallData([], "fd0", opts.method, opts.display_mode) + rescue.runRescue(anaconda) # shouldn't get back here sys.exit(1) @@ -835,7 +840,6 @@ if __name__ == "__main__": if opts.display_mode == 'g' and flags.usevnc: runVNC(vncpassword, vncconnecthost, vncconnectport, doStartupX11Actions) - anaconda.rootPath = opts.rootPath anaconda.intf = getInstallInterface(opts) # imports after setting up the path diff --git a/partedUtils.py b/partedUtils.py index 8e9dc181c..a2bf84939 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -641,7 +641,7 @@ class DiskSet: return labels - def findExistingRootPartitions(self, intf, mountpoint, upgradeany = 0): + def findExistingRootPartitions(self, anaconda, upgradeany = 0): """Return a list of all of the partitions which look like a root fs.""" rootparts = [] @@ -655,20 +655,20 @@ class DiskSet: found = 0 for fs in fsset.getFStoTry(dev): try: - isys.mount(dev, mountpoint, fs, readOnly = 1) + isys.mount(dev, anaconda.rootPath, fs, readOnly = 1) found = 1 break except SystemError, (errno, msg): pass if found: - if os.access (mountpoint + '/etc/fstab', os.R_OK): - relstr = getReleaseString(mountpoint) + if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((dev, fs, relstr)) - isys.umount(mountpoint) + isys.umount(anaconda.rootPath) # now, look for candidate lvm roots lvm.vgscan() @@ -681,20 +681,20 @@ class DiskSet: found = 0 for fs in fsset.getFStoTry(dev): try: - isys.mount(dev, mountpoint, fs, readOnly = 1) + isys.mount(dev, anaconda.rootPath, fs, readOnly = 1) found = 1 break except SystemError: pass if found: - if os.access (mountpoint + '/etc/fstab', os.R_OK): - relstr = getReleaseString(mountpoint) + if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((dev, fs, relstr)) - isys.umount(mountpoint) + isys.umount(anaconda.rootPath) lvm.vgdeactivate() @@ -715,22 +715,29 @@ class DiskSet: elif (part.fs_type and part.fs_type.name in fsset.getUsableLinuxFs()): node = get_partition_name(part) + + # In hard drive ISO method, don't try to mount the + # protected partitions because that'll throw up a + # useless error message. + if node in anaconda.method.protectedPartitions(): + continue + try: - isys.mount(node, mountpoint, part.fs_type.name) + isys.mount(node, anaconda.rootPath, part.fs_type.name) except SystemError, (errno, msg): - intf.messageWindow(_("Error"), + anaconda.intf.messageWindow(_("Error"), _("Error mounting file system on " "%s: %s") % (node, msg)) part = disk.next_partition(part) continue - if os.access (mountpoint + '/etc/fstab', os.R_OK): - relstr = getReleaseString(mountpoint) + if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((node, part.fs_type.name, relstr)) - isys.umount(mountpoint) + isys.umount(anaconda.rootPath) part = disk.next_partition(part) return rootparts @@ -174,8 +174,7 @@ def runShell(): else: os.waitpid(shpid, 0) -def runRescue(instPath, mountroot, id): - +def runRescue(anaconda): for file in [ "services", "protocols", "group", "joe", "man.config", "nsswitch.conf", "selinux" ]: try: @@ -184,7 +183,7 @@ def runRescue(instPath, mountroot, id): pass # see if they would like networking enabled - if not methodUsesNetworking(id.methodstr): + if not methodUsesNetworking(anaconda.id.methodstr): screen = SnackScreen() while 1: @@ -193,7 +192,7 @@ def runRescue(instPath, mountroot, id): "this system?"), [_("Yes"), _("No")]) if rc != string.lower(_("No")): - intf = RescueInterface(screen) + anaconda.intf = RescueInterface(screen) # need to call sequence of screens, have to look in text.py # @@ -206,7 +205,7 @@ def runRescue(instPath, mountroot, id): lastrc = INSTALL_OK step = 0 - dir = 1 + anaconda.dir = 1 while 1: s = "from %s import %s; nextWindow = %s" % \ @@ -215,21 +214,17 @@ def runRescue(instPath, mountroot, id): win = nextWindow() - if classNames[step] == "NetworkDeviceWindow": - args = (id.network, dir, intf, None, 0) - else: - args = (id.network, dir, intf, None) - rc = apply(win, (screen, ) + args) + rc = win(screen, anaconda) if rc == INSTALL_NOOP: rc = lastrc if rc == INSTALL_BACK: step = step - 1 - dir = - 1 + anaconda.dir = - 1 elif rc == INSTALL_OK: step = step + 1 - dir = 1 + anaconda.dir = 1 lastrc = rc @@ -239,19 +234,20 @@ def runRescue(instPath, mountroot, id): "from here. You will have to try " "again."), buttons=[_("OK")]) - dir = 1 + anaconda.dir = 1 step = 0 elif step >= len(classNames): break - startNetworking(id.network, intf) + startNetworking(anaconda.id.network, anaconda.intf) break else: break screen.finish() - if (not mountroot): + # Early shell access with no disk access attempts + if not anaconda.rescue_mount: print print _("When finished please exit from the shell and your " "system will reboot.") @@ -269,7 +265,7 @@ def runRescue(instPath, mountroot, id): isys.makeDevInode(dev, "/dev/" + dev) screen = SnackScreen() - intf = RescueInterface(screen) + anaconda.intf = RescueInterface(screen) # prompt to see if we should try and find root filesystem and mount # everything in /etc/fstab on that root @@ -283,7 +279,7 @@ def runRescue(instPath, mountroot, id): "\n\n" "If for some reason this process fails you can choose 'Skip' " "and this step will be skipped and you will go directly to a " - "command shell.\n\n") % (instPath,), + "command shell.\n\n") % (anaconda.rootPath,), [_("Continue"), _("Read-Only"), _("Skip")] ) if rc == string.lower(_("Skip")): @@ -298,7 +294,7 @@ def runRescue(instPath, mountroot, id): else: readOnly = 0 - disks = upgrade.findExistingRoots(intf, id, instPath, upgradeany = 1) + disks = upgrade.findExistingRoots(anaconda, upgradeany = 1) if not disks: root = None @@ -336,8 +332,8 @@ def runRescue(instPath, mountroot, id): # only pass first two parts of tuple for root, since third # element is a comment we dont want - rc = upgrade.mountRootPartition(intf, root[:2], - fs, instPath, + rc = upgrade.mountRootPartition(anaconda.intf, root[:2], + fs, anaconda.rootPath, allowDirty = 1, warnDirty = 1, readOnly = readOnly) @@ -356,7 +352,7 @@ def runRescue(instPath, mountroot, id): "make your system the root environment, run the command:\n\n" "\tchroot %s\n\nThe system will reboot " "automatically when you exit from the shell.") % - (instPath,instPath), + (anaconda.rootPath, anaconda.rootPath), [_("OK")] ) rootmounted = 1 @@ -368,12 +364,12 @@ def runRescue(instPath, mountroot, id): log.error("Error enabling swap") # now that dev is udev, bind mount the installer dev there - isys.mount("/dev", "%s/dev" %(instPath,), bindMount = 1) + isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = 1) # and /selinux too - if flags.selinux and os.path.isdir("%s/selinux" %(instPath,)): + if flags.selinux and os.path.isdir("%s/selinux" %(anaconda.rootPath,)): try: - isys.mount("/selinux", "%s/selinux" %(instPath,), + isys.mount("/selinux", "%s/selinux" %(anaconda.rootPath,), "selinuxfs") except Exception, e: log.error("error mounting selinuxfs: %s" %(e,)) @@ -437,7 +433,7 @@ def runRescue(instPath, mountroot, id): _("An error occurred trying to mount some or all of your " "system. Some of it may be mounted under %s.\n\n" "Press <return> to get a shell. The system will reboot " - "automatically when you exit from the shell.") % (instPath,), + "automatically when you exit from the shell.") % (anaconda.rootPath,), [_("OK")] ) else: ButtonChoiceWindow(screen, _("Rescue Mode"), @@ -450,12 +446,12 @@ def runRescue(instPath, mountroot, id): print if rootmounted and not readOnly: - makeMtab(instPath, fs) + makeMtab(anaconda.rootPath, fs) try: - makeResolvConf(instPath) + makeResolvConf(anaconda.rootPath) except Exception, e: log.error("error making a resolv.conf: %s" %(e,)) - print _("Your system is mounted under the %s directory.") % (instPath,) + print _("Your system is mounted under the %s directory.") % (anaconda.rootPath,) print print _("When finished please exit from the shell and your " diff --git a/upgrade.py b/upgrade.py index a52589957..6dbd91730 100644 --- a/upgrade.py +++ b/upgrade.py @@ -63,7 +63,7 @@ def findRootParts(anaconda): if anaconda.dir == DISPATCH_BACK: return if anaconda.id.rootParts is None: - anaconda.id.rootParts = findExistingRoots(anaconda.intf, anaconda.id, anaconda.rootPath) + anaconda.id.rootParts = findExistingRoots(anaconda) anaconda.id.upgradeRoot = [] for (dev, fs, meta) in anaconda.id.rootParts: @@ -77,23 +77,23 @@ def findRootParts(anaconda): anaconda.dispatch.skipStep("findinstall", skip = 1) anaconda.dispatch.skipStep("installtype", skip = 0) -def findExistingRoots(intf, id, chroot, upgradeany = 0): +def findExistingRoots(anaconda, upgradeany = 0): if not flags.setupFilesystems: - relstr = partedUtils.getReleaseString (chroot) + relstr = partedUtils.getReleaseString (anaconda.rootPath) if ((flags.cmdline.has_key("upgradeany")) or (upgradeany == 1) or (partedUtils.productMatches(relstr, productName))): - return [(chroot, 'ext2', "")] + return [(anaconda.rootPath, 'ext2', "")] return [] diskset = partedUtils.DiskSet() diskset.openDevices() - win = intf.progressWindow(_("Searching"), + win = anaconda.intf.progressWindow(_("Searching"), _("Searching for %s installations...") % (productName,), 5) - rootparts = diskset.findExistingRootPartitions(intf, chroot, + rootparts = diskset.findExistingRootPartitions(anaconda, upgradeany = upgradeany) for i in range(1, 6): time.sleep(0.25) |