From 3d1b2101ccfd34f15b108f54a563a616cb679109 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Dec 2004 16:38:50 +0000 Subject: [PATCH] * Place manifests in /nix/var/nix/manifests. * Use the new patch downloader. --- configure.ac | 1 - corepkgs/Makefile.am | 2 +- corepkgs/nix-pull/Makefile.am | 11 ------ corepkgs/nix-pull/builder.sh.in | 34 ------------------ corepkgs/nix-pull/default.nix | 7 ---- scripts/Makefile.am | 8 +++-- .../download-using-manifests.pl.in | 4 +-- scripts/nix-build.in | 0 scripts/nix-channel.in | 0 scripts/nix-collect-garbage.in | 0 scripts/nix-pull.in | 36 +++++++++---------- scripts/readmanifest.pm.in | 11 ++++-- 12 files changed, 35 insertions(+), 79 deletions(-) delete mode 100644 corepkgs/nix-pull/Makefile.am delete mode 100644 corepkgs/nix-pull/builder.sh.in delete mode 100644 corepkgs/nix-pull/default.nix rename corepkgs/nix-pull/download.pl => scripts/download-using-manifests.pl.in (98%) mode change 100755 => 100644 mode change 100755 => 100644 scripts/nix-build.in mode change 100755 => 100644 scripts/nix-channel.in mode change 100755 => 100644 scripts/nix-collect-garbage.in diff --git a/configure.ac b/configure.ac index 2e247053e..d7574bbad 100644 --- a/configure.ac +++ b/configure.ac @@ -195,7 +195,6 @@ AC_CONFIG_FILES([Makefile corepkgs/nar/Makefile corepkgs/buildenv/Makefile corepkgs/channels/Makefile - corepkgs/nix-pull/Makefile doc/Makefile doc/manual/Makefile misc/Makefile diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am index ca4cea2fc..c9ea11cef 100644 --- a/corepkgs/Makefile.am +++ b/corepkgs/Makefile.am @@ -1 +1 @@ -SUBDIRS = fetchurl nar buildenv channels nix-pull +SUBDIRS = fetchurl nar buildenv channels diff --git a/corepkgs/nix-pull/Makefile.am b/corepkgs/nix-pull/Makefile.am deleted file mode 100644 index 91adb4853..000000000 --- a/corepkgs/nix-pull/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -all-local: builder.sh - -install-exec-local: - $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs - $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull - $(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull - $(INSTALL_PROGRAM) builder.sh $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull - -include ../../substitute.mk - -EXTRA_DIST = default.nix builder.sh.in diff --git a/corepkgs/nix-pull/builder.sh.in b/corepkgs/nix-pull/builder.sh.in deleted file mode 100644 index cc1a125d8..000000000 --- a/corepkgs/nix-pull/builder.sh.in +++ /dev/null @@ -1,34 +0,0 @@ -#! @shell@ -e - -export PATH=/bin:/usr/bin - -mkdir $out - -cat > $out/fetch < '$manifest'") == 0 or die "curl failed: $?"; - + readManifest $manifest, \%narFiles, \%patches, \%successors; + + my $baseName = "unnamed"; + if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component + $baseName = $1; + } + + my $hash = `@bindir@/nix-hash --flat '$manifest'` + or die "cannot hash `$manifest'"; + chomp $hash; + + my $finalPath = "@localstatedir@/nix/manifests/$baseName-$hash.nixmanifest"; + + system("mv '$manifest' '$finalPath'") == 0 + or die "cannot move `$manifest' to `$finalPath"; } while (@ARGV) { @@ -42,18 +56,6 @@ my $size = scalar (keys %narFiles); print "$size store paths in manifest\n"; -# Instantiate a store expression that builds the substitute program -# (the program that fetches URLs and unpacks them into the store). -my $nixExpr = - "(import @datadir@/nix/corepkgs/nix-pull) " . - "{system = \"@system@\";}"; - -print STDERR "building downloader...\n"; -my $substProgram = `echo '$nixExpr' | @bindir@/nix-store -qnf \$(@bindir@/nix-instantiate -)` - or die "cannot instantiate Nix expression"; -chomp $substProgram; - - # Register all substitutes. print STDERR "registering substitutes...\n"; @@ -66,10 +68,8 @@ foreach my $storePath (keys %narFiles) { my $narFileList = $narFiles{$storePath}; foreach my $narFile (@{$narFileList}) { print WRITE "$storePath\n"; - print WRITE "$substProgram/fetch\n"; - print WRITE "2\n"; - print WRITE "$narFile->{url}\n"; - print WRITE "$narFile->{hash}\n"; + print WRITE "@libexecdir@/nix/download-using-manifests.pl\n"; + print WRITE "0\n"; } } diff --git a/scripts/readmanifest.pm.in b/scripts/readmanifest.pm.in index 8d6694ff2..7f41bd55f 100644 --- a/scripts/readmanifest.pm.in +++ b/scripts/readmanifest.pm.in @@ -19,6 +19,7 @@ sub readManifest { my $basePath; my $baseHash; my $patchType; + my $narHash; while () { chomp; @@ -34,6 +35,7 @@ sub readManifest { undef $hash; $size = 999999999; @preds = (); + undef $narHash; } elsif (/^patch \{$/) { $type = "patch"; @@ -44,6 +46,7 @@ sub readManifest { undef $basePath; undef $baseHash; undef $patchType; + undef $narHash; } else { die "bad line: $_"; } } else { @@ -71,7 +74,9 @@ sub readManifest { } if (!$found) { push @{$narFileList}, - {url => $url, hash => $hash, size => $size}; + { url => $url, hash => $hash, size => $size + , narHash => $narHash + }; } foreach my $p (@preds) { @@ -102,6 +107,7 @@ sub readManifest { push @{$patchList}, { url => $url, hash => $hash, size => $size , basePath => $basePath, baseHash => $baseHash + , narHash => $narHash }; } @@ -117,11 +123,12 @@ sub readManifest { elsif (/^\s*BasePath:\s*(\/\S+)\s*$/) { $basePath = $1; } elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; } elsif (/^\s*Type:\s*(\S+)\s*$/) { $patchType = $1; } + elsif (/^\s*NarHash:\s*(\S+)\s*$/) { $narHash = $1; } # Compatibility; elsif (/^\s*NarURL:\s*(\S+)\s*$/) { $url = $1; } elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = $1; } - + else { die "bad line: $_"; } } }