From 903a64c87dffab61bdc15e7aed4127585635ca84 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Jan 2007 14:34:44 +0000 Subject: [PATCH] * Some things are best done in Perl. svn path=/nixos/trunk/; revision=7773 --- helpers/make-iso9660-image.nix | 8 ++++---- helpers/make-iso9660-image.sh | 22 +++++++++------------- helpers/paths-from-graph.pl | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 helpers/paths-from-graph.pl diff --git a/helpers/make-iso9660-image.nix b/helpers/make-iso9660-image.nix index 3cecb6106e5..c16d5413896 100644 --- a/helpers/make-iso9660-image.nix +++ b/helpers/make-iso9660-image.nix @@ -1,4 +1,4 @@ -{ stdenv, cdrtools +{ stdenv, perl, cdrtools # The file name of the resulting ISO image. , isoName ? "cd.iso" @@ -29,7 +29,7 @@ assert bootable -> bootImage != ""; stdenv.mkDerivation { name = "iso9660-image"; builder = ./make-iso9660-image.sh; - buildInputs = [cdrtools]; + buildInputs = [perl cdrtools]; inherit isoName bootable bootImage; # !!! should use XML. @@ -42,6 +42,6 @@ stdenv.mkDerivation { # For obtaining the closure of `storeContents'. exportReferencesGraph = - map (x: [("closure-" + baseNameOf x.symlink) x.object]) storeContents; - pathsFromGraph = ./paths-from-graph.sh; + map (x: [("closure-" + baseNameOf x.object) x.object]) storeContents; + pathsFromGraph = ./paths-from-graph.pl; } diff --git a/helpers/make-iso9660-image.sh b/helpers/make-iso9660-image.sh index 1fa04aef7b2..6ce205adc2a 100644 --- a/helpers/make-iso9660-image.sh +++ b/helpers/make-iso9660-image.sh @@ -12,28 +12,24 @@ if test -n "$bootable"; then fi +# Add the individual files. graftList= for ((i = 0; i < ${#targets_[@]}; i++)); do graftList="$graftList ${targets_[$i]}=$(readlink -f ${sources_[$i]})" done +# Add the closures of the top-level store objects. +storePaths=$(perl $pathsFromGraph closure-*) +for i in $storePaths; do + graftList="$graftList ${i:1}=$i" +done + + +# Add symlinks to the top-level store objects. for ((n = 0; n < ${#objects[*]}; n++)); do object=${objects[$n]} symlink=${symlinks[$n]} - - # Get the paths in the closure of `object'. - closure=closure-$(basename $symlink) - if ! test -e $closure; then - echo 'Your Nix installation is too old! Upgrade to nix-0.11pre7038 or newer.' - exit 1 - fi - storePaths=$($SHELL $pathsFromGraph $closure) - - for i in $storePaths; do - graftList="$graftList ${i:1}=$i" - done - if test "$symlink" != "none"; then mkdir -p $(dirname ./$symlink) ln -s $object ./$symlink diff --git a/helpers/paths-from-graph.pl b/helpers/paths-from-graph.pl new file mode 100644 index 00000000000..a4faa36d00f --- /dev/null +++ b/helpers/paths-from-graph.pl @@ -0,0 +1,26 @@ +use strict; + +my %storePaths; + +foreach my $graph (@ARGV) { + open GRAPH, "<$graph" or die; + + while () { + chomp; + my $storePath = "$_"; + $storePaths{$storePath} = 1; + + my $deriver = ; chomp $deriver; + my $count = ; chomp $count; + + for (my $i = 0; $i < $count; ++$i) { + my $ref = ; + } + } + + close GRAPH; +} + +foreach my $storePath (sort (keys %storePaths)) { + print "$storePath\n"; +}