From 78b2ed263ea9739f2813f62fa2e0a8fd93f91803 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 Nov 2006 14:13:21 +0000 Subject: [PATCH] * Use exportReferencesGraph everywhere. svn path=/nixu/trunk/; revision=7063 --- test/boot-environment.nix | 6 +++--- test/installer.nix | 11 +++-------- test/installer.sh | 11 +---------- test/make-initrd.nix | 23 ++++++++++++++--------- test/make-initrd.sh | 13 +++++++------ test/make-iso9660-image.nix | 12 +++++++++--- test/make-iso9660-image.sh | 6 ++---- test/paths-from-graph.sh | 10 ++++++++++ test/rescue-cd.nix | 2 +- 9 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 test/paths-from-graph.sh diff --git a/test/boot-environment.nix b/test/boot-environment.nix index b2050fb14aee..2dc1445e9f97 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -62,15 +62,15 @@ rec { # The closure of the init script of boot stage 1 is what we put in # the initial RAM disk. initialRamdisk = import ./make-initrd.nix { - inherit (pkgs) stdenv cpio nix; - packages = []; + inherit (pkgs) stdenv cpio; init = bootStage1; }; # The installer. nixosInstaller = import ./installer.nix { - inherit (pkgs) stdenv genericSubstituter nix; + inherit (pkgs) stdenv genericSubstituter; + nix = pkgs.nixUnstable; # needs the exportReferencesGraph feature shell = pkgs.bash + "/bin/sh"; }; diff --git a/test/installer.nix b/test/installer.nix index 2f8963a443b2..44080b86a85e 100644 --- a/test/installer.nix +++ b/test/installer.nix @@ -7,16 +7,11 @@ genericSubstituter { isExecutable = true; inherit shell nix; + pathsFromGraph = ./paths-from-graph.sh; + nixClosure = stdenv.mkDerivation { name = "closure"; exportReferencesGraph = ["refs" nix]; - builder = builtins.toFile "builder.sh" " - source $stdenv/setup - if ! test -e refs; then - echo 'Your Nix installation is too old!' - exit 1 - fi - cp refs $out - "; + builder = builtins.toFile "builder.sh" "source $stdenv/setup; cp refs $out"; }; } diff --git a/test/installer.sh b/test/installer.sh index 4abad8e38409..be20b3095b8c 100644 --- a/test/installer.sh +++ b/test/installer.sh @@ -74,16 +74,7 @@ mkdir -m 0755 -p \ # Get the store paths to copy from the references graph. -storePaths="" -while read storePath; do - storePaths="$storePaths $storePath" - read deriver - read count - for ((i = 0; i < $count; i++)); do - read ref - done -done < @nixClosure@ - +storePaths=$(@shell@ @pathsFromGraph@ @nixClosure@) # Copy Nix to the Nix store on the target device. echo "copying Nix to $targetDevice...." diff --git a/test/make-initrd.nix b/test/make-initrd.nix index 91722b966022..2fb52f121fb8 100644 --- a/test/make-initrd.nix +++ b/test/make-initrd.nix @@ -1,20 +1,25 @@ -# Create an initial ramdisk containing the specified set of packages. -# An initial ramdisk is used during the initial stages of booting a -# Linux system. It is loaded by the boot loader along with the kernel -# image. It's supposed to contain everything (such as kernel modules) -# necessary to allow us to mount the root file system. Once the root -# file system is mounted, the `real' boot script can be called. +# Create an initial ramdisk containing the closure of the specified +# `init' package. An initial ramdisk is used during the initial +# stages of booting a Linux system. It is loaded by the boot loader +# along with the kernel image. It's supposed to contain everything +# (such as kernel modules) necessary to allow us to mount the root +# file system. Once the root file system is mounted, the `real' boot +# script can be called. # # An initrd is really just a gzipped cpio archive. # # A symlink `/init' is made to the store path passed in the `init' # argument. -{stdenv, cpio, packages, init, nix}: +{stdenv, cpio, init}: stdenv.mkDerivation { name = "initrd"; builder = ./make-initrd.sh; - buildInputs = [cpio nix]; - inherit packages init; + buildInputs = [cpio]; + inherit init; + + # For obtaining the closure of `init'. + exportReferencesGraph = ["init-closure" init]; + pathsFromGraph = ./paths-from-graph.sh; } diff --git a/test/make-initrd.sh b/test/make-initrd.sh index 5da23533febd..ea2ca5819a66 100644 --- a/test/make-initrd.sh +++ b/test/make-initrd.sh @@ -2,17 +2,18 @@ source $stdenv/setup set -o pipefail -# Get the paths in the closure of `packages'. Unfortunately, the only -# way to get the closure is to call Nix, which is strictly speaking -# forbidden. But we do it anyway. In time, we should add a feature -# to Nix to let Nix pass closures to builders. -packagesClosure=$(nix-store -qR $packages $init) +# Get the paths in the closure of `init'. +if ! test -e ./init-closure; then + echo 'Your Nix installation is too old! Upgrade to nix-0.11pre7038 or newer.' + exit 1 +fi +storePaths=$($SHELL $pathsFromGraph ./init-closure) # Paths in cpio archives *must* be relative, otherwise the kernel # won't unpack 'em. mkdir root cd root -cp -prd --parents $packagesClosure . +cp -prd --parents $storePaths . # Put the closure in a gzipped cpio archive. ensureDir $out diff --git a/test/make-iso9660-image.nix b/test/make-iso9660-image.nix index 861b229b8a4d..e98de8ffcb44 100644 --- a/test/make-iso9660-image.nix +++ b/test/make-iso9660-image.nix @@ -1,4 +1,4 @@ -{ stdenv, cdrtools, nix +{ stdenv, cdrtools # The file name of the resulting ISO image. , isoName ? "cd.iso" @@ -9,9 +9,11 @@ # grafted in the file system at path `target'. contents +/* , # In addition to `contents', the closure of the store paths listed # in `packages' are also placed in the file system. packages ? [] +*/ , # `init' should be a store path, the closure of which is added to # the image, just like `packages'. However, in addition, a symlink @@ -31,8 +33,12 @@ assert bootable -> bootImage != ""; stdenv.mkDerivation { name = "iso9660-image"; builder = ./make-iso9660-image.sh; - buildInputs = [cdrtools nix]; - inherit isoName packages init bootable bootImage; + buildInputs = [cdrtools]; + inherit isoName init bootable bootImage; sources = map ({source, target}: source) contents; targets = map ({source, target}: target) contents; + + # For obtaining the closure of `init'. + exportReferencesGraph = ["init-closure" init]; + pathsFromGraph = ./paths-from-graph.sh; } diff --git a/test/make-iso9660-image.sh b/test/make-iso9660-image.sh index 774fbb8a90ec..9a8bef7416d2 100644 --- a/test/make-iso9660-image.sh +++ b/test/make-iso9660-image.sh @@ -11,11 +11,9 @@ for ((i = 0; i < ${#targets_[@]}; i++)); do graftList="$graftList ${targets_[$i]}=$(readlink -f ${sources_[$i]})" done -# !!! Just as with make-initrd.nix, the call to Nix here needs to be -# fixed. -packagesClosure=$(nix-store -qR $packages $init) +storePaths=$($SHELL $pathsFromGraph ./init-closure) -for i in $packagesClosure; do +for i in $storePaths; do graftList="$graftList ${i:1}=$i" done diff --git a/test/paths-from-graph.sh b/test/paths-from-graph.sh new file mode 100644 index 000000000000..4a134cb3165f --- /dev/null +++ b/test/paths-from-graph.sh @@ -0,0 +1,10 @@ +graph="$1" + +while read storePath; do + echo $storePath + read deriver + read count + for ((i = 0; i < $count; i++)); do + read ref + done +done < $graph diff --git a/test/rescue-cd.nix b/test/rescue-cd.nix index 70c44ca2382b..da9e4cd3f3bf 100644 --- a/test/rescue-cd.nix +++ b/test/rescue-cd.nix @@ -36,7 +36,7 @@ rec { # kernel, the initrd produced above, and the closure of the stage 2 # init. rescueCD = import ./make-iso9660-image.nix { - inherit (pkgs) stdenv cdrtools nix; + inherit (pkgs) stdenv cdrtools; isoName = "nixos.iso"; contents = [