ACC SHELL

Path : /usr/share/YaST2/include/add-on/
File Upload :
Current File : //usr/share/YaST2/include/add-on/misc.ycp

/**
 * File:
 *      include/add-on/misc.ycp
 *
 * Module:
 *      System installation
 *
 * Summary:
 *      Add-on product miscellaneous
 *
 * Authors:
 *      Lukas Ocilka <locilka@suse.cz>
 *
 *
 */
{

textdomain "add-on";

import "AddOnProduct";
import "Popup";

/**
 * Returns whether the machine has insufficient memory for using
 * Add-Ons (in inst-sys).
 *
 * @return boolean has insufficient memory
 */
boolean HasInsufficientMemory () {
    // 384 MB - 5% (bugzilla #239630)
    integer enough_memory = 373000;

    map meminfo = (map) SCR::Read (.proc.meminfo);
    integer totalmem = meminfo["memtotal"]:0 + meminfo["swaptotal"]:0;

    y2milestone ("Memory: %1, Swap: %2, Total: %3",
	meminfo["memtotal"]:0, meminfo["swaptotal"]:0, totalmem
    );

    // something is wrong
    if (totalmem == nil) {
	// using only RAM if possible
	if (meminfo["memtotal"]:nil != nil) {
	    totalmem = meminfo["memtotal"]:0;
	// can't do anything, just assume we enough
	} else {
	    totalmem = enough_memory;
	}
    }

    // do we have less memory than needed?
    return (totalmem < enough_memory);
}

boolean ContinueIfInsufficientMemory () {
    y2warning ("Not enough memory!");

    // If already reported, just continue
    if (! AddOnProduct::low_memory_already_reported) {
	// report it only once
	AddOnProduct::low_memory_already_reported = true;

	if (Popup::YesNoHeadline (
	    // TRANSLATORS: pop-up headline
	    _("Warning: Not enough memory!"),
	    // TRANSLATORS: pop-up question
	    _("Your system does not seem to have enough memory to use add-on products
during installation. You can enable add-on products later when the
system is running.

Do you want to skip using add-on products?")
	)) {
	    y2milestone ("User decided to skip Add-Ons");
	    AddOnProduct::skip_add_ons = true;
		
	    return false;
	} else {
	    y2warning ("User decided to continue with not enough memory...!");

	    return true;
	}
    }

    return true;
}

} //end of include

ACC SHELL 2018