Separate the memory check logic from the act of displaying dialogs or switching to text mode. This makes it easier to skip it when --nomemcheck is passed. Add --nomemcheck which continues the install even if there isn't enough memory. --- anaconda | 59 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 39 insertions(+), 20 deletions(-) diff --git a/anaconda b/anaconda index 21ae8fe..ff6eda1 100755 --- a/anaconda +++ b/anaconda @@ -219,6 +219,7 @@ def parseOptions(argv = None): op.add_option("--dogtail", dest="dogtail", action="store", type="string") op.add_option("--dlabel", action="store_true", default=False) op.add_option("--image", action="append", dest="images", default=[]) + op.add_option("--nomemcheck", action="store_true") # Deprecated, unloved, unused op.add_option("-r", "--rootPath", dest="unsupportedMode", @@ -311,7 +312,25 @@ def gtk_warning(title, reason): dialog.run() dialog.destroy() -def check_memory(anaconda, opts, display_mode=None): +def how_much_ram(): + """ Return information on how much RAM is available + + A tuple consisting of: + (total_ram, (text_ok, text_ram), (gui_ok, gui_ram)) + + text_ok and gui_ok are True/False + RAM values are in MiB + """ + total_ram = int(isys.total_memory() / 1024) + text_ram = int((isys.MIN_RAM) / 1024) + gui_ram = text_ram + int(isys.GUI_INSTALL_EXTRA_RAM / 1024) + + return (total_ram, + (text_ram <= total_ram, text_ram), + (gui_ram <= total_ram, gui_ram) + ) + +def check_memory(opts, display_mode=None): reason_strict = _("%s requires %s MB of memory to install, but you only have " "%s MB on this machine.\n") reason_graphical = _("The %s graphical installer requires %s MB of memory, but " @@ -325,43 +344,43 @@ def check_memory(anaconda, opts, display_mode=None): "terminal.") nolivecd_extra = _(" Starting text mode.") - if not display_mode: - display_mode = anaconda.displayMode + (total_ram, (text_ok, text_ram), (gui_ok, gui_ram)) = how_much_ram() - extra_ram = 0 - reason = reason_strict - total_ram = int(isys.total_memory() / 1024) - needed_ram = int((isys.MIN_RAM + extra_ram) / 1024) + # log the results + log.info(_("Total RAM: %sMiB Text Mode: %sMiB GUI Mode: %sMiB"), + total_ram, text_ram, gui_ram) + if opts.nomemcheck: + return - if needed_ram > total_ram: - from snack import SnackScreen, ButtonChoiceWindow + if not text_ok: + reason = reason_strict if opts.liveinst: - stdoutLog.warning(reason % (product.productName, needed_ram, total_ram)) - gtk_warning(livecd_title, reason % (product.productName, needed_ram, total_ram)) + stdoutLog.warning(reason % (product.productName, text_ram, total_ram)) + gtk_warning(livecd_title, reason % (product.productName, text_ram, total_ram)) else: + from snack import SnackScreen, ButtonChoiceWindow reason += reboot_extra screen = SnackScreen() ButtonChoiceWindow(screen, _('Fatal Error'), - reason % (product.productName, needed_ram, total_ram), + reason % (product.productName, text_ram, total_ram), buttons = (_("OK"),)) screen.finish() sys.exit(1) # override display mode if machine cannot nicely run X - if display_mode not in ('t', 'c') and not flags.usevnc: - needed_ram += int(isys.GUI_INSTALL_EXTRA_RAM / 1024) + if display_mode == 'g' and not flags.usevnc: reason = reason_graphical - if needed_ram > total_ram: + if not gui_ok: if opts.liveinst: reason += livecd_extra - stdoutLog.warning(reason % (product.productName, needed_ram, total_ram)) + stdoutLog.warning(reason % (product.productName, gui_ram, total_ram)) title = livecd_title - gtk_warning(title, reason % (product.productName, needed_ram, total_ram)) + gtk_warning(title, reason % (product.productName, gui_ram, total_ram)) sys.exit(1) else: reason += nolivecd_extra - stdoutLog.warning(reason % (product.productName, needed_ram, total_ram)) + stdoutLog.warning(reason % (product.productName, gui_ram, total_ram)) anaconda.displayMode = 't' time.sleep(2) @@ -450,7 +469,7 @@ def setupDisplay(anaconda, opts): vncS.password = ret log.info("Display mode = %s" % anaconda.displayMode) - check_memory(anaconda, opts) + check_memory(opts, anaconda.displayMode) # # now determine if we're going to run in GUI or TUI mode @@ -638,7 +657,7 @@ if __name__ == "__main__": anaconda.opts = opts # check memory, just the text mode for now: - check_memory(anaconda, opts, 't') + check_memory(opts, 't') if opts.unsupportedMode: stdoutLog.error("Running anaconda in %s mode is no longer supported." % opts.unsupportedMode) -- 1.7.4.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list