From 7eed57e784068ae6e2e9bf4409639067df467cd3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Dec 2004 14:57:03 +0000 Subject: [PATCH] * Sync with changed substitute mechanism. * Accept the NarHash line. * Clear substitutes in `nix-channel --update'. --- scripts/nix-channel.in | 4 ++++ scripts/nix-prefetch-url.in | 4 +++- scripts/nix-pull.in | 9 ++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 1733afceb..3c99f454c 100755 --- a/scripts/nix-channel.in +++ b/scripts/nix-channel.in @@ -53,6 +53,10 @@ sub addChannel { sub update { readChannels; + # Get rid of all the old substitutes. + system "@bindir@/nix-store --clear-substitutes"; + die "cannot clear substitutes" if ($? != 0); + # Pull cache manifests. foreach my $url (@channels) { print "pulling cache manifest from `$url'\n"; diff --git a/scripts/nix-prefetch-url.in b/scripts/nix-prefetch-url.in index 32f40b5ae..9a67ca141 100644 --- a/scripts/nix-prefetch-url.in +++ b/scripts/nix-prefetch-url.in @@ -49,7 +49,9 @@ finalPath=$(@bindir@/nix-store -qnB --force-realise $storeExpr) if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi -rm -rf $tmpPath1 $tmpPath2 || true +if test -n "$tmpPath1" -o -n "$tmpPath2"; then + rm -rf $tmpPath1 $tmpPath2 || true +fi echo $hash diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index a06ee7e57..d2c38d0ca 100644 --- a/scripts/nix-pull.in +++ b/scripts/nix-pull.in @@ -48,10 +48,10 @@ my $nixExpr = "(import @datadir@/nix/corepkgs/nix-pull) " . "{system = \"@system@\";}"; -print STDERR "instantiating store expression...\n"; -my $storeExpr = `echo '$nixExpr' | @bindir@/nix-instantiate -` +print STDERR "building downloader...\n"; +my $substProgram = `echo '$nixExpr' | @bindir@/nix-store -qnf \$(@bindir@/nix-instantiate -)` or die "cannot instantiate Nix expression"; -chomp $storeExpr; +chomp $substProgram; # Register all substitutes. @@ -66,8 +66,7 @@ foreach my $storePath (keys %narFiles) { my $narFileList = $narFiles{$storePath}; foreach my $narFile (@{$narFileList}) { print WRITE "$storePath\n"; - print WRITE "$storeExpr\n"; - print WRITE "/fetch\n"; + print WRITE "$substProgram/fetch\n"; print WRITE "2\n"; print WRITE "$narFile->{url}\n"; print WRITE "$narFile->{hash}\n";