Author: locilka
Date: Tue Apr 1 15:50:07 2008
New Revision: 45932
URL: http://svn.opensuse.org/viewcvs/yast?rev=45932&view=rev
Log:
- New functionality to select the best-matching image for image
installation if more than one fit.
Modified:
trunk/installation/package/yast2-installation.changes
trunk/installation/src/modules/ImageInstallation.ycp
Modified: trunk/installation/package/yast2-installation.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/package/yast2-installation.changes?rev=45932&r1=45931&r2=45932&view=diff
==============================================================================
--- trunk/installation/package/yast2-installation.changes (original)
+++ trunk/installation/package/yast2-installation.changes Tue Apr 1 15:50:07 2008
@@ -4,6 +4,8 @@
- Automatic configuration can be newly defined by control file. Two
new variables have been added enable_autoconfiguration and
autoconfiguration_default.
+- New functionality to select the best-matching image for image
+ installation if more than one fit.
-------------------------------------------------------------------
Tue Apr 1 12:36:52 CEST 2008 - jsrain@suse.cz
Modified: trunk/installation/src/modules/ImageInstallation.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/src/modules/ImageInstallation.ycp?rev=45932&r1=45931&r2=45932&view=diff
==============================================================================
--- trunk/installation/src/modules/ImageInstallation.ycp (original)
+++ trunk/installation/src/modules/ImageInstallation.ycp Tue Apr 1 15:50:07 2008
@@ -312,6 +312,42 @@
// TODO error checking
}
+// TODO: extract the weight from control file
+list <string> patterns_priority = ["^kde", "^gnome", "^xfce", "^x11", "^base", "^enhanced_base"];
+
+/**
+ * Function finds a pattern weight
+ * The return value is 0 to 9999. The smaller the number the bigger the weight.
+ *
+ * @param string pattern
+ * @return integer pattern weight
+ */
+integer GetPatternWeight (string pattern) {
+ integer weight = 9999;
+
+ integer counter = -1;
+ foreach (string one_pattern_regexp, patterns_priority, {
+ counter = counter + 1;
+ if (regexpmatch (pattern, one_pattern_regexp)) {
+ weight = counter;
+ break;
+ }
+ });
+
+ return weight;
+}
+
+/**
+ * Patterns have an internal weight. It says which one of two is better
+ * to use for image installation. The size does matter.
+ */
+boolean DoesPatternFitBetter (string last_pattern, string new_pattern) {
+ integer last_pattern_weight = GetPatternWeight (last_pattern);
+ integer new_pattern_weight = GetPatternWeight (new_pattern);
+
+ return (new_pattern_weight < last_pattern_weight);
+}
+
/**
* Find a set of images which suites selected patterns
* @param patterns a list of patterns which are selected
@@ -345,16 +381,52 @@
y2milestone ("Image set descriptions: %1", image_sets);
map