Author: jsrain
Date: Wed Aug 20 15:43:04 2008
New Revision: 50236
URL: http://svn.opensuse.org/viewcvs/yast?rev=50236&view=rev
Log:
added skeleton for checking whether scenario is supported, not yet actually used (fate #304499)
Added:
trunk/bootloader/src/modules/BootSupportCheck.ycp
Modified:
trunk/bootloader/package/yast2-bootloader.changes
trunk/bootloader/src/modules/Makefile.am
Modified: trunk/bootloader/package/yast2-bootloader.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/package/yast2-bootloader.changes?rev=50236&r1=50235&r2=50236&view=diff
==============================================================================
--- trunk/bootloader/package/yast2-bootloader.changes (original)
+++ trunk/bootloader/package/yast2-bootloader.changes Wed Aug 20 15:43:04 2008
@@ -1,7 +1,13 @@
-------------------------------------------------------------------
+Wed Aug 20 15:34:22 CEST 2008 - jsrain@suse.cz
+
+- added skeleton for checking whether scenario is supported, not
+ yet actually used (fate #304499)
+
+-------------------------------------------------------------------
Mon Aug 18 12:34:35 CEST 2008 - jsrain@suse.cz
-- store bootloader type vefore installing packagwes, fixed check
+- store bootloader type before installing packages, fixed check
for undefined product name (bnc #417383)
- 2.17.14
Added: trunk/bootloader/src/modules/BootSupportCheck.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootSupportCheck.ycp?rev=50236&view=auto
==============================================================================
--- trunk/bootloader/src/modules/BootSupportCheck.ycp (added)
+++ trunk/bootloader/src/modules/BootSupportCheck.ycp Wed Aug 20 15:43:04 2008
@@ -0,0 +1,190 @@
+/**
+ * File:
+ * modules/BootSupportCheck.ycp
+ *
+ * Module:
+ * Bootloader installation and configuration
+ *
+ * Summary:
+ * Check whether the current system setup is a supported configuration
+ *
+ * Authors:
+ * Jiri Srain
+ *
+ * $Id: BootCommon.ycp 49686 2008-08-05 10:04:46Z juhliarik $
+ *
+ */
+
+{
+module "BootSupportCheck";
+
+textdomain "bootloader";
+
+import "Bootloader";
+import "Arch";
+import "Storage";
+import "BootCommon";
+
+/**
+ * List of problems found during last check
+ */
+list<string> detected_problems = [];
+
+/**
+ * Add a new problem description to the list of found problems
+ */
+void AddNewProblem (string description) {
+ detected_problems = add (detected_problems, description);
+}
+
+/**
+ * List detected problems
+ * Always run SystemSupported before calling this function
+ * @return boolean a list of problems, empty if no was found
+ */
+global list<string> DetectedProblems () {
+ return detected_problems;
+}
+
+/**
+ * Check that bootloader is known and supported
+ */
+boolean KnownLoader () {
+ if (! contains (["grub", "elilo", "ppc", "zipl", "none"], Bootloader::getLoaderType ()))
+ {
+ y2error ("Unknown bootloader: %1", Bootloader::getLoaderType ());
+ AddNewProblem (sformat (_("Unknown bootloader: %1"), Bootloader::getLoaderType ()));
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Check that bootloader matches current hardware
+ */
+boolean CorrectLoaderType () {
+ string lt = Bootloader::getLoaderType ();
+ if (lt == "none")
+ return true;
+
+ if (Arch::s390() && lt == "zipl")
+ return true;
+ if (Arch::ppc() && lt == "ppc")
+ return true;
+ if (Arch::ia64() && lt == "elilo")
+ return true;
+ if (Arch::i386() || Arch::x86_64()) {
+ if (false) {// FIXME: check for EFI
+ if (lt == "elilo")
+ return true;
+ } else {
+ if (lt == "grub")
+ return true;
+ }
+ }
+ y2error ("Unsupported combination of hardware platform %1 and bootloader %2", Arch::architecture(), lt);
+ AddNewProblem (sformat (_("Unsupported combination of hardware platform %1 and bootloader %2"), Arch::architecture(), lt));
+ return false;
+}
+
+/**
+ * Checks for GPT partition table
+ // FIXME adapt for ELILO if needed
+ */
+boolean GptPartitionTable () {
+ map tm = Storage::GetTargetMap ();
+ list<string> devices = [ BootCommon::BootPartitionDevice ];
+ // TODO add more devices
+ foreach (string dev, devices, {
+ map p_dev = Storage::GetDiskPartition (dev);
+ integer num = BootCommon::myToInteger( p_dev["nr"]:nil );
+ string mbr_dev = p_dev["disk"]:"";
+ string label = tm[mbr_dev,"label"]:"";
+ y2milestone ("Label: %1", label);
+ y2internal ("Num: %1", num);
+ if (label == "gpt")
+ {
+ if (num > 3)
+ {
+ y2error ("Partitin number > 3 is being used for booting with GPT partition table");
+ AddNewProblem (_("Partitin number > 3 is being used for booting with GPT partition table"));
+ return false;
+ }
+ }
+ });
+ return true;
+}
+
+/**
+ * Check that the root partition is reachable
+ */
+boolean RootPartition () {
+ return true;
+}
+
+/**
+ * GRUB-related check
+ */
+boolean GRUB () {
+ boolean ret = GptPartitionTable ();
+ return ret;
+}
+
+/**
+ * ELILO related check
+ */
+boolean ELILO () {
+ return true;
+}
+
+/**
+ * ZIPL related check
+ */
+boolean ZIPL () {
+ return true;
+}
+
+/**
+ * PPC related check
+ */
+boolean PPC () {
+ return true;
+}
+
+/**
+ * Check if the system configuraiton is supported
+ * Also sets the founds problems into internal variable
+ * Always run this function before calling DetectedProblems()
+ * @return boolean true if supported
+ */
+global boolean SystemSupported () {
+ detected_problems = [];
+
+ // check if the bootloader is known and supported
+ boolean supported = KnownLoader ();
+
+ string lt = Bootloader::getLoaderType ();
+ if (lt == "none")
+ return true;
+
+ // detect correct bootloader type
+ supported = CorrectLoaderType () && supported;
+
+ // check whether root partition can be reached
+ supported = RootPartition () && supported;
+
+ // check specifics for individual loaders
+ if (lt == "grub")
+ supported = GRUB () && supported;
+ else if (lt == "elilo")
+ supported = ELILO () && supported;
+ else if (lt == "ppc")
+ supported = PPC () && supported;
+ else if (lt == "zipl")
+ supported = ZIPL () && supported;
+
+ y2milestone ("Configuration supported: %1", supported);
+ return supported;
+}
+
+} // EOF
Modified: trunk/bootloader/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/Makefile.am?rev=50236&r1=50235&r2=50236&view=diff
==============================================================================
--- trunk/bootloader/src/modules/Makefile.am (original)
+++ trunk/bootloader/src/modules/Makefile.am Wed Aug 20 15:43:04 2008
@@ -14,7 +14,8 @@
BootLILO.ycp \
BootPOWERLILO.ycp \
BootZIPL.ycp \
- Bootloader_API.pm
+ Bootloader_API.pm \
+ BootSupportCheck.ycp
# BootS390.ycp \
# BootMILO.ycp \
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org