From 1691c6667326f5e3b9209444c38be28451f3820a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 4 Nov 2006 00:01:13 +0000 Subject: [PATCH] * Nix expression for stage 2. * Start stage 2 from stage 1. svn path=/nixu/trunk/; revision=6945 --- test/boot-stage-1-init.sh | 7 ++++++- test/boot-stage-2-init.sh | 31 +++++++++++++++++++++++++++++++ test/boot-stage-2.nix | 14 ++++++++++++++ test/rescue-system.nix | 10 +++++++++- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/boot-stage-2-init.sh create mode 100644 test/boot-stage-2.nix diff --git a/test/boot-stage-1-init.sh b/test/boot-stage-1-init.sh index f216f05e237..2100d864d04 100644 --- a/test/boot-stage-1-init.sh +++ b/test/boot-stage-1-init.sh @@ -36,5 +36,10 @@ mkdir /mnt mkdir /mnt/cdrom mount -o ro /dev/hdc /mnt/cdrom -# Start an interactive shell. +# Start stage 2. !!! We use chroot for now, but I guess that should +# be pivot_root or so. +chroot /mnt/cdrom /init + +# If starting stage 2 failed, start an interactive shell. +echo "Stage 2 failed, starting emergency shell..." exec @shell@ diff --git a/test/boot-stage-2-init.sh b/test/boot-stage-2-init.sh new file mode 100644 index 00000000000..4be4a29de2d --- /dev/null +++ b/test/boot-stage-2-init.sh @@ -0,0 +1,31 @@ +#! @shell@ + +# !!! copied from stage 1; remove duplication + +# Print a greeting. +echo +echo "<<< NixOS Stage 2 >>>" +echo + +# Set the PATH. +export PATH=/empty +for i in @path@; do + PATH=$PATH:$i/bin + if test -e $i/sbin; then + PATH=$PATH:$i/sbin + fi +done + +# Mount special file systems. +mkdir /etc # to shut up mount +touch /etc/fstab # idem +mkdir /proc +mount -t proc proc /proc +mkdir /sys +mount -t sysfs sys /sys + +# Create device nodes in /dev. +source @makeDevices@ + +# Start an interactive shell. +exec @shell@ diff --git a/test/boot-stage-2.nix b/test/boot-stage-2.nix new file mode 100644 index 00000000000..5605bd593a5 --- /dev/null +++ b/test/boot-stage-2.nix @@ -0,0 +1,14 @@ +{ genericSubstituter, shell, coreutils +, utillinux +}: + +genericSubstituter { + src = ./boot-stage-2-init.sh; + isExecutable = true; + inherit shell; + path = [ + coreutils + utillinux + ]; + makeDevices = ./make-devices.sh; +} diff --git a/test/rescue-system.nix b/test/rescue-system.nix index d87de72715e..b20a662c599 100644 --- a/test/rescue-system.nix +++ b/test/rescue-system.nix @@ -56,6 +56,14 @@ rec { }; + # The init script of boot stage 2, which is supposed to do + # everything else to bring up the system. + bootStage2 = import ./boot-stage-2.nix { + inherit (pkgs) genericSubstituter coreutils utillinux; + shell = pkgs.bash + "/bin/sh"; + }; + + # Create an ISO image containing the isolinux boot loader, the # kernel, and initrd produced above. rescueCD = import ./make-iso9660-image.nix { @@ -77,7 +85,7 @@ rec { } ]; - init = pkgs.bash + "/bin/sh"; + init = bootStage2; bootable = true; bootImage = "isolinux/isolinux.bin";