/**
 * File:
 *      bootloader/ppc/prep.ycp
 *
 * Module:
 *      Bootloader installation and configuration
 *
 * Summary:
 *      include containing specific functions for iSeries configuration
 *      and installation
 *
 * Authors:
 *      Jiri Srain <jsrain@suse.cz>
 *
 * $Id: chrp.ycp 19973 2004-10-27 07:50:12Z jsrain $
 *
 */

{
    textdomain "bootloader";

    import "Kernel";
    import "Mode";

    import "BootCommon";

    include "bootloader/ppc/misc.ycp";
    include "bootloader/routines/popups.ycp";

    /**
      * Propose bootloader settings
      * @param initial boolean true if doing initial proposal
      */
    global define void CHRPPropose (boolean initial) ``{
	if (BootCommon::was_proposed)
	{
	    return;
	}

        if ( ! (size (prep_boot_partitions) > 0 ||
            (prep_boot_partition != "" && prep_boot_partition != "/dev/null")))
        {
            BootCommon::activate = false;
	    prep_boot_partition = "/dev/null";
        }
	else
	{
	    BootCommon::activate = true;
	}
    }

    /**
      * Read the board-type-specific settings
      * @return boolean true on success
      */
    global define boolean CHRPRead () ``{
	prep_boot_partition = (string)
	    lookup_value (BootCommon::globals, "boot", "");
	BootCommon::activate
	    = prep_boot_partition != "" && prep_boot_partition != "/dev/null";
	of_defaultdevice = (boolean)
	    lookup_value (BootCommon::globals, "activate", false);
	return true;
    }

    /**
      * Update the board-type-specific settings
      * @return boolean true on success
      */
    global define boolean CHRPUpdate () ``{
	return true;
    }

    /**
      * Save the board-type-specific settings
      * @return boolean true on success
      */
    global define boolean CHRPSave () ``{
	BootCommon::globals = modifySection (BootCommon::globals, "boot",
	    prep_boot_partition);
	BootCommon::globals = modifySection (BootCommon::globals, "activate",
	    of_defaultdevice);
	return true;
    }

    /**
      * retuen the board-type-specific part of summary
      * @return a list of summary strings
      */
    global define list<string> CHRPSummary () ``{
	list<string> ret = [];
	if ((! Mode::config ()) && 0 == size (prep_boot_partitions))
	{
	    ret = [
		// summary part
		_("There is no 41 PReP boot partition. You cannot boot from the hard disk."),
	    ];
	}
	else if (BootCommon::activate == false)
	{
	    ret = [
		// summary part
		_("No boot configuration. Configure booting manually.")
	    ];
	}
	else
	{
	    ret = [
		sformat(
		    // summary part
		    _("yaboot will be written to %1. Use SMS Multiboot to boot from this drive."),
		    prep_boot_partition
		)
	    ];
	}
	return ret;
	// TODO of_defaultdevice ??
    }

    /**
      * Install the board-type-specific part of bootloader
      * @param requires_initrd boolean true if initrd is required
      * @return boolean true on success
      */
    global define boolean CHRPWrite (boolean requires_initrd) ``{
	// just call lilo
	return true;
    }

    /**
      * Initialize attributes of the board type
      */
    global define void CHRPInit () ``{
	y2milestone ("Initializing CHRP attributes");
	prep_only_active = true;
	prep_only_iseries_vd = false;
	prep_only_primary = true;
	prep_same_disk_as_root = true;
	table_items = [ "__chrp_location", "__set_default_of" ];
    }

}
