diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-13T18·58+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-13T18·58+0000 |
commit | 9c620e4afa03e63ddaff2979396144de8d9298a5 (patch) | |
tree | 7bfabf03cd1665a9049763b31ce42305d85af13e /scripts/nix-push.in | |
parent | 5304a1eb3a2bbcc379924d3f5a58b64ce77f4849 (diff) |
* Generate the scripts so that we can substitute the prefix
etc. correctly. * Fixed nix-switch.
Diffstat (limited to 'scripts/nix-push.in')
-rw-r--r-- | scripts/nix-push.in | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in new file mode 100644 index 000000000000..bf30f3a49d7f --- /dev/null +++ b/scripts/nix-push.in @@ -0,0 +1,70 @@ +#! /usr/bin/perl -w + +my @pushlist; + +foreach my $hash (@ARGV) { + + die unless $hash =~ /^([0-9a-z]{32})$/; + + # Get all paths referenced by the normalisation of the given + # fstate expression. + my @paths; + open PATHS, "nix -qrh $hash 2> /dev/null |" or die "nix -qrh"; + while (<PATHS>) { + chomp; + next unless /^\//; + push @paths, $_; + } + close PATHS; + + # For each path, create a Fix expression that turns the path into + # a Nix archive. + foreach my $path (@paths) { + + # Hash the path. + my $phash = `nix-hash $path`; + $? and die "nix-hash"; + chomp $phash; + die unless $phash =~ /^([0-9a-z]{32})$/; + + # Construct a name for the Nix archive. If the file is an + # fstate successor, encode this into the name. + my $name = $phash; + if ($path =~ /-s-([0-9a-z]{32}).nix$/) { + $name = "$name-s-$1"; + } + $name = $name . ".nar.bz2"; + + # Construct a Fix expression that creates a Nix archive. + my $fixexpr = + "App(IncludeFix(\"nar/nar.fix\"), " . + "[ (\"path\", Path(\"$path\", Hash(\"$phash\"), [Include(\"$hash\")]))" . + ", (\"name\", \"$name\")" . + "])"; + + my $fixfile = "/tmp/nix-push-tmp.fix"; + open FIX, ">$fixfile"; + print FIX $fixexpr; + close FIX; + + # Instantiate a Nix expression from the Fix expression. + my $nhash = `fix $fixfile`; + $? and die "instantiating Nix archive expression"; + chomp $nhash; + die unless $nhash =~ /^([0-9a-z]{32})$/; + + # Realise the Nix expression. + my $npath = `nix -qph $nhash 2> /dev/null`; + $? and die "creating Nix archive"; + chomp $npath; + + push @pushlist, $npath; + + print "$path -> $npath\n"; + } +} + +# Push the prebuilts to the server. !!! FIXME +if (scalar @pushlist > 0) { + system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/"; +} |