[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Rewrite how main-menu handle errors



The current behaviour of main-menu when a d-i module fail is to raise
the menu debconf priority to make sure the menu appears.  This do not
really solve the problem when installing automatically, as all the
questions leading up to the problem are still not shown.  Instead of
changing the menu priority, I suggest lowering the debconf priority
limit.  When running with priority=high (as I do), this will make the
menu appear, and give me the option of answering most of the questions
that were hidden.  If one is running with priority=critical, the
failing package is likely to be choosen automatically again, fail
again (as no debconf answer is changed since the last try), and this
time it fails the priority limit will be lowered to 'medium' and the
menu will appear.

In addition to this fix, we need a way to change the debconf priority
limit from the menu, to be able to return to automatic installation.

This patch should fix main-menu.  I have no time to test it before I
go to NUCCC, but I wanted this change to make it into the next version
of main-menu.  Do any of you have time to test and commit it?

--- main-menu.c.~1.63.~	Wed Mar 26 20:17:18 2003
+++ main-menu.c	Wed Mar 26 20:29:49 2003
@@ -103,8 +103,6 @@
 	return NULL;
 }
 
-static char *menu_priority = "medium";
-
 /* Displays the main menu via debconf and returns the selected menu item. */
 struct package_t *show_main_menu(struct linkedlist_t *list) {
 	static struct debconfclient *debconf = NULL;
@@ -190,7 +188,7 @@
 	debconf->command(debconf, "SUBST", MAIN_MENU, "MENU", menutext, NULL);
 	if (menudefault)
 		debconf->command(debconf, "SET", MAIN_MENU, menudefault->description, NULL);
-	debconf->command(debconf, "INPUT", menu_priority, MAIN_MENU, NULL);
+	debconf->command(debconf, "INPUT", "medium", MAIN_MENU, NULL);
 	debconf->command(debconf, "GO", NULL);
 	debconf->command(debconf, "GET", MAIN_MENU, NULL);
 	s=debconf->value;
@@ -399,6 +397,37 @@
 	debconfclient_delete(debconf);
 }
 
+static char *debconf_priorities[] =
+  {
+    "low",
+    "medium",
+    "high",
+    "critical"
+  };
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+static void lower_debconf_priority (void) {
+	int pri;
+	debconf->command(debconf, "GET", "debconf/priority", NULL);
+	if ( ! debconf->value )
+		pri = 1;
+	else
+		for (pri = 0; i < ARRAY_SIZE(debconf_priorities); ++pri) {
+			if (0 == strcmp(debconf->value,
+					debconf_priorities[pri]) )
+				break;
+		}
+	--pri;
+	if (0 > pri)
+		pri = 0;
+
+	di_log("Lowering debconf priority limit from '%s' to '%s'",
+	       debconf->value, debconf_priorities[pri]);
+
+	debconf->command(debconf, "SET", "debconf/priority",
+			 debconf_priorities[pri], NULL);
+}
+
 int main (int argc, char **argv) {
 	struct package_t *p;
 
@@ -408,8 +437,10 @@
 	packages = status_read();
 	while ((p=show_main_menu(packages))) {
 		if (!do_menu_item(p)) {
-			di_log("Setting main menu question priority to critical");
-			menu_priority = "critical";
+			/* Something went wrong.  Lower debconf
+			   priority limit to try to give the user more
+			   control over the situation. */
+			lower_debconf_priority();
 		}
 		di_list_free(packages, di_pkg_free);
 		packages = status_read();



Reply to: