summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-12-08 19:26:57 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-12-08 19:26:57 +0000
commit2c34d1a1a491861b68b76d6dbb449771d1cf114c (patch)
treebd06ff016d5417ef10ca6c67432622dd7ee8afc3 /mdk-stage1
parent28b12d4a72442d2a13b42460f93eb64d8856ae41 (diff)
downloaddrakx-2c34d1a1a491861b68b76d6dbb449771d1cf114c.tar
drakx-2c34d1a1a491861b68b76d6dbb449771d1cf114c.tar.gz
drakx-2c34d1a1a491861b68b76d6dbb449771d1cf114c.tar.bz2
drakx-2c34d1a1a491861b68b76d6dbb449771d1cf114c.tar.xz
drakx-2c34d1a1a491861b68b76d6dbb449771d1cf114c.zip
mdk-stage1 can now run the Install from CDROM
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/Makefile2
-rw-r--r--mdk-stage1/cdrom.c38
-rw-r--r--mdk-stage1/frontend.h1
-rw-r--r--mdk-stage1/log.c9
-rw-r--r--mdk-stage1/log.h2
-rw-r--r--mdk-stage1/mount.c68
-rw-r--r--mdk-stage1/mount.h27
-rw-r--r--mdk-stage1/newt-frontend.c13
-rw-r--r--mdk-stage1/probing.c1
-rw-r--r--mdk-stage1/stage1-data/stage1-with-sash.tar.bz2bin345061 -> 346027 bytes
-rw-r--r--mdk-stage1/stage1.c29
-rw-r--r--mdk-stage1/stage1.h3
12 files changed, 178 insertions, 15 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
index beefda163..7e02acb78 100644
--- a/mdk-stage1/Makefile
+++ b/mdk-stage1/Makefile
@@ -41,7 +41,7 @@ INITOBJS = $(subst .c,.o,$(INITSRC))
#- stage1 itself (minus stage1.c)
-STAGE1SRC = log.c tools.c modules.c probing.c newt-frontend.c cdrom.c disk.c network.c
+STAGE1SRC = log.c tools.c modules.c probing.c newt-frontend.c cdrom.c disk.c network.c mount.c
STAGE1OBJS = $(subst .c,.o,$(STAGE1SRC)) insmod-busybox/libinsmod.a mar/libmar.a /usr/lib/libnewt.a /usr/lib/libslang.a /usr/lib/libz.a
diff --git a/mdk-stage1/cdrom.c b/mdk-stage1/cdrom.c
index e794dc9f5..1ac84979c 100644
--- a/mdk-stage1/cdrom.c
+++ b/mdk-stage1/cdrom.c
@@ -21,20 +21,48 @@
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
+#include <sys/mount.h>
#include "stage1.h"
#include "frontend.h"
#include "modules.h"
#include "probing.h"
#include "log.h"
+#include "mount.h"
#include "cdrom.h"
+
+
static enum return_type try_with_device(char *dev_name)
{
- log_message("with dev %s", dev_name);
+ char device_fullname[50];
- error_message("Should be trying with sucking device.");
+ strcpy(device_fullname, "/dev/");
+ strcat(device_fullname, dev_name);
+ if (my_mount(device_fullname, "/tmp/image", "iso9660") == -1) {
+ enum return_type results;
+ results = ask_yes_no("I can't access a CDROM disc in your drive.\nRetry?");
+ if (results == RETURN_OK)
+ return try_with_device(dev_name);
+ return results;
+ }
+
+ if (access("/tmp/image/Mandrake", R_OK)) {
+ enum return_type results;
+ umount("/tmp/image");
+ results = ask_yes_no("That CDROM disc does not seem to be a Linux-Mandrake Installation CDROM.\nRetry with another disc?");
+ if (results == RETURN_OK)
+ return try_with_device(dev_name);
+ return results;
+ }
+
+ log_message("found a Linux-Mandrake CDROM, good news!");
+/*
+ if (special_stage2 || total_memory() > 52 * 1024) loadMdkinstStage2();
+ if (rescue) umount("/tmp/rhimage");
+*/
return RETURN_OK;
}
@@ -50,10 +78,11 @@ enum return_type cdrom_prepare(void)
my_insmod("isofs");
medias = get_medias(CDROM, QUERY_NAME);
+ medias_models = get_medias(CDROM, QUERY_MODEL);
ptr = medias;
while (ptr && *ptr) {
- log_message("found CDROM %s", *ptr);
+ log_message("have CDROM %s", *ptr);
count++;
ptr++;
}
@@ -67,6 +96,7 @@ enum return_type cdrom_prepare(void)
}
if (count == 1) {
+ log_message("Only one CDROM detected: %s (%s)", *medias, *medias_models);
results = try_with_device(*medias);
if (results == RETURN_OK)
return RETURN_OK;
@@ -76,8 +106,6 @@ enum return_type cdrom_prepare(void)
return cdrom_prepare();
}
- medias_models = get_medias(CDROM, QUERY_MODEL);
-
results = ask_from_list_comments("Please choose the CDROM drive to use for the installation.", medias, medias_models, &choice);
if (results != RETURN_OK)
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
index 27b858a51..95f5fb58f 100644
--- a/mdk-stage1/frontend.h
+++ b/mdk-stage1/frontend.h
@@ -28,6 +28,7 @@ void error_message(char *msg);
void wait_message(char *msg, ...);
void remove_wait_message(void);
+enum return_type ask_yes_no(char *msg);
enum return_type ask_from_list(char *msg, char ** elems, char ** choice);
enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice);
diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c
index 7536d0a08..173ebe520 100644
--- a/mdk-stage1/log.c
+++ b/mdk-stage1/log.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <time.h>
#include <errno.h>
+#include "stage1.h"
#include "log.h"
@@ -68,9 +69,9 @@ void log_perror(char *msg)
}
-void open_log(int testing)
+void open_log(void)
{
- if (!testing) {
+ if (!IS_TESTING) {
logfile = fopen("/dev/tty3", "w");
if (!logfile)
logfile = fopen("/tmp/install.log", "a");
@@ -81,6 +82,8 @@ void open_log(int testing)
void close_log(void)
{
- if (logfile)
+ if (logfile) {
+ log_message("stage1: disconnecting life support systems");
fclose(logfile);
+ }
}
diff --git a/mdk-stage1/log.h b/mdk-stage1/log.h
index 9be73e83c..65e0a2416 100644
--- a/mdk-stage1/log.h
+++ b/mdk-stage1/log.h
@@ -29,7 +29,7 @@ void log_message(const char * s, ...);
void vlog_message(const char * s, va_list args);
void vlog_message_nobs(const char * s, va_list args);
void log_perror(char *msg);
-void open_log(int useLocal);
+void open_log(void);
void close_log(void);
#endif
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
new file mode 100644
index 000000000..9a5dfca55
--- /dev/null
+++ b/mdk-stage1/mount.c
@@ -0,0 +1,68 @@
+/*
+ * 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
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "log.h"
+
+#include "mount.h"
+
+
+int my_mount(char *dev, char *location, char *fs)
+{
+ unsigned long flags;
+ char * opts = NULL;
+ struct stat buf;
+
+ log_message("mounting %s on %s as type %s", dev, location, fs);
+
+ if (stat(location, &buf)) {
+ log_message("creating dir %s", location);
+ if (mkdir(location, 0755)) {
+ log_message("could not create location dir");
+ return -1;
+ }
+ } else if (!S_ISDIR(buf.st_mode)) {
+ log_message("not a dir %s, will unlink and mkdir", location);
+ if (unlink(location)) {
+ log_message("could not unlink %s", location);
+ return -1;
+ }
+ if (mkdir(location, 0755)) {
+ log_message("could not create location dir");
+ return -1;
+ }
+ }
+
+ flags = MS_MGC_VAL;
+
+ if (!strcmp(fs, "vfat"))
+ opts = "check=relaxed";
+
+ if (!strcmp(fs, "iso9660"))
+ flags |= MS_RDONLY;
+
+ return mount(dev, location, fs, flags, opts);
+}
diff --git a/mdk-stage1/mount.h b/mdk-stage1/mount.h
new file mode 100644
index 000000000..6ab4da559
--- /dev/null
+++ b/mdk-stage1/mount.h
@@ -0,0 +1,27 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _MOUNT_H_
+#define _MOUNT_H_
+
+int my_mount(char *dev, char *location, char *fs);
+
+#endif
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index 2c7e5434b..9321108d6 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -147,3 +147,16 @@ enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
return RETURN_OK;
}
+
+enum return_type ask_yes_no(char *msg)
+{
+ int rc;
+
+ rc = newtWinTernary("Please answer..", "Yes", "No", "Back", msg);
+
+ if (rc == 1)
+ return RETURN_OK;
+ else if (rc == 3)
+ return RETURN_BACK;
+ else return RETURN_ERROR;
+}
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 29ffdcd7c..e2bd61aae 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -48,7 +48,6 @@ static void pci_probing(enum driver_type type)
error_message("You should be asked if you have some SCSI.");
} else {
wait_message("Installing SCSI module...");
- my_insmod("advansys");
remove_wait_message();
}
}
diff --git a/mdk-stage1/stage1-data/stage1-with-sash.tar.bz2 b/mdk-stage1/stage1-data/stage1-with-sash.tar.bz2
index 1398f0146..52c15a238 100644
--- a/mdk-stage1/stage1-data/stage1-with-sash.tar.bz2
+++ b/mdk-stage1/stage1-data/stage1-with-sash.tar.bz2
Binary files differ
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 16d896f3b..f984b3058 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -46,8 +46,9 @@
/* globals */
-int stage1_mode = 0;
struct cmdline_elem params[500];
+int stage1_mode = 0;
+char * method_name;
void fatal_error(char *msg)
@@ -200,11 +201,14 @@ enum return_type method_select_and_prepare(void)
int main(int argc, char **argv)
{
enum return_type ret;
+ char ** argptr;
+ char * stage2_args[30];
+
if (getpid() > 50)
stage1_mode |= MODE_TESTING;
- open_log(IS_TESTING);
+ open_log();
log_message("welcome to the Linux-Mandrake install (stage1, version " VERSION " built " __DATE__ " " __TIME__")");
@@ -224,10 +228,27 @@ int main(int argc, char **argv)
ret = method_select_and_prepare();
finish_frontend();
- close_log();
if (ret == RETURN_ERROR)
fatal_error("could not select an installation method");
- return 0;
+ if (!IS_LIVE) {
+ if (symlink("/tmp/image/Mandrake/mdkinst", "/tmp/stage2") != 0)
+ fatal_error("symlink to /tmp/stage2 failed");
+ }
+
+ close_log();
+
+ argptr = stage2_args;
+ *argptr++ = "/usr/bin/runinstall2";
+ *argptr++ = "--method";
+ *argptr++ = method_name;
+ *argptr++ = NULL;
+
+ execv(stage2_args[0], stage2_args);
+
+ printf("error in exec of stage2 :-(");
+ fatal_error(strerror(errno));
+
+ return 0; /* shut up compiler (we can't get here) */
}
diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h
index 108fe14aa..2f193a065 100644
--- a/mdk-stage1/stage1.h
+++ b/mdk-stage1/stage1.h
@@ -37,6 +37,7 @@ extern struct cmdline_elem params[500];
enum return_type { RETURN_OK, RETURN_BACK, RETURN_ERROR };
extern int stage1_mode;
+extern char * method_name;
#define MODE_TESTING (1 << 0)
#define MODE_EXPERT (1 << 1)
@@ -45,6 +46,7 @@ extern int stage1_mode;
#define MODE_KICKSTART (1 << 4)
#define MODE_PCMCIA (1 << 5)
#define MODE_CDROM (1 << 6)
+#define MODE_LIVE (1 << 7)
#define IS_TESTING ((stage1_mode) & MODE_TESTING)
#define IS_EXPERT ((stage1_mode) & MODE_EXPERT)
@@ -53,6 +55,7 @@ extern int stage1_mode;
#define IS_KICKSTART ((stage1_mode) & MODE_KICKSTART)
#define IS_PCMCIA ((stage1_mode) & MODE_PCMCIA)
#define IS_CDROM ((stage1_mode) & MODE_CDROM)
+#define IS_LIVE ((stage1_mode) & MODE_LIVE)
void fatal_error(char *msg);