Browse Source

added debconf return code parsing, and it now understands what the user

picks from the menu

r34
keep-around/c8703c509368e1805e513d61f98a9d17d2cdd9cc
Joey Hess 22 years ago
parent
commit
dee77ef889
  1. 3
      TODO
  2. 19
      debconf.c
  3. 18
      main-menu.c
  4. 1
      main-menu.h

3
TODO

@ -1,4 +1,5 @@
* Handle processing debconf's return codes.
* Handle processing debconf's return codes and getting the textual return
value.
* Once something is picked from the menu, (re)configure its package (and
first configure everything its package depends on).
* Figure out how to handle configuring only one virtual package (pick off

19
debconf.c

@ -2,15 +2,30 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
/* Holds the textual return code of the last command. */
char *text;
int debconf_command (const char *fmt, ...) {
char buf[BUFSIZE];
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
printf("\n");
fflush(stdout); /* make sure debconf sees it to prevent deadlock */
fgets(buf, BUFSIZE, stdin);
/* TODO: this could be more robust */
strtok(buf, " \t\n");
text=strtok(NULL, "\n");
return atoi(buf);
}
/* TODO: read result from debconf */
return 1;
char *debconf_ret (void) {
return text;
}

18
main-menu.c

@ -64,7 +64,7 @@ int isdefault(struct package_t *p) {
}
/* Displays the main menu via debconf. */
void main_menu(struct package_t *packages) {
struct package_t *show_main_menu(struct package_t *packages) {
struct package_t **package_list, *p, *head = NULL, *tail = NULL;
int i = 0, num = 0;
void *package_tree = NULL;
@ -114,19 +114,31 @@ void main_menu(struct package_t *packages) {
*s = 0;
s = menutext;
/* Make debconf show the menu and get the user's choice. */
if (menudefault)
debconf_command("SET %s %s", MAIN_MENU, menudefault);
debconf_command("FSET %s isdefault true", MAIN_MENU);
debconf_command("SUBST %s MENU %s", MAIN_MENU, menutext);
debconf_command("INPUT medium %s", MAIN_MENU);
debconf_command("GO");
debconf_command("GET %s", MAIN_MENU);
s=debconf_ret();
/* Figure out which menu item was selected. */
for (p = head; p; p = p->next) {
if (p->installer_menu_item && strcmp(p->description, s) == 0)
return p;
}
return 0; // should never happen
}
int main (int argc, char **argv) {
struct package_t *packages;
struct package_t *p, *packages;
packages = status_read();
main_menu(packages);
p=show_main_menu(packages);
fprintf(stderr, "%s\n", p->package);
return(0);
}

1
main-menu.h

@ -24,3 +24,4 @@ struct package_t {
struct package_t *status_read(void);
int package_compare (const void *, const void *);
int debconf_command (const char *, ...);
char *debconf_ret (void);

Loading…
Cancel
Save