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

Re: Another installation failure report



Hi...
On Tue, 3 Jun 2003 10:39 pm, Martin Sjögren wrote:
> Yes. A future project of mine is to change that question so that
> packages with priority standard will appear in the list too, with
> checked boxes. But this question will most likely be asked at priority
> low, as only a nitpicker should need to answer it.
>

Try the attached patch. It works with the exception that for some reason 
debconf doesn't prompt for the question the first time this code is run. Any 
idea why? What have I missed to make this happen?

/me goes back to studying for exams now.

=)
Peter
Index: anna.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/anna/anna.c,v
retrieving revision 1.55
diff -u -3 -p -u -r1.55 anna.c
--- anna.c	29 May 2003 15:06:07 -0000	1.55
+++ anna.c	4 Jun 2003 04:27:03 -0000
@@ -54,13 +54,14 @@ static int ask_count;
 static int
 choose_modules(void)
 {
-    struct linkedlist_t *pkglist, *tmplist, *status_p, *asklist;
+    struct linkedlist_t *pkglist, *tmplist, *status_p, *asklist, *sellist;
     struct list_node *node, *prev, *next;
-    struct package_t *p;
+    struct package_t *p, **selpkgs;
     FILE *fp;
-    char *choices, *pkg_kernel, *running_kernel = NULL;
+    char *choices, *selected_choices, *pkg_kernel, *running_kernel = NULL;
     struct utsname uts;
     int package_count = 0;
+    int sel_count = 0;
 
     config_retriever();
     ask_count = 0;
@@ -103,51 +104,74 @@ choose_modules(void)
     di_pkg_resolve_deps(pkglist);
     /* Figure out which packages we definitely want to install */
     prev = NULL;
-    instlist = get_initial_package_list(pkglist);
+    sellist = get_initial_package_list(pkglist);
     for (node = pkglist->head; node != NULL; node = next) {
         next = node->next;
         p = (struct package_t *)node->data;
         pkg_kernel = udeb_kernel_version(p);
         if (p->priority >= standard || enhances(p, status_p) ||
                 (running_kernel && pkg_kernel && strcmp(running_kernel, pkg_kernel) == 0)) {
-            /* These packages will automatically be installed */
-            if (prev != NULL)
-                prev->next = next;
-            else
-                pkglist->head = next;
-            if (instlist->tail == NULL) {
-                instlist->head = node;
-                instlist->tail = node;
-            } else {
-                instlist->tail->next = node;
-                instlist->tail = node;
+            /* These packages should be selected by default, add them to the
+             * selected list if they aren't already there. */
+            if (di_pkg_find(sellist, p->package) == NULL) {
+                struct list_node *newnode = calloc(1, sizeof(struct list_node));
+                newnode->data = node->data;
+                
+                if (sellist->tail == NULL) {
+                    sellist->head = sellist->tail = newnode;
+                } else {
+                    sellist->tail->next = newnode;
+                    sellist->tail = newnode;
+                }
             }
-            node->next = NULL;
-            continue;
         }
         package_count++;
-        prev = node;
     }
+    
     /* Drop files in udeb_exclude */
-    drop_excludes(instlist);
+    drop_excludes(sellist);
+    
     /* Pull in dependencies */
-    tmplist = di_pkg_toposort_list(instlist);
+    tmplist = di_pkg_toposort_list(sellist);
+
     /* Free up the memory used by the nodes in the old instlist */
     //di_list_free(instlist, free); /* This actually causes memory corruption...dammit */
-    di_list_free(status_p, di_pkg_free);
-    instlist = tmplist;
+    sellist = tmplist;
+
+
+    /* Build up the list of packages that have been selected */
+    selpkgs = calloc(package_count, sizeof(struct package_t *));
+    if (selpkgs == NULL)
+        return 6;
+    
+    for (node = sellist->head; node != NULL; node = next) {
+        next = node->next;
+
+        p = (struct package_t *)node->data;   
+
+        /* If p->filename is NULL, it's a virtual package */
+        if (p->filename != NULL && !is_installed(p, status_p))
+                selpkgs[sel_count++] = p;
+        
+        free(node);
+    }
+    selected_choices = list_to_choices(selpkgs, sel_count);
+    debconf->command(debconf, "SET", ANNA_CHOOSE_MODULES, selected_choices, NULL);
+    free(selected_choices);
+    free(selpkgs);
+    free(sellist);
 
     /* Slight over-allocation, but who cares */
     askpkgs = calloc(package_count, sizeof(struct package_t *));
-    /* Now build the asklist, figuring out which packages have been
-     * pulled into instlist */
+
+    /* Now build the asklist */
     prev = NULL;
     asklist = pkglist;
     for (node = asklist->head; node != NULL; node = next) {
         next = node->next;
         p = (struct package_t *)node->data;
         /* If p->filename is NULL, it's a virtual package */
-        if (p->filename != NULL && di_pkg_find(instlist, p->package) == NULL)
+        if (p->filename != NULL && !is_installed(p, status_p))
             askpkgs[ask_count++] = p;
         free(node);
     }
@@ -156,8 +180,14 @@ choose_modules(void)
     choices = list_to_choices(askpkgs, ask_count);
     debconf->command(debconf, "FSET", ANNA_CHOOSE_MODULES, "seen", "false", NULL);
     debconf->command(debconf, "SUBST", ANNA_CHOOSE_MODULES, "CHOICES", choices, NULL);
-    debconf->command(debconf, "INPUT medium", ANNA_CHOOSE_MODULES, NULL);
+    debconf->command(debconf, "INPUT low", ANNA_CHOOSE_MODULES, NULL);
     free(choices);
+    
+    di_list_free(status_p, di_pkg_free);
+
+    instlist = calloc(1, sizeof(struct linkedlist_t));
+    if (instlist == NULL)
+        return 7;
 
     return 0;
 }

Reply to: