[PC-BSD Commits] r7222 - pcbsd-projects/txt-sysinstall
svn at pcbsd.org
svn at pcbsd.org
Thu Jul 15 21:54:17 PDT 2010
Author: johnh
Date: 2010-07-15 21:54:17 -0700 (Thu, 15 Jul 2010)
New Revision: 7222
Added:
pcbsd-projects/txt-sysinstall/packages.c
Modified:
pcbsd-projects/txt-sysinstall/Makefile
pcbsd-projects/txt-sysinstall/components.c
pcbsd-projects/txt-sysinstall/disksel.c
pcbsd-projects/txt-sysinstall/ftp.c
pcbsd-projects/txt-sysinstall/main.c
pcbsd-projects/txt-sysinstall/txt-sysinstall.h
pcbsd-projects/txt-sysinstall/tzone.c
pcbsd-projects/txt-sysinstall/util.c
Log:
Support for packages as well as various other tidbits.
Modified: pcbsd-projects/txt-sysinstall/Makefile
===================================================================
--- pcbsd-projects/txt-sysinstall/Makefile 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/Makefile 2010-07-16 04:54:17 UTC (rev 7222)
@@ -3,6 +3,7 @@
PROG= txt-sysinstall
SRCS= main.c mainmenu.c disksel.c partsel.c useradd.c netif.c rootpass.c
SRCS+= tzone.c components.c util.c install.c medium.c label.c ftp.c
+SRCS+= packages.c
CFLAGS+= -ggdb -DDEBUG -D__PCBSD__
Modified: pcbsd-projects/txt-sysinstall/components.c
===================================================================
--- pcbsd-projects/txt-sysinstall/components.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/components.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -34,6 +34,7 @@
#include "txt-sysinstall.h"
#define MAXCOMP 50
+#define COMPSTRSIZE 16384
#define MODULE "Components selection"
struct component {
@@ -81,7 +82,7 @@
char *token;
char *buf;
char *ptr;
- char compstr[2048];
+ char *compstr;
dialogMenuItem *menus;
struct component *components;
int status;
@@ -91,8 +92,8 @@
buf = safe_malloc(BUFSZ+1);
status = run_pcsysinstall(buf, BUFSZ, "list-components", NULL);
menus = safe_malloc(sizeof(*menus)*MAXCOMP);
+ compstr = safe_malloc(COMPSTRSIZE);
- bzero(compstr, sizeof(compstr));
components = safe_malloc(sizeof(*components)*MAXCOMP);
i = 0;
@@ -153,7 +154,9 @@
}
free(buf);
+ free(compstr);
free(menus);
+ save_config();
do_install();
}
Modified: pcbsd-projects/txt-sysinstall/disksel.c
===================================================================
--- pcbsd-projects/txt-sysinstall/disksel.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/disksel.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -62,7 +62,6 @@
DMENUF(&menus[i++], "Next", NULL, NULL);
DMENUF(&menus[i++], "Back", NULL, NULL);
- i = 2;
while ((token = strsep(&buf, "\n")) != NULL && safe_strlen(token) > 0 &&
i < MAXDISKS+2) {
char *disk;
Modified: pcbsd-projects/txt-sysinstall/ftp.c
===================================================================
--- pcbsd-projects/txt-sysinstall/ftp.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/ftp.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -95,7 +95,6 @@
DMENUF(&menus[i++], "Next", NULL, NULL);
DMENUF(&menus[i++], "Back", NULL, NULL);
- i = 2;
while ((token = strsep(&buf, "\n")) != NULL && safe_strlen(token) > 0 &&
i < MAXSERVERS-1) {
desc = strsep(&token, ":");
Modified: pcbsd-projects/txt-sysinstall/main.c
===================================================================
--- pcbsd-projects/txt-sysinstall/main.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/main.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -56,8 +56,11 @@
}
}
+ sysinstall_init();
+
setenv("DIALOGRC", style, 1);
init_dialog();
- sysinstall();
+ //sysinstall();
+ dialog_packages();
end_dialog();
}
Property changes on: pcbsd-projects/txt-sysinstall/packages.c
___________________________________________________________________
Added: svn:keywords
+ Id Date Author Rev
Modified: pcbsd-projects/txt-sysinstall/txt-sysinstall.h
===================================================================
--- pcbsd-projects/txt-sysinstall/txt-sysinstall.h 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/txt-sysinstall.h 2010-07-16 04:54:17 UTC (rev 7222)
@@ -43,12 +43,18 @@
mptr->selected = s; \
mptr->fire = f; \
mptr->data = d; \
+ mptr->lbra = '['; \
+ mptr->mark = 'X'; \
+ mptr->rbra = ']'; \
mptr->aux = a; \
} while (0)
#define DMENUF(m, p, t, f) \
DMENU(m, p, t, NULL, NULL, f, NULL, 0)
+#define DMENUFC(m, p, t, f, c) \
+ DMENU(m, p, t, c, NULL, f, NULL, 0)
+
#define DMENUFD(m, p, t, f, d) \
DMENU(m, p, t, NULL, NULL, f, d, 0)
@@ -65,12 +71,17 @@
void dialog_medium(void);
void dialog_label(int);
void dialog_ftp(void);
+void dialog_packages(void);
void do_install(void);
/* utility functions */
+void sysinstall_init(void);
+void sysinstall_fini(void);
void screen_clear(const char *);
int empty(const char *);
void * safe_malloc(size_t);
size_t safe_strlen(const char *);
+char * safe_strdup(const char *);
int run_pcsysinstall(char *, size_t, const char *, const char *);
void appendconfig(const char *, const char *);
+void save_config(void);
Modified: pcbsd-projects/txt-sysinstall/tzone.c
===================================================================
--- pcbsd-projects/txt-sysinstall/tzone.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/tzone.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -74,13 +74,6 @@
i < MAXTZONES) {
DMENUF(&menus[i++], strsep(&token, "/"), token, tzone_fire);
-
-/*
- menus[i].prompt = strsep(&token, "/");
- menus[i].title = token;
- menus[i].fire = tzone_fire;
- i++;
-*/
}
screen_clear(MODULE);
dialog_menu("Timezone selection",
Modified: pcbsd-projects/txt-sysinstall/util.c
===================================================================
--- pcbsd-projects/txt-sysinstall/util.c 2010-07-15 20:57:41 UTC (rev 7221)
+++ pcbsd-projects/txt-sysinstall/util.c 2010-07-16 04:54:17 UTC (rev 7222)
@@ -27,8 +27,10 @@
*/
#include <sys/types.h>
+#include <sys/queue.h>
#include <sys/wait.h>
#include <err.h>
+#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -39,10 +41,16 @@
#include "txt-sysinstall.h"
+struct config {
+ char *key;
+ char *value;
+ STAILQ_ENTRY(config) entries;
+};
+STAILQ_HEAD(confighead, config) configlist;
+
void
screen_clear(const char *module)
{
-
dialog_clear();
mvprintw(0, 0, "%s installer >> %s", OSNAME, module);
}
@@ -87,6 +95,19 @@
return (len);
}
+char *
+safe_strdup(const char *str)
+{
+ size_t len;
+ char *copy;
+
+ len = safe_strlen(str) + 1;
+ copy = safe_malloc(len);
+ memcpy(copy, str, len);
+
+ return (copy);
+}
+
/*
* Run pc-sysinstall with the specified cmd. If the function
* returns non-NULL, it's up to the caller to free the buf.
@@ -121,7 +142,7 @@
end_dialog();
close(fd[0]);
close(fd[1]);
- errx(1, "pc-sysinstall not found");
+ return (status);
}
}
@@ -149,19 +170,56 @@
}
void
+sysinstall_init(void)
+{
+ STAILQ_INIT(&configlist);
+}
+
+void
+sysinstall_fini(void)
+{
+ struct config *c, *temp;
+
+ STAILQ_FOREACH_SAFE(c, &configlist, entries, temp) {
+ STAILQ_REMOVE(&configlist, c, config, entries);
+ free(c->key);
+ free(c->value);
+ free(c);
+ }
+}
+
+void
appendconfig(const char *key, const char *value)
{
+ struct config *c;
+
+ c = safe_malloc(sizeof(*c));
+ c->key = safe_strdup(key);
+ c->value = NULL;
+ if (value) {
+ c->value = safe_strdup(value);
+ }
+ STAILQ_INSERT_TAIL(&configlist, c, entries);
+}
+
+void
+save_config(void)
+{
FILE *fp;
+ struct config *c;
- fp = fopen("result.cfg", "a");
- if (!fp) {
+ if ((fp = fopen("result.cfg", "w")) == NULL) {
end_dialog();
err(1, "couldn't open config file\n");
return;
}
- fprintf(fp, "%s", key);
- if (value)
- fprintf(fp, "=%s", value);
- fprintf(fp, "\n");
+
+ STAILQ_FOREACH(c, &configlist, entries) {
+ fprintf(fp, "%s", c->key);
+ if (c->value)
+ fprintf(fp, "=%s", c->value);
+ fprintf(fp, "\n");
+ }
+
fclose(fp);
}
More information about the Commits
mailing list