From 14cc7b88289ce90470f9b5556707e9cd2becb519 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Nov 2006 23:41:57 +0000 Subject: [PATCH] * Support adding the closure of a set of store paths to the ISO image (along with an /init symlink for stage 2 of the boot process). svn path=/nixu/trunk/; revision=6944 --- test/make-iso9660-image.nix | 14 ++++++++++++-- test/make-iso9660-image.sh | 23 ++++++++++++++++++++++- test/rescue-system.nix | 2 ++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/test/make-iso9660-image.nix b/test/make-iso9660-image.nix index 976f7047fd4..f08aac3abc5 100644 --- a/test/make-iso9660-image.nix +++ b/test/make-iso9660-image.nix @@ -9,6 +9,15 @@ # 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 + # `/init' to `init' will be created. + init ? null + # Whether this should be an El-Torito bootable CD. , bootable ? false @@ -23,6 +32,7 @@ stdenv.mkDerivation { name = "iso9660-image"; builder = ./make-iso9660-image.sh; buildInputs = [cdrtools]; - inherit isoName bootable bootImage; - graftList = map ({source, target}: target + "=" + source) contents; + inherit isoName packages init bootable bootImage; + sources = map ({source, target}: source) contents; + targets = map ({source, target}: target) contents; } diff --git a/test/make-iso9660-image.sh b/test/make-iso9660-image.sh index 7e9017f41a1..a2d98044c13 100644 --- a/test/make-iso9660-image.sh +++ b/test/make-iso9660-image.sh @@ -6,5 +6,26 @@ if test -n "$bootable"; then bootFlags="-b $bootImage -c boot.cat -no-emul-boot -boot-load-size 4" fi +graftList= +sources_=($sources) +targets_=($targets) +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/bin/nix-store -qR $packages $init) + +for i in $packagesClosure; do + graftList="$graftList ${i:1}=$i" +done + +if test -n "$init"; then + ln -s $init init + graftList="$graftList init=init" +fi + # !!! -f is a quick hack. -mkisofs -r -J -f -o $out/$isoName $bootFlags -graft-points $graftList +mkisofs -r -J -o $out/$isoName $bootFlags \ + -graft-points $graftList diff --git a/test/rescue-system.nix b/test/rescue-system.nix index 5e1e47a112f..d87de72715e 100644 --- a/test/rescue-system.nix +++ b/test/rescue-system.nix @@ -76,6 +76,8 @@ rec { target = "isolinux/initrd"; } ]; + + init = pkgs.bash + "/bin/sh"; bootable = true; bootImage = "isolinux/isolinux.bin";