* Syntax fixes.

* When pushing, put the hash in the file name so that the 
  client can verify (proof-carrying file names?).
This commit is contained in:
Eelco Dolstra 2003-07-21 21:34:56 +00:00
parent d5ee6f8700
commit c7bdb76fe4
4 changed files with 32 additions and 17 deletions

View File

@ -1,6 +1,6 @@
Function(["path", "name"], Function(["path"],
Package( Package(
[ ("name", Var("name")) [ ("name", "nar")
, ("build", Relative("nar/nar.sh")) , ("build", Relative("nar/nar.sh"))
, ("path", Var("path")) , ("path", Var("path"))
] ]

View File

@ -1,5 +1,10 @@
#! /bin/sh #! /bin/sh
echo "packing $path into $out..." echo "packing $path into $out..."
@bindir@/nix --dump --file "$path" | bzip2 > $out || exit 1 mkdir $out || exit 1
tmp=$out/tmp
@bindir@/nix --dump --path "$path" | bzip2 > $out/tmp || exit 1
md5=$(md5sum -b $tmp | cut -c1-32)
if test $? != 0; then exit 1; fi
mv $out/tmp $out/$md5-`basename $path`.nar.bz2 || exit 1

View File

@ -8,13 +8,24 @@ foreach my $id (@ARGV) {
# Get all paths referenced by the normalisation of the given # Get all paths referenced by the normalisation of the given
# fstate expression. # fstate expression.
system "nix -ih $id"; system "nix --install $id";
if ($?) { die "`nix -ih' failed"; } if ($?) { die "`nix --install' failed"; }
my @paths; my @paths;
open PATHS, "nix -qrh $id 2> /dev/null |" or die "nix -qrh";
open PATHS, "nix --query --refs $id 2> /dev/null |" or die "nix -qr";
while (<PATHS>) { while (<PATHS>) {
chomp; chomp;
next unless /^\//; die "bad: $_" unless /^\//;
push @paths, $_;
}
close PATHS;
# Also add all normal forms that are contained in these paths.
open PATHS, "nix --query --generators --path @paths |" or die "nix -qg";
while (<PATHS>) {
chomp;
die "bad: $_" unless /^\//;
push @paths, $_; push @paths, $_;
} }
close PATHS; close PATHS;
@ -38,7 +49,6 @@ foreach my $id (@ARGV) {
my $fixexpr = my $fixexpr =
"App(IncludeFix(\"nar/nar.fix\"), " . "App(IncludeFix(\"nar/nar.fix\"), " .
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" . "[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
", (\"name\", \"$name\")" .
"])"; "])";
my $fixfile = "/tmp/nix-push-tmp.fix"; my $fixfile = "/tmp/nix-push-tmp.fix";
@ -53,13 +63,13 @@ foreach my $id (@ARGV) {
die unless $nid =~ /^([0-9a-z]{32})$/; die unless $nid =~ /^([0-9a-z]{32})$/;
# Realise the Nix expression. # Realise the Nix expression.
system "nix -ih $nid"; system "nix --install $nid";
if ($?) { die "`nix -ih' failed"; } if ($?) { die "`nix --install' failed"; }
my $npath = `nix -qph $nid 2> /dev/null`; my $npath = `nix --query --list $nid 2> /dev/null`;
$? and die "creating Nix archive"; $? and die "`nix --query --list' failed";
chomp $npath; chomp $npath;
push @pushlist, $npath; push @pushlist, "$npath/*";
print "$path -> $npath\n"; print "$path -> $npath\n";
} }

View File

@ -15,11 +15,11 @@ $hash || die "no package hash specified";
my $linkdir = "@localstatedir@/nix/links"; my $linkdir = "@localstatedir@/nix/links";
# Build the specified package, and all its dependencies. # Build the specified package, and all its dependencies.
system "nix -ih $hash"; system "nix --install $hash";
if ($?) { die "`nix -ih' failed"; } if ($?) { die "`nix --install' failed"; }
my $pkgdir = `nix -qph $hash`; my $pkgdir = `nix --query --list $hash`;
if ($?) { die "`nix -qph' failed"; } if ($?) { die "`nix --query --list' failed"; }
chomp $pkgdir; chomp $pkgdir;
# Figure out a generation number. # Figure out a generation number.