Browse Source

actually talks to debconf now (make demo)

r29
keep-around/c8703c509368e1805e513d61f98a9d17d2cdd9cc
Joey Hess 22 years ago
parent
commit
a290636dab
  1. 3
      Makefile
  2. 9
      debconf.c
  3. 38
      main-menu.c
  4. 3
      main-menu.h
  5. 5
      main-menu.templates
  6. 11
      status

3
Makefile

@ -7,5 +7,8 @@ all: $(BIN)
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS) $(LIBS)
demo: $(BIN)
/usr/share/debconf/frontend ./$(BIN)
clean:
-rm -f $(BIN) $(OBJS) *~

9
debconf.c

@ -0,0 +1,9 @@
#include "main-menu.h"
#include <stdio.h>
int debconf_command (char *command) {
printf("%s\n", command);
/* TODO: read result from debconf */
return 1;
}

38
main-menu.c

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <search.h>
#include <stdio.h>
/* For btree. */
int package_compare (const void *p1, const void *p2) {
@ -46,11 +45,12 @@ static void order(struct package_t *p, void *package_tree,
p->processed = 1;
}
/* Orders the main menu. Returns a linked list of packages. */
struct package_t *main_menu(struct package_t *packages) {
/* Displays the main menu via debconf. */
void 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;
char *s, menutext[1024] = "SUBST " MAIN_MENU " MENU ";
/* Make a flat list of the packages, plus a btree for name lookup. */
for (p = packages; p; p = p->next) {
@ -73,20 +73,34 @@ struct package_t *main_menu(struct package_t *packages) {
order(package_list[i], package_tree, &head, &tail);
}
}
return head;
/* Make debconf display it. */
s = menutext + strlen(menutext);
for (p = head; p; p=p->next) {
if (p->installer_menu_item) {
strcpy(s, p->description);
s += strlen(p->description);
*s++ = ',';
*s++ = ' ';
}
}
s = s - 2;
*s = 0;
/*
* TODO: save some executable size by not hard coding the MAIN_MENU
* string everwhere
*/
debconf_command("FSET " MAIN_MENU " isdefault true");
debconf_command(menutext);
debconf_command("INPUT medium " MAIN_MENU);
debconf_command("GO");
}
int main (int argc, char **argv) {
struct package_t *first, *p, *packages;
struct package_t *packages;
packages = status_read();
first = main_menu(packages);
for (p = first; p; p=p->next) {
if (p->installer_menu_item)
printf("--%s\n", p->description);
}
main_menu(packages);
return(0);
}

3
main-menu.h

@ -3,6 +3,8 @@
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
#define MAIN_MENU "debian-installer/main-menu"
/* data structures */
struct package_t {
char *package;
@ -15,3 +17,4 @@ struct package_t {
struct package_t *status_read(void);
int package_compare (const void *, const void *);
int debconf_command (char *);

5
main-menu.templates

@ -0,0 +1,5 @@
Template: debian-installer/main-menu
Type: select
Choices: ${MENU}
Description: Choose the next step:
Here is the main menu of the Debian installer.

11
status

@ -25,15 +25,6 @@ Installer-Menu-Item: 3
Depends: disk-driver
Description: Partition disk
Package: mom
Depends: dad
Package: dad
Description: dad
Installer-Menu-Item: 9
Package: foo
Package: disk-driver
Package: format-partitions
@ -47,7 +38,7 @@ Depends: format-partitions, install-media
Description: Install base system
Package: install-lilo
Installer-Menu-Item: 2
Installer-Menu-Item: 1
Depends: install-base
Description: Install lilo

Loading…
Cancel
Save