summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-12-11 17:10:17 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-12-11 17:10:17 +0000
commit7e1dcea7f367619fe2fca98d79087a0beed267b4 (patch)
treea0d1adc99d8253a9c2866272709dc1870935e6bd
parent75dbadee24b0bd6b738093b66f8415a630692671 (diff)
downloaddrakx-7e1dcea7f367619fe2fca98d79087a0beed267b4.tar
drakx-7e1dcea7f367619fe2fca98d79087a0beed267b4.tar.gz
drakx-7e1dcea7f367619fe2fca98d79087a0beed267b4.tar.bz2
drakx-7e1dcea7f367619fe2fca98d79087a0beed267b4.tar.xz
drakx-7e1dcea7f367619fe2fca98d79087a0beed267b4.zip
add stdio frontend (get rid of newt+slang -eq reducing binary by 80 kbytes) (40 kbytes for compressed binary)
-rw-r--r--mdk-stage1/Makefile21
-rw-r--r--mdk-stage1/frontend.h4
-rw-r--r--mdk-stage1/newt-frontend.c2
-rw-r--r--mdk-stage1/probing.c5
-rw-r--r--mdk-stage1/stdio-frontend.c172
5 files changed, 195 insertions, 9 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
index 793c707c7..1ce2e3eba 100644
--- a/mdk-stage1/Makefile
+++ b/mdk-stage1/Makefile
@@ -27,7 +27,7 @@ ARCH := $(patsubst sparc%,sparc,$(ARCH))
#- We can leave "-g" forever since stripping will remove everything
-CFLAGS = -Os -g -Wall -Werror # -fomit-frame-pointer
+CFLAGS = -Os -Wall -Werror -fomit-frame-pointer
INCLUDES = -I.
DEFS = -D_GNU_SOURCE=1 -DVERSION=\"$(VERSION)\"
@@ -40,10 +40,23 @@ INITSRC = minilibc.c init.c
INITOBJS = $(subst .c,.o,$(INITSRC))
+ #- frontend
+NEWT_FRONTEND_SRC = newt-frontend.c
+NEWT_FRONTEND_LIBS = /usr/lib/libnewt.a /usr/lib/libslang.a
+
+STDIO_FRONTEND_SRC = stdio-frontend.c
+STDIO_FRONTEND_LIBS =
+
+FRONTEND_OBJS = $(subst .c,.o,$(STDIO_FRONTEND_SRC))
+FRONTEND_LIBS = $(STDIO_FRONTEND_LIBS)
+
+
#- stage1 itself (minus stage1.c)
-STAGE1SRC = log.c tools.c modules.c probing.c newt-frontend.c cdrom.c disk.c network.c mount.c
+STAGE1SRC = log.c tools.c modules.c probing.c cdrom.c disk.c network.c mount.c
+
+STAGE1OBJS = $(subst .c,.o,$(STAGE1SRC)) $(FRONTEND_OBJS) insmod-busybox/libinsmod.a mar/libmar.a $(FRONTEND_LIBS) /usr/lib/libz.a
+
-STAGE1OBJS = $(subst .c,.o,$(STAGE1SRC)) insmod-busybox/libinsmod.a mar/libmar.a /usr/lib/libnewt.a /usr/lib/libslang.a /usr/lib/libz.a
ALLSRC = $(INITSRC) $(STAGE1SRC) stage1.c
@@ -118,7 +131,7 @@ clean:
@for n in $(DIRS); do \
(cd $$n; make clean) \
done
- rm -f *.o .depend *.rdz *.img $(BINS)
+ rm -f *.o .depend *.rdz *.img $(BINS) st1
deps:
$(CPP) $(CFLAGS) -DHAVE_CONFIG_H -M $(ALLSRC) > .depend
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
index 95f5fb58f..ae125fa27 100644
--- a/mdk-stage1/frontend.h
+++ b/mdk-stage1/frontend.h
@@ -24,8 +24,8 @@
void init_frontend(void);
void finish_frontend(void);
-void error_message(char *msg);
-void wait_message(char *msg, ...);
+void error_message(char *msg); /* blocking */
+void wait_message(char *msg, ...); /* non-blocking */
void remove_wait_message(void);
enum return_type ask_yes_no(char *msg);
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index 2114cbc70..fcaeabcb6 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -152,7 +152,7 @@ enum return_type ask_yes_no(char *msg)
{
int rc;
- rc = newtWinTernary("Please answer..", "Yes", "No", "Back", msg);
+ rc = newtWinTernary("Please answer...", "Yes", "No", "Back", msg);
if (rc == 1)
return RETURN_OK;
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 0a012ad95..e252194ba 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -47,9 +47,10 @@ static void pci_probing(enum driver_type type)
if (IS_EXPERT) {
error_message("You should be asked if you have some SCSI.");
} else {
- wait_message("Installing SCSI module..."); sleep(1);
+/* wait_message("Installing SCSI module...");
+ my_insmod("advansys");
remove_wait_message();
- }
+*/ }
}
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
new file mode 100644
index 000000000..e702a79a7
--- /dev/null
+++ b/mdk-stage1/stdio-frontend.c
@@ -0,0 +1,172 @@
+/*
+ * Guillaume Cottenceau (gc@mandrakesoft.com)
+ *
+ * Copyright 2000 MandrakeSoft
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * Portions from Erik Troan (ewt@redhat.com)
+ *
+ * Copyright 1996 Red Hat Software
+ *
+ */
+
+
+/*
+ * Each different frontend must implement all functions defined in frontend.h
+ */
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include "stage1.h"
+#include "log.h"
+#include "newt.h"
+
+#include "frontend.h"
+
+
+void init_frontend(void)
+{
+ printf("Welcome to Linux-Mandrake (" VERSION ") " __DATE__ " " __TIME__ "\n");
+}
+
+
+void finish_frontend(void)
+{
+}
+
+static char get_char_response(void)
+{
+ unsigned char cmd1, cmd2;
+
+ fflush(stdout);
+ if (read(0, &cmd1, 1) > 0) {
+ fcntl(0, F_SETFL, O_NONBLOCK);
+ while (read(0, &cmd2, 1) > 0);
+ fcntl(0, F_SETFL, 0);
+ }
+
+ return cmd1;
+}
+
+
+void error_message(char *msg)
+{
+ printf("Error! %s", msg);
+ get_char_response();
+ printf("\n");
+}
+
+void wait_message(char *msg, ...)
+{
+ va_list args;
+
+ printf("Please wait: ");
+ va_start(args, msg);
+ vprintf(msg, args);
+ va_end(args);
+
+ fflush(stdout);
+}
+
+void remove_wait_message(void)
+{
+ printf("\n");
+}
+
+
+enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+{
+ char ** sav_elems = elems;
+ int i, j;
+ unsigned char answ;
+
+ printf("> %s\n(0) Cancel\n", msg);
+ i = 1;
+ while (elems && *elems) {
+ printf("(%d) %s (%s)\n", i, *elems, *elems_comments);
+ i++;
+ elems++;
+ elems_comments++;
+ }
+
+ printf("? ");
+
+ answ = get_char_response();
+
+ j = answ - '0';
+
+ if (j == 0)
+ return RETURN_BACK;
+
+ if (j >= 1 && j < i) {
+ *choice = strdup(sav_elems[j-1]);
+ return RETURN_OK;
+ }
+
+ return RETURN_ERROR;
+}
+
+
+enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
+{
+ char ** sav_elems = elems;
+ int i, j;
+ unsigned char answ;
+
+ printf("> %s\n(0) Cancel\n", msg);
+ i = 1;
+ while (elems && *elems) {
+ printf("(%d) %s\n", i, *elems);
+ i++;
+ elems++;
+ }
+
+ printf("? ");
+
+ answ = get_char_response();
+
+ j = answ - '0';
+
+ if (j == 0)
+ return RETURN_BACK;
+
+ if (j >= 1 && j < i) {
+ *choice = strdup(sav_elems[j-1]);
+ return RETURN_OK;
+ }
+
+ return RETURN_ERROR;
+}
+
+
+enum return_type ask_yes_no(char *msg)
+{
+ unsigned char answ;
+ int j;
+
+ printf("> %s\n(0) Yes\n(1) No\n(2) Back\n? ", msg);
+
+ answ = get_char_response();
+
+ j = answ - '0';
+
+ if (j == 0)
+ return RETURN_OK;
+ else if (j == 2)
+ return RETURN_BACK;
+ else return RETURN_ERROR;
+}