summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-05-13 08:34:50 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-05-13 08:34:50 +0000
commite79950d93af06b735b86548120dc60b2c5be6ee0 (patch)
treecd0d96ad02a9febbbf7b00071c84d89adf81fdc0
parent29a2a329574efc2b945de3d9f2dc08803c6dafd9 (diff)
downloaddrakx-e79950d93af06b735b86548120dc60b2c5be6ee0.tar
drakx-e79950d93af06b735b86548120dc60b2c5be6ee0.tar.gz
drakx-e79950d93af06b735b86548120dc60b2c5be6ee0.tar.bz2
drakx-e79950d93af06b735b86548120dc60b2c5be6ee0.tar.xz
drakx-e79950d93af06b735b86548120dc60b2c5be6ee0.zip
instead of keeping stage1 (mostly as temporary space but with a fixed size, and for the background init),
exit the stage1 giving hand to stage2 in a tmpfs (same as what was done for Mandrakemove)
-rw-r--r--mdk-stage1/.cvsignore2
-rw-r--r--mdk-stage1/Makefile16
-rw-r--r--mdk-stage1/adsl.c2
-rw-r--r--mdk-stage1/cdrom.c2
-rw-r--r--mdk-stage1/config-stage1.h21
-rw-r--r--mdk-stage1/dhcp.c2
-rw-r--r--mdk-stage1/disk.c11
-rw-r--r--mdk-stage1/init.c1
-rw-r--r--mdk-stage1/log.c2
-rw-r--r--mdk-stage1/network.c8
-rw-r--r--mdk-stage1/stage1.c208
-rw-r--r--mdk-stage1/stage1.h2
-rw-r--r--mdk-stage1/tools.c31
-rw-r--r--mdk-stage1/tools.h2
-rw-r--r--perl-install/Makefile6
-rw-r--r--perl-install/install2.pm9
-rw-r--r--perl-install/share/devices18
-rw-r--r--perl-install/share/symlinks10
18 files changed, 191 insertions, 162 deletions
diff --git a/mdk-stage1/.cvsignore b/mdk-stage1/.cvsignore
index 4594eb719..46b9c94a0 100644
--- a/mdk-stage1/.cvsignore
+++ b/mdk-stage1/.cvsignore
@@ -1,5 +1,5 @@
init
-init-move
+init-stage2
stage1-full
stage1-cdrom
stage1-disk
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
index 76cd102a7..2e886c798 100644
--- a/mdk-stage1/Makefile
+++ b/mdk-stage1/Makefile
@@ -57,7 +57,11 @@ ifeq (i386, $(ARCH))
INITSRC = minilibc.c init.c
INIT_DEFS = -DINIT_HEADERS=\"minilibc.h\" -fno-builtin
INIT_DEFS_ADD = -DBINARY=\"/sbin/stage1\"
-INIT_DEFS_ADD_MANDRAKE_MOVE = -DBINARY=\"/usr/bin/runstage2.pl\"
+ifdef MOVE
+INIT_DEFS_ADD_STAGE2 = -DBINARY=\"/usr/bin/runstage2.pl\"
+else
+INIT_DEFS_ADD_STAGE2 = -DBINARY=\"/usr/bin/runinstall2\"
+endif
else
ifeq (x86_64, $(ARCH))
INITSRC = minilibc.c init.c
@@ -73,7 +77,7 @@ endif
endif
INITOBJS = $(subst .c,.o,$(INITSRC))
-INITOBJS-MANDRAKE_MOVE = $(subst .c,-MOVE.o,$(INITSRC))
+INITOBJS-STAGE2 = $(subst .c,-STAGE2.o,$(INITSRC))
#- frontends
@@ -159,7 +163,7 @@ endif
endif
-BINS = init stage1-full
+BINS = init init-stage2 stage1-full
ifeq (i386, $(ARCH))
BINS += stage1-cdrom stage1-network
@@ -202,7 +206,7 @@ init: $(INITOBJS) $(INIT_LIBC)
$(CC) $(LDFLAGS_INIT) -o $@ $^
$(STRIPCMD) $@
-init-move: $(INITOBJS-MANDRAKE_MOVE) $(INIT_LIBC)
+init-stage2: $(INITOBJS-STAGE2) $(INIT_LIBC)
$(CC) $(LDFLAGS_INIT) -o $@ $^
$(STRIPCMD) $@
@@ -222,8 +226,8 @@ stage1-full: $(STAGE1OBJS-FULL) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRON
$(INITOBJS): %.o: %.c
$(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD) -c $<
-$(INITOBJS-MANDRAKE_MOVE): %-MOVE.o: %.c
- $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD_MANDRAKE_MOVE) -c $< -o $@
+$(INITOBJS-STAGE2): %-STAGE2.o: %.c
+ $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD_STAGE2) -c $< -o $@
$(STAGE1OBJS-CDROM): %-CDROM.o: %.c
$(DIET) $(COMPILE) $(INCLUDES) $(CDROM_DEFS) -c $< -o $@
diff --git a/mdk-stage1/adsl.c b/mdk-stage1/adsl.c
index b3ed0f87e..bdbd06872 100644
--- a/mdk-stage1/adsl.c
+++ b/mdk-stage1/adsl.c
@@ -75,7 +75,7 @@ static enum return_type adsl_connect(char * net_device, char * username, char *
log_perror("could not set new controlling tty");
printf("\t(exec of pppd)\n");
- execve(pppd_launch[0], pppd_launch, grab_env());
+ execv(pppd_launch[0], pppd_launch);
log_message("execve of %s failed: %s", pppd_launch[0], strerror(errno));
exit(-1);
}
diff --git a/mdk-stage1/cdrom.c b/mdk-stage1/cdrom.c
index a6d0ab726..055200499 100644
--- a/mdk-stage1/cdrom.c
+++ b/mdk-stage1/cdrom.c
@@ -82,7 +82,7 @@ static enum return_type do_with_device(char * dev_name, char * dev_model)
if (IS_RESCUE)
umount(IMAGE_LOCATION);
- method_name = strdup("cdrom");
+ add_to_env("METHOD", "cdrom");
return RETURN_OK;
}
diff --git a/mdk-stage1/config-stage1.h b/mdk-stage1/config-stage1.h
index 5d42bab1a..d66fa25dc 100644
--- a/mdk-stage1/config-stage1.h
+++ b/mdk-stage1/config-stage1.h
@@ -29,23 +29,26 @@
#define LIVE_LOCATION "/Mandrake/mdkinst/"
#define RAMDISK_LOCATION "/Mandrake/base/"
-#define STAGE2_LOCATION "/tmp/stage2"
+#define SLASH_LOCATION "/sysroot"
+#define STAGE2_LOCATION SLASH_LOCATION "/tmp/stage2"
#ifdef MANDRAKE_MOVE
#define MEM_LIMIT_MOVE 120
#define DISTRIB_NAME "Mandrakemove"
-#define IMAGE_LOCATION "/sysroot/cdrom"
-#define IMAGE_LOCATION_REAL "/sysroot/image"
-#define SLASH_LOCATION "/sysroot"
+#define IMAGE_LOCATION SLASH_LOCATION "/cdrom"
+#define IMAGE_LOCATION_REAL SLASH_LOCATION "/image"
#define RAW_LOCATION_REL "/cdrom"
-#define LIVE_LOCATION_REL "/image"
-#define BOOT_LOCATION "/sysroot/image_boot"
-#define ALWAYS_LOCATION "/sysroot/image_always"
-#define TOTEM_LOCATION "/sysroot/image_totem"
+#define STAGE2_LOCATION_REL "/image"
+#define BOOT_LOCATION SLASH_LOCATION "/image_boot"
+#define ALWAYS_LOCATION SLASH_LOCATION "/image_always"
+#define TOTEM_LOCATION SLASH_LOCATION "/image_totem"
+
#else
+
#define DISTRIB_NAME "Mandrake Linux"
-#define IMAGE_LOCATION "/tmp/image"
+#define IMAGE_LOCATION SLASH_LOCATION "/tmp/image"
#define IMAGE_LOCATION_REAL "/tmp/image"
+#define STAGE2_LOCATION_REL "/tmp/stage2"
#endif
diff --git a/mdk-stage1/dhcp.c b/mdk-stage1/dhcp.c
index 3dbefa0bb..d55bc04dd 100644
--- a/mdk-stage1/dhcp.c
+++ b/mdk-stage1/dhcp.c
@@ -213,7 +213,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
if (breq->bootfile && strlen(breq->bootfile) > 0) {
if (IS_NETAUTO)
- stage2_kickstart = strdup(breq->bootfile);
+ add_to_env("KICKSTART", breq->bootfile);
else
log_message("warning: ignoring `bootfile' DHCP server parameter, since `netauto' boot parameter was not given; reboot with `linux netauto' (and anymore useful boot parameters) if you want `bootfile' to be used as a `auto_inst.cfg.pl' stage2 configuration file");
}
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index 3cd2da6a4..f6694dd68 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -205,11 +205,7 @@ static enum return_type try_with_device(char *dev_name)
static char ** answers_location = NULL;
char location_full[500];
-#ifndef MANDRAKE_MOVE
- char * disk_own_mount = "/tmp/hdimage";
-#else
char * disk_own_mount = SLASH_LOCATION "/tmp/hdimage";
-#endif
char * loopdev = NULL;
char * parts[50];
@@ -235,9 +231,6 @@ static enum return_type try_with_device(char *dev_name)
if (results != RETURN_OK)
return results;
}
-#ifdef MANDRAKE_MOVE
- mkdir (SLASH_LOCATION "/tmp", 0755);
-#endif
if (try_mount(choice, disk_own_mount)) {
stg1_error_message("I can't find a valid filesystem (tried: ext2, vfat, reiserfs).");
@@ -327,7 +320,7 @@ static enum return_type try_with_device(char *dev_name)
umount(disk_own_mount);
}
- method_name = strdup("disk");
+ add_to_env("METHOD", "disk");
return RETURN_OK;
}
@@ -447,7 +440,7 @@ process_recovery(void)
if (ramdisk_possible())
load_ramdisk(); /* if load of ramdisk failed, try to continue in live */
- method_name = strdup("disk");
+ add_to_env("METHOD", "disk");
return 1;
}
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
index 1125d2113..8d9035b33 100644
--- a/mdk-stage1/init.c
+++ b/mdk-stage1/init.c
@@ -322,6 +322,7 @@ void unmount_filesystems(void)
if (!strcmp(fs[numfs].fs, "nfs"))
disallow_eject = 1;
if (strcmp(fs[numfs].name, "/")
+ && !strstr(fs[numfs].dev, "ram")
&& strcmp(fs[numfs].name, "/dev")
&& strcmp(fs[numfs].name, "/sys")
&& strncmp(fs[numfs].name, "/proc", 5))
diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c
index e41653305..bae9e849e 100644
--- a/mdk-stage1/log.c
+++ b/mdk-stage1/log.c
@@ -77,7 +77,7 @@ void open_log(void)
{
if (!IS_TESTING) {
logtty = fopen("/dev/tty3", "w");
- logfile = fopen("/tmp/stage1.log", "w");
+ logfile = fopen(SLASH_LOCATION "/tmp/stage1.log", "w");
}
else
logfile = fopen("debug.log", "w");
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 13085cfcc..7cc30ff7f 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -693,7 +693,7 @@ enum return_type nfs_prepare(void)
if (IS_RESCUE)
umount(IMAGE_LOCATION);
- method_name = strdup("nfs");
+ add_to_env("METHOD", "nfs");
return RETURN_OK;
}
@@ -800,13 +800,13 @@ enum return_type ftp_prepare(void)
}
if (use_http_proxy) {
- method_name = strdup("http");
+ add_to_env("METHOD", "http");
sprintf(location_full, "ftp://%s%s", ftp_hostname, answers[1]);
add_to_env("URLPREFIX", location_full);
add_to_env("PROXY", answers[4]);
add_to_env("PROXYPORT", answers[5]);
} else {
- method_name = strdup("ftp");
+ add_to_env("METHOD", "ftp");
add_to_env("HOST", answers[0]);
add_to_env("PREFIX", answers[1]);
if (!streq(answers[2], "")) {
@@ -875,7 +875,7 @@ enum return_type http_prepare(void)
if (load_ramdisk_fd(fd, size) != RETURN_OK)
return RETURN_ERROR;
- method_name = strdup("http");
+ add_to_env("METHOD", "http");
sprintf(location_full, "http://%s%s", answers[0], answers[1]);
add_to_env("URLPREFIX", location_full);
if (!streq(answers[2], ""))
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 24ad55fbb..8306772b0 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -68,8 +68,6 @@ _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
/************************************************************
* globals */
-char * method_name;
-char * stage2_kickstart = NULL;
void fatal_error(char *msg)
@@ -93,6 +91,17 @@ void stg1_error_message(char *msg, ...)
va_end(args);
}
+void stg1_fatal_message(char *msg, ...)
+{
+ va_list args;
+ va_start(args, msg);
+ log_message("unsetting automatic");
+ unset_param(MODE_AUTOMATIC);
+ verror_message(msg, args);
+ va_end(args);
+ exit(1);
+}
+
void stg1_info_message(char *msg, ...)
{
va_list args;
@@ -139,7 +148,7 @@ static void spawn_shell(void)
if (ioctl(0, TIOCSCTTY, NULL))
log_perror("could not set new controlling tty");
- execve(shell_name[0], shell_name, grab_env());
+ execv(shell_name[0], shell_name);
log_message("execve of %s failed: %s", shell_name[0], strerror(errno));
exit(-1);
}
@@ -268,20 +277,21 @@ static void expert_third_party_modules(void)
#ifdef ENABLE_PCMCIA
-static void handle_pcmcia(char ** pcmcia_adapter)
+static void handle_pcmcia(void)
{
+ char * pcmcia_adapter;
if (kernel_version() == 2) {
stg1_error_message("We now use kernel pcmcia support and this won't work with a 2.2 kernel.");
return;
}
- *pcmcia_adapter = pcmcia_probe();
- if (!*pcmcia_adapter) {
+ pcmcia_adapter = pcmcia_probe();
+ if (!pcmcia_adapter) {
log_message("no pcmcia adapter found");
return;
}
my_insmod("pcmcia_core", ANY_DRIVER_TYPE, NULL, 0);
- my_insmod(*pcmcia_adapter, ANY_DRIVER_TYPE, NULL, 0);
+ my_insmod(pcmcia_adapter, ANY_DRIVER_TYPE, NULL, 0);
my_insmod("ds", ANY_DRIVER_TYPE, NULL, 0);
/* call to cardmgr takes time, let's use the wait message */
@@ -291,6 +301,8 @@ static void handle_pcmcia(char ** pcmcia_adapter)
if (IS_EXPERT)
expert_third_party_modules();
+
+ add_to_env("PCMCIA", pcmcia_adapter);
}
#endif
@@ -363,21 +375,47 @@ static void method_select_and_prepare(void)
return method_select_and_prepare();
}
-#ifdef MANDRAKE_MOVE
-int mandrake_move_pre(void)
+enum return_type create_initial_fs(char* symlinks, char* devices)
{
- log_message("move: creating %s directory and mounting as tmpfs", SLASH_LOCATION);
+ FILE *f;
+ char buf[5000];
- if (scall(mkdir(SLASH_LOCATION, 0755), "mkdir"))
+ if (scall(!(f = fopen(symlinks, "rb")), "fopen"))
return RETURN_ERROR;
+ while (fgets(buf, sizeof(buf), f)) {
+ char oldpath[500], newpath[500], newpathfinal[500];
+ buf[strlen(buf)-1] = '\0'; // trim \n
+ if (sscanf(buf, "%s %s", oldpath, newpath) != 2) {
+ sprintf(oldpath, "%s%s", STAGE2_LOCATION_REL, buf);
+ sprintf(newpathfinal, "%s%s", SLASH_LOCATION, buf);
+ } else {
+ sprintf(newpathfinal, "%s%s", SLASH_LOCATION, newpath);
+ }
+ log_message("creating symlink %s -> %s", oldpath, newpathfinal);
+ if (scall(symlink(oldpath, newpathfinal), "symlink"))
+ return RETURN_ERROR;
+ }
+ fclose(f);
- if (scall(mount("none", SLASH_LOCATION, "tmpfs", MS_MGC_VAL, NULL), "mount tmpfs"))
+ // need to create the few devices needed to start up stage2 in a decent manner, we can't symlink or they will keep CD busy
+ if (scall(mkdir(SLASH_LOCATION "/dev", 0755), "mkdir"))
return RETURN_ERROR;
-
+ if (scall(!(f = fopen(devices, "rb")), "fopen"))
+ return RETURN_ERROR;
+ while (fgets(buf, sizeof(buf), f)) {
+ char name[500], path[500], type;
+ int major, minor;
+ sscanf(buf, "%s %c %d %d", name, &type, &major, &minor);
+ sprintf(path, "%s%s", SLASH_LOCATION, name);
+ log_message("creating device %s %c %d %d", path, type, major, minor);
+ if (scall(mknod(path, (type == 'c' ? S_IFCHR : S_IFBLK) | 0600, makedev(major, minor)), "mknod"))
+ return RETURN_ERROR;
+ }
+ fclose(f);
return RETURN_OK;
}
-
+#ifdef MANDRAKE_MOVE
static enum return_type handle_clp(char* clp, char* live, char* location_live, char* location_mount, int* is_symlink, char* clp_tmpfs)
{
static int count = 0;
@@ -416,10 +454,6 @@ static enum return_type handle_clp(char* clp, char* live, char* location_live, c
int mandrake_move_post(void)
{
- FILE *f;
- char buf[5000];
- int fd;
- char rootdev[] = "0x0100";
int boot__real_is_symlink_to_raw = 0;
int always__real_is_symlink_to_raw = 0;
int totem__real_is_symlink_to_raw = 0;
@@ -445,19 +479,6 @@ int mandrake_move_post(void)
&main__real_is_symlink_to_raw, NULL) != RETURN_OK)
return RETURN_ERROR;
- if (scall(!(f = fopen(IMAGE_LOCATION_REAL "/move/symlinks", "rb")), "fopen[" IMAGE_LOCATION_REAL "/move/symlinks]"))
- return RETURN_ERROR;
- while (fgets(buf, sizeof(buf), f)) {
- char oldpath[500], newpath[500];
- buf[strlen(buf)-1] = '\0'; // trim \n
- sprintf(oldpath, "%s%s", LIVE_LOCATION_REL, buf);
- sprintf(newpath, "%s%s", SLASH_LOCATION, buf);
- log_message("move: creating symlink %s -> %s", oldpath, newpath);
- if (scall(symlink(oldpath, newpath), "symlink"))
- return RETURN_ERROR;
- }
- fclose(f);
-
// in case we didn't mount any clp, because gzloop.o is not available later in /lib/modules
my_insmod("gzloop", ANY_DRIVER_TYPE, NULL, 0);
@@ -467,25 +488,11 @@ int mandrake_move_post(void)
return RETURN_ERROR;
} else
// need a fallback in case we don't use image_totem.clp nor live_tree_totem, but we're in -u mode
- if (scall(symlink(LIVE_LOCATION_REL "/usr", SLASH_LOCATION "/usr"), "symlink"))
+ if (scall(symlink(STAGE2_LOCATION_REL "/usr", SLASH_LOCATION "/usr"), "symlink"))
return RETURN_ERROR;
- // need to create the few devices needed to start up stage2 in a decent manner, we can't symlink or they will keep CD busy
- // we need only the ones before mounting /dev as devfs
- if (scall(mkdir(SLASH_LOCATION "/dev", 0755), "mkdir"))
+ if (create_initial_fs(IMAGE_LOCATION_REAL "/move/symlinks", IMAGE_LOCATION_REAL "/move/devices") != RETURN_OK)
return RETURN_ERROR;
- if (scall(!(f = fopen(IMAGE_LOCATION_REAL "/move/devices", "rb")), "fopen"))
- return RETURN_ERROR;
- while (fgets(buf, sizeof(buf), f)) {
- char name[500], path[500], type;
- int major, minor;
- sscanf(buf, "%s %c %d %d", name, &type, &major, &minor);
- sprintf(path, "%s%s", SLASH_LOCATION, name);
- log_message("move: creating device %s %c %d %d", path, type, major, minor);
- if (scall(mknod(path, type == 'c' ? S_IFCHR : S_IFBLK, makedev(major, minor)), "mknod"))
- return RETURN_ERROR;
- }
- fclose(f);
if (boot__real_is_symlink_to_raw) {
if (scall(unlink(BOOT_LOCATION), "unlink"))
@@ -514,14 +521,19 @@ int mandrake_move_post(void)
if (scall(symlink(RAW_LOCATION_REL "/live_tree", IMAGE_LOCATION_REAL), "symlink"))
return RETURN_ERROR;
}
+ return RETURN_OK;
+}
+#endif
- mkdir(SLASH_LOCATION "/etc", 0755);
- copy_file("/etc/resolv.conf", SLASH_LOCATION "/etc/resolv.conf", NULL);
+int do_pivot_root(void)
+{
+ int fd;
+ char rootdev[] = "0x0100";
if (IS_DEBUGSTAGE1)
while (1);
- log_message("move: pivot_rooting");
+ log_message("pivot_rooting");
// trick so that kernel won't try to mount the root device when initrd exits
if (scall((fd = open("/proc/sys/kernel/real-root-dev", O_WRONLY)) < 0, "open"))
return RETURN_ERROR;
@@ -539,26 +551,62 @@ int mandrake_move_post(void)
return RETURN_OK;
}
+
+void finish_preparing(void)
+{
+ if (!IS_RESCUE) {
+#ifdef MANDRAKE_MOVE
+ if (mandrake_move_post() != RETURN_OK)
+ stg1_fatal_message("Fatal error when launching MandrakeMove.");
+#else
+ mkdir(SLASH_LOCATION "/etc", 0755);
+ mkdir(SLASH_LOCATION "/var", 0755);
+ /* STAGE2_LOCATION is wrong for live installs before pivot_root */
+ if ((!IS_RAMDISK && create_initial_fs(IMAGE_LOCATION LIVE_LOCATION "/usr/share/symlinks",
+ IMAGE_LOCATION LIVE_LOCATION "/usr/share/devices") != RETURN_OK)
+ || (IS_RAMDISK && create_initial_fs(STAGE2_LOCATION "/usr/share/symlinks",
+ STAGE2_LOCATION "/usr/share/devices") != RETURN_OK))
+ stg1_fatal_message("Fatal error finishing initialization.");
#endif
+
+ copy_file("/etc/resolv.conf", SLASH_LOCATION "/etc/resolv.conf", NULL);
+ mkdir(SLASH_LOCATION "/modules", 0755);
+ copy_file("/modules/modules.dep", SLASH_LOCATION "/modules/modules.dep", NULL);
+
+ umount("/tmp/tmpfs");
+ do_pivot_root();
+
+ if (file_size("/sbin/init") == -1)
+ stg1_fatal_message("Fatal error giving hand to second stage.");
+ }
+ if (shell_pid != 0) {
+ int fd;
+ kill(shell_pid, 9);
+ fd = open("/dev/tty2", O_RDWR);
+ write(fd, "Killed\n", 7);
+ close(fd);
+ }
+}
+
int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)), char **env)
{
- char ** argptr;
- char * stage2_args[30];
-#ifdef ENABLE_PCMCIA
- char * pcmcia_adapter = NULL;
-#endif
if (getpid() > 50)
set_param(MODE_TESTING);
+ else {
+ mkdir(SLASH_LOCATION, 0755);
+ if (scall(mount("none", SLASH_LOCATION, "tmpfs", MS_MGC_VAL, NULL), "mount tmpfs"))
+ fatal_error("Fatal error initializing.");
+ mkdir(SLASH_LOCATION "/tmp", 0755);
+ }
spawn_interactive();
open_log();
log_message("welcome to the " DISTRIB_NAME " install (mdk-stage1, version " VERSION " built " __DATE__ " " __TIME__")");
process_cmdline();
- handle_env(env);
#ifdef SPAWN_SHELL
spawn_shell();
#endif
@@ -579,7 +627,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
#ifdef ENABLE_PCMCIA
if (!IS_NOAUTO)
- handle_pcmcia(&pcmcia_adapter);
+ handle_pcmcia();
#endif
// load usb interface as soon as possible, helps usb mouse detection in stage2 */
@@ -600,8 +648,6 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
if (total_memory() < MEM_LIMIT_MOVE)
stg1_error_message(DISTRIB_NAME " typically needs more than %d Mbytes of memory (detected %d Mbytes). You may proceed, but the machine may crash or lock up for no apparent reason. Continue at your own risk. Alternatively, you may reboot your system now.",
MEM_LIMIT_MOVE, total_memory());
- if (mandrake_move_pre() != RETURN_OK)
- stg1_error_message("Fatal error when preparing Mandrakemove.");
#endif
#ifndef DISABLE_DISK
@@ -619,51 +665,13 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
if (interactive_pid != 0)
kill(interactive_pid, 9);
-#ifdef MANDRAKE_MOVE
- if (mandrake_move_post() != RETURN_OK)
- stg1_error_message("Fatal error when launching Mandrakemove.");
-#endif
-
- if (shell_pid != 0) {
- int fd;
- kill(shell_pid, 9);
- fd = open("/dev/tty2", O_RDWR);
- write(fd, "Killed\n", 7);
- close(fd);
- }
+ finish_preparing();
- umount("/tmp/tmpfs");
finish_frontend();
close_log();
-#ifndef MANDRAKE_MOVE
- if (IS_RESCUE)
-#endif
- return 66;
if (IS_TESTING)
return 0;
-
- argptr = stage2_args;
- *argptr++ = "/usr/bin/runinstall2";
- *argptr++ = "--method";
- *argptr++ = method_name;
-#ifdef ENABLE_PCMCIA
- if (pcmcia_adapter) {
- *argptr++ = "--pcmcia";
- *argptr++ = pcmcia_adapter;
- }
-#endif
- if (stage2_kickstart) {
- *argptr++ = "--kickstart";
- *argptr++ = stage2_kickstart;
- }
- *argptr++ = NULL;
-
- execve(stage2_args[0], stage2_args, grab_env());
-
- printf("error in exec of stage2 :-(\n");
- printf("trying to execute '/usr/bin/runinstall2' from the installation volume,\nthe following fatal error occurred\n");
- fatal_error(strerror(errno));
-
- return 0; /* shut up compiler (we can't get here anyway!) */
+ else
+ return 66;
}
diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h
index 926f84151..9bbc779fb 100644
--- a/mdk-stage1/stage1.h
+++ b/mdk-stage1/stage1.h
@@ -28,9 +28,7 @@
/* Some global stuff */
-extern char * method_name;
extern char * interactive_fifo;
-extern char * stage2_kickstart;
#define MODE_TESTING (1 << 0)
#define MODE_EXPERT (1 << 1)
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index dbbd45772..76a70dec0 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -410,31 +410,16 @@ void * memdup(void *src, size_t size)
}
-static char ** my_env = NULL;
-static int env_size = 0;
-
-void handle_env(char ** env)
-{
- char ** ptr = env;
- while (ptr && *ptr) {
- ptr++;
- env_size++;
- }
- my_env = malloc(sizeof(char *) * 100);
- memcpy(my_env, env, sizeof(char *) * (env_size+1));
-}
-
-char ** grab_env(void) {
- return my_env;
-}
-
void add_to_env(char * name, char * value)
{
- char tmp[500];
- sprintf(tmp, "%s=%s", name, value);
- my_env[env_size] = strdup(tmp);
- env_size++;
- my_env[env_size] = NULL;
+ FILE* fakeenv = fopen(SLASH_LOCATION "/tmp/env", "a");
+ if (fakeenv) {
+ char* e = asprintf_("%s=%s\n", name, value);
+ fwrite(e, 1, strlen(e), fakeenv);
+ free(e);
+ fclose(fakeenv);
+ } else
+ log_message("couldn't fopen to fake env");
}
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index 3b95a2f26..f183e0a1d 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -38,8 +38,6 @@ enum return_type load_ramdisk(void);
enum return_type load_ramdisk_fd(int ramdisk_fd, int size);
void * memdup(void *src, size_t size);
void add_to_env(char * name, char * value);
-void handle_env(char ** env);
-char ** grab_env(void);
char ** list_directory(char * direct);
int string_array_length(char ** a);
int kernel_version(void);
diff --git a/perl-install/Makefile b/perl-install/Makefile
index 612cf79d5..129063f7b 100644
--- a/perl-install/Makefile
+++ b/perl-install/Makefile
@@ -12,6 +12,8 @@ OTHERS = $(OTHERDIRS) $(OTHERFILES)
OTHERDIRS = tools/ddcprobe tools/serial_probe
OTHERFILES = tools/rpcinfo-flushed.c
+STAGE1 = ../mdk-stage1
+
.PHONY: all $(DIRS) install clean stage2 full_stage2
all: list_modules.pm TAGS $(DIRS)
@@ -172,7 +174,7 @@ endif
gzip -9f $(DEST)/usr/share/ldetect-lst/*
- cd share ; cp -a consolefonts $(DEST)/usr/share
+ cd share ; cp -a consolefonts devices symlinks $(DEST)/usr/share
-cd share ; cp -f *.png $(DEST)/usr/share
-cd pixmaps ; cp -af *.png *.xpm langs $(DEST)/usr/share ; rm -f $(DEST)/usr/share/wiz_*
unneeded=`perl -I. -Mlang -e 'lang::get_unneeded_png_lang_files'`; cd $(DEST)/usr/share; rm -f $$unneeded
@@ -193,6 +195,8 @@ ifeq (i386,$(ARCH))
../tools/patch_pcmcia_config.pl $(DEST)/etc/pcmcia/config ../kernel/all.modules/`cat ../kernel/all.kernels/.main`/modules.dep
endif
+ cp -f $(STAGE1)/init-stage2 $(DEST)/usr/bin/init
+
find $(DEST) -name CVS | xargs rm -rf
full_stage2:
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index c1a47d33d..814f38546 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -370,7 +370,11 @@ sub main {
$opt = '';
}
} $cmdline{$opt} = 1 if $opt;
-
+
+ #- from stage1
+ put_in_hash(\%ENV, { getVarsFromSh('/tmp/env') });
+ exists $ENV{$_} and $cmdline{lc($_)} = $ENV{$_} foreach qw(METHOD PCMCIA KICKSTART);
+
map_each {
my ($n, $v) = @_;
my $f = ${{
@@ -438,6 +442,9 @@ sub main {
move::init($o);
}
+ #- free up stage1 memory
+ eval { fs::umount($_) } foreach qw(/stage1/proc/bus/usb /stage1/proc /stage1);
+
$o->{prefix} = $::prefix = $::testing ? "/tmp/test-perl-install" : $::move ? "" : "/mnt";
mkdir $o->{prefix}, 0755;
devices::make("/dev/zero"); #- needed by ddcxinfos
diff --git a/perl-install/share/devices b/perl-install/share/devices
new file mode 100644
index 000000000..844070b2e
--- /dev/null
+++ b/perl-install/share/devices
@@ -0,0 +1,18 @@
+/dev/console c 5 1
+/dev/ttyS0 c 4 64
+/dev/null c1 3
+/dev/mem c 1 1
+/dev/tty0 c 4 0
+/dev/tty1 c 4 1
+/dev/tty2 c 4 2
+/dev/tty3 c 4 3
+/dev/tty4 c 4 4
+/dev/tty5 c 4 5
+/dev/tty6 c 4 6
+/dev/tty7 c 4 7
+/dev/tty8 c 4 8
+/dev/fb0 c 29 0
+/dev/loop3 b 7 3
+/dev/ram3 b 1 3
+/dev/fd0 b 2 0
+/dev/ram b 1 1
diff --git a/perl-install/share/symlinks b/perl-install/share/symlinks
new file mode 100644
index 000000000..d2db5f4b7
--- /dev/null
+++ b/perl-install/share/symlinks
@@ -0,0 +1,10 @@
+/usr/bin /sbin
+/sbin /bin
+/proc/mounts /etc/mtab
+/etc/protocols
+/etc/services
+/etc/group
+/etc/passwd
+/lib
+/usr
+/tmp /var/run