aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2006-11-24 00:04:29 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2006-11-24 00:04:29 +0000
commit2cccff268df477df673880415a250eae5c816b26 (patch)
tree66eb831568b74428d1d83522db6b94420160b2b8
parent1fb01e46c594282eb3ecc797883dda4018c355a5 (diff)
* Pass the path of the stage 2 init script to stage 1 init through the
kernel command line, instead of having a /init symlink. This allows us to switch between configurations. * Some debug support: adding `debug' to the kernel command line gives a stage 1 shell. svn path=/nixu/trunk/; revision=7107
Diffstat (limited to '')
-rw-r--r--test/README5
-rw-r--r--test/boot-stage-1-init.sh26
-rw-r--r--test/system-configuration.nix2
-rw-r--r--test/system-configuration.sh6
4 files changed, 33 insertions, 6 deletions
diff --git a/test/README b/test/README
index 701faaf22fa..e2f76b08301 100644
--- a/test/README
+++ b/test/README
@@ -1,3 +1,8 @@
+To get a Stage 1 shell:
+
+Add "debug1" to the kernel command line.
+
+
Switching to maintenance mode:
$ shutdown now
diff --git a/test/boot-stage-1-init.sh b/test/boot-stage-1-init.sh
index 3e93571ebda..3d115760e06 100644
--- a/test/boot-stage-1-init.sh
+++ b/test/boot-stage-1-init.sh
@@ -32,6 +32,25 @@ mkdir /sys
mount -t sysfs none /sys
+# Process the kernel command line.
+stage2Init=@stage2Init@
+for o in $(cat /proc/cmdline); do
+ case $o in
+ init=*)
+ set -- $(IFS==; echo $o)
+ stage2Init=$2
+ ;;
+ debugtrace)
+ # Show each command.
+ set -x
+ ;;
+ debug1)
+ fail
+ ;;
+ esac
+done
+
+
# Create device nodes in /dev.
source @makeDevices@
@@ -85,6 +104,7 @@ else
fi
+
# Start stage 2.
# !!! Note: we can't use pivot_root here (the kernel gods have
# decreed), but we could use run-init from klibc, which deletes all
@@ -94,6 +114,10 @@ mount --move . /
umount /proc # cleanup
umount /sys
-exec chroot . @stage2Init@
+echo "INIT = $stage2Init"
+
+if test -z "$stage2Init"; then fail; fi
+
+exec chroot . $stage2Init
fail
diff --git a/test/system-configuration.nix b/test/system-configuration.nix
index 8675cf5d71b..b357683f446 100644
--- a/test/system-configuration.nix
+++ b/test/system-configuration.nix
@@ -11,7 +11,7 @@ let
bootEnv = import ./boot-environment.nix {
autoDetectRootDevice = false;
inherit rootDevice;
- stage2Init = "/init"; # !!! should be bootEnv.bootStage2;
+ stage2Init = ""; # Passed on the command line via Grub.
readOnlyRoot = false;
};
diff --git a/test/system-configuration.sh b/test/system-configuration.sh
index 653774cc5cc..4a803d81e4b 100644
--- a/test/system-configuration.sh
+++ b/test/system-configuration.sh
@@ -6,9 +6,8 @@ ln -s $kernel $out/kernel
ln -s $grub $out/grub
cat > $out/menu.lst << GRUBEND
-title NixOS
- kernel $kernel selinux=0 apm=on acpi=on
- initrd $initrd
+kernel $kernel selinux=0 apm=on acpi=on init=$bootStage2
+initrd $initrd
GRUBEND
ensureDir $out/bin
@@ -20,7 +19,6 @@ export PATH=$coreutils/bin:$gnused/bin:$gnugrep/bin:$diffutils/bin
if test -n "$grubDevice"; then
$grubMenuBuilder $out
$grub/sbin/grub-install "$grubDevice" --no-floppy --recheck
- ln -sf $bootStage2 /init # !!! fix?
fi
EOF