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

Bug#219888: anna: Give the user full control of modules to be installed



On Mon, Nov 10, 2003 at 09:31:12PM +0100, Jeremie Koenig wrote:
> Ok, I'll look into these too. I'll test the new patch and send it
> tomorrow evening.

Well, this was more like 2 weeks, but here is a patch anyway. Can
someone have a look ? (to anna's changelog too, BTW, it looks weird.)

Changes:

    - Include all components to be autoinstalled in the modules selection
      question, when anna/list_all_modules is true or debconf/priority is
      low. (Closes: #219888)
    - Get rid of unconditionnaly resetting the seen flag. Instead,
      instanciate multiple questions from the templates, depending on the
      retriever passed on the command line.

Ideally, udebs calling anna should pass it their name or debconf root
for item #2, rather that letting us use the retriever name for
instanciating questions, but it don't cause any problem for now and i
guess it's not really the moment to change interfaces.

I don't know how this patch stands wrt the freeze. FWIW, I was able to
install a computer with only 28M of RAM using this patch (and some
rootskel tweak for the tmpfs filesystem size), so this can be regarded
as fixing a problem. I have a patch which only includes the first
change, if necessary.

I tested the patch with load-installer and download-installer, at
debconf/priority=low and medium, and everything has gone well.

-- 
Jeremie Koenig <sprite@sprite.fr.eu.org>
diff -ur --exclude=po --exclude=CVS anna.mrvn/TODO anna/TODO
--- anna.mrvn/TODO	Sun Nov 23 20:25:50 2003
+++ anna/TODO	Sun Nov 23 18:25:38 2003
@@ -18,9 +18,3 @@
   detect kernel module udebs and only install ones for the current kernel,
   and replace it with proper dependency checking. Throw out udebs whose
   deps cannot be met.
-
-* Include all packages that will be autoinstalled in the question about
-  what to install, in addition to those that will not be installed.
-  In corner cases the user mqay need to omit a particular package
-  from being installed even though it would be normally (think kernel
-  module udeb with a module that hangs with the given HW or something).
diff -ur --exclude=po --exclude=CVS anna.mrvn/anna.c anna/anna.c
--- anna.mrvn/anna.c	Sun Nov 23 20:25:50 2003
+++ anna/anna.c	Tue Nov 25 21:19:27 2003
@@ -20,8 +20,7 @@
     choices = list_to_choices(retrievers);
     if (!choices)
         di_log(DI_LOG_LEVEL_ERROR, "can't build choices");
-    debconf_fget(debconf, ANNA_RETRIEVER, "seen");
-    if (strcmp(debconf->value, "false") == 0) {
+    if (!seen(debconf, anna_retriever)) {
         const char *retriever = get_default_retriever(choices);
         char buf[200];
         di_package *p;
@@ -32,9 +31,8 @@
         }
     }
 
-    debconf_fset(debconf, ANNA_RETRIEVER, "seen", "false");
-    debconf_subst(debconf, ANNA_RETRIEVER, "CHOICES", choices);
-    debconf_input(debconf, "medium", ANNA_RETRIEVER);
+    debconf_subst(debconf, anna_retriever, "CHOICES", choices);
+    debconf_input(debconf, "medium", anna_retriever);
 
     di_free(retrievers);
     di_free(choices);
@@ -46,8 +44,8 @@
 static int
 choose_modules(di_packages *status, di_packages **packages, di_packages_allocator **packages_allocator)
 {
-    char *choices, *package_kernel, *running_kernel = NULL;
-    int package_count = 0;
+    char *choices, *choices_dfl, *package_kernel, *running_kernel = NULL;
+    int package_count = 0, package_count_dfl, i;
     di_package *package, *status_package, **package_array;
     di_slist_node *node, *node1;
     struct utsname uts;
@@ -136,23 +134,45 @@
 
     di_packages_resolve_dependencies_mark(*packages);
 
+    /* Now build the asklist. If debconf/priority == low, show all packages
+     * and preselect the good ones. Otherwise we only offer extra things. */
+
     /* Slight over-allocation, but who cares */
     package_array = di_new0(di_package *, di_hash_table_size((*packages)->table));
-    /* Now build the asklist, figuring out which packages have been
-     * pulled into instlist */
+    /* Modules selected by default, listed first. */
+    if(list_all_mods) {
+        for (node = (*packages)->list.head; node; node = node->next) {
+            package = node->data;
+            if (package->status_want == di_package_status_want_install)
+                package_array[package_count++] = package;
+        }
+    }
+    qsort(package_array, package_count, sizeof(di_package *),
+          package_array_compare);
+    package_count_dfl = package_count;
+    choices_dfl = list_to_choices(package_array);
+    /* Now, extra things. */
     for (node = (*packages)->list.head; node; node = node->next) {
         package = node->data;
         if (package->status_want == di_package_status_want_unknown)
             package_array[package_count++] = package;
     }
+    qsort(package_array + package_count_dfl, package_count - package_count_dfl,
+          sizeof(di_package *), package_array_compare);
 
-    qsort(package_array, package_count, sizeof(di_package *), package_array_compare);
     choices = list_to_choices(package_array);
-    debconf_fset(debconf, ANNA_CHOOSE_MODULES, "seen", "false");
-    debconf_subst(debconf, ANNA_CHOOSE_MODULES, "CHOICES", choices);
-    debconf_input(debconf, "medium", ANNA_CHOOSE_MODULES);
+
+    if(list_all_mods)
+        for(i = 0 ; i < package_count_dfl ; i++)
+            package_array[i]->status_want = di_package_status_want_unknown;
+
+    debconf_subst(debconf, anna_choose_modules, "CHOICES", choices);
+    if(!seen(debconf, anna_choose_modules))
+        debconf_set(debconf, anna_choose_modules, choices_dfl);
+    debconf_input(debconf, "medium", anna_choose_modules);
 
     di_free(choices);
+    di_free(choices_dfl);
     di_free(package_array);
 
     return 0;
@@ -166,7 +186,7 @@
     char *f, *fp, *dest_file;
     int ret = 0, pkg_count = 0;
 
-    debconf_get(debconf, ANNA_CHOOSE_MODULES);
+    debconf_get(debconf, anna_choose_modules);
     if (debconf->value != NULL) {
         char *choices = debconf->value;
 
@@ -277,10 +297,15 @@
 
     di_package **retrievers_before = get_retriever_packages(status);
 
+    /* Maybe the retreiver preselection and debconf instanciation things
+     * should be separate, and menu stuff should provide their names for
+     * use in question names instead. */
     if (argc > 1) {
-	    set_retriever(argv[1]);
-	    state=1; /* skip manual setting and use the supplied retriever */
-    }
+        prepare_questions(argv[1]);
+        set_retriever(argv[1]);
+        state=1; /* skip manual setting and use the supplied retriever */
+    } else
+        prepare_questions(NULL);
     
     while (state >= 0 && states[state] != NULL) {
         ret = states[state](status, &packages, &packages_allocator);
diff -ur --exclude=po --exclude=CVS anna.mrvn/anna.h anna/anna.h
--- anna.mrvn/anna.h	Sun Nov 23 20:25:50 2003
+++ anna/anna.h	Mon Nov 24 10:41:45 2003
@@ -11,14 +11,27 @@
 #define INCLUDE_FILE            DOWNLOAD_DIR "/include"
 #define EXCLUDE_FILE            DOWNLOAD_DIR "/exclude"
 #define DPKG_UNPACK_COMMAND	"udpkg --unpack"
+
+/* Debconf templates */
 #define ANNA_RETRIEVER          "anna/retriever"
+#define ANNA_LIST_ALL_MODS      "anna/list_all_modules"
 #define ANNA_CHOOSE_MODULES     "anna/choose_modules"
+#define ANNA_CHOOSE_MODULES_ALL "anna/choose_modules_all"
 #define ANNA_NO_MODULES         "anna/no_modules"
+/* Debconf questions */
+extern char *anna_choose_modules;
+extern char *anna_retriever;
+extern int list_all_mods;
 
 #undef LIBDI_SYSTEM_DPKG
 
 extern struct debconfclient *debconf;
 
+#define seen(debconf, question) \
+    ((debconf_fget(debconf, question, "seen") == CMD_SUCCESS) \
+     && (strcmp(debconf->value, "true") == 0))
+
+void prepare_questions(const char *retriever);
 di_package **get_retriever_packages(di_packages *status);
 const char *get_default_retriever(const char *choices);
 void set_retriever(const char *retriever);
diff -ur --exclude=po --exclude=CVS anna.mrvn/debian/changelog anna/debian/changelog
--- anna.mrvn/debian/changelog	Wed Nov 26 09:05:30 2003
+++ anna/debian/changelog	Tue Nov 25 21:35:45 2003
@@ -7,6 +7,13 @@
       and Geert Stappers
   * Safir Å eÄ?eroviÄ? 
     - Updated Bosnian translation.
+  * Jeremie Koenig
+    - Include all components to be autoinstalled in the modules selection
+      question, when anna/list_all_modules is true or debconf/priority is
+      low. (Closes: #219888)
+    - Get rid of unconditionnaly resetting the seen flag. Instead,
+      instanciate multiple questions from the templates, depending on the
+      retriever passed on the command line.
 
  -- Bart Cornelis <cobaco@linux.be>  Mon, 17 Nov 2003 16:44:25 +0100
 
diff -ur --exclude=po --exclude=CVS anna.mrvn/debian/templates anna/debian/templates
--- anna.mrvn/debian/templates	Sun Nov 23 20:25:50 2003
+++ anna/debian/templates	Tue Nov 25 21:41:32 2003
@@ -5,6 +5,30 @@
  The retriever is responsible for fetching installer components to be
  loaded.
 
+Template: anna/list_all_modules
+Type: boolean
+Default: false
+Description: Do you want to have full control over the components selection ?
+ In most cases, all core installer components will be installed automatically,
+ without your intervention. However, you may want to be offered the opportunity
+ to deselect some of them, in particular if you're short on memory.
+ .
+ This question is never shown directly. Instead it is set to true if the
+ debconf priority is low.
+
+Template: anna/choose_modules_all
+Type: multiselect
+Choices: ${CHOICES}
+_Description: Installer components to load:
+ Things you are most likely to need are shown first and have been
+ preselected. Beware than without some of them, the installation can be
+ impossible to complete because of missing functionnality. The other
+ installer components have low priority and are probably not necessary,
+ but may be interesting to some users.
+ .
+ Note that if you select a component that requires others, those
+ components will also be loaded.
+
 Template: anna/choose_modules
 Type: multiselect
 Choices: ${CHOICES}
diff -ur --exclude=po --exclude=CVS anna.mrvn/util.c anna/util.c
--- anna.mrvn/util.c	Sun Nov 23 20:25:50 2003
+++ anna/util.c	Tue Nov 25 21:10:37 2003
@@ -6,6 +6,46 @@
 #include <sys/utsname.h>
 #include "anna.h"
 
+/* Choose which questions to ask. Instanciate templates if necessary */
+
+char *anna_choose_modules;
+char *anna_retriever;
+int list_all_mods;
+
+static char *instanciate(const char *template, const char *suffix)
+{
+    char *question;
+
+    if(!suffix) {
+        question = strdup(template);
+    } else {
+        asprintf(&question, "%s.%s", template, suffix);
+        debconf_register(debconf, template, question);
+    }
+
+    return question;
+}
+
+void prepare_questions(const char *suffix)
+{
+    char *anna_list_all_mods;
+
+    anna_list_all_mods = instanciate(ANNA_LIST_ALL_MODS, suffix);
+    if(debconf_get(debconf, "debconf/priority") != CMD_SUCCESS)
+        list_all_mods = 0;
+    else if(strcmp(debconf->value, "low") == 0)
+        list_all_mods = 1;
+    else if(debconf_get(debconf, anna_list_all_mods) != CMD_SUCCESS)
+        list_all_mods = 0;
+    else
+        list_all_mods = (strcmp(debconf->value, "true") == 0);
+    debconf_set(debconf, anna_list_all_mods, list_all_mods ? "true" : "false");
+    free(anna_list_all_mods);
+
+    anna_choose_modules = instanciate(list_all_mods ? ANNA_CHOOSE_MODULES_ALL
+            : ANNA_CHOOSE_MODULES, suffix);
+    anna_retriever = instanciate(ANNA_RETRIEVER, suffix);
+}
 
 /* Construct a list of all the retriever packages */
 di_package **
@@ -58,7 +98,7 @@
 /* Force use of a given retriever. */
 void
 set_retriever(const char *retriever) {
-    debconf_set(debconf, ANNA_RETRIEVER, retriever);
+    debconf_set(debconf, anna_retriever, retriever);
 }
 
 /*
@@ -70,7 +110,7 @@
 {
     char *retriever = NULL, *colon_p = NULL;
 
-    debconf_get(debconf, ANNA_RETRIEVER);
+    debconf_get(debconf, anna_retriever);
     if (debconf->value != NULL)
         colon_p = strchr(debconf->value, ':');
     if (colon_p != NULL)

Reply to: