From 7dd91d3779b4f806ac0085e0ccc60416d81c1148 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 25 May 2003 22:42:19 +0000 Subject: * Prebuilt package sharing. We allow transparent binary deployment by sharing package directories (i.e., the result of building a Nix descriptor). `nix-pull-prebuilts' obtains a list of all known prebuilts by consulting the paths and URLs specified in $prefix/etc/nix/prebuilts.conf. The mappings ($pkghash, $prebuilthash) and ($prebuilthash, $location) are registered with Nix so that it can use the prebuilt with hash $prebuilthash when installing a package with hash $pkghash by downloading and unpacking $location. `nix-push-prebuilts' creates prebuilts for all packages for which no prebuilt is known to exist. It can then optionally upload these to the network through rsync. `nix-[pull|push]-prebuilts' just provide a policy. Nix provides the mechanism through the `nix [export|regprebuilt|regurl]' commands. --- scripts/nix-push-prebuilts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/nix-push-prebuilts (limited to 'scripts/nix-push-prebuilts') diff --git a/scripts/nix-push-prebuilts b/scripts/nix-push-prebuilts new file mode 100755 index 000000000..2e3029b16 --- /dev/null +++ b/scripts/nix-push-prebuilts @@ -0,0 +1,40 @@ +#! /usr/bin/perl -w + +my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix +my $etcdir = "$prefix/etc/nix"; +my $exportdir = "$prefix/var/nix/prebuilts/exports"; +my $knowns = "$prefix/var/nix/known-prebuilts"; + +# For performance, put the known hashes in an associative array. +my %knowns = (); +open KNOWNS, "<$knowns"; +while () { + next unless /([0-9a-z]{32})/; + $knowns{$1} = 1; +} +close KNOWNS; + +# For each installed package, check whether a prebuilt is known. + +open PKGS, "nix listinst|"; +open KNOWNS, ">>$knowns"; + +while () { + chomp; + next unless /([0-9a-z]{32})/; + my $pkghash = $1; + if (!defined $knowns{$1}) { + # No known prebuilt exists for this package; so export it. + print "exporting $pkghash...\n"; + system "nix export '$exportdir' $pkghash"; + if ($?) { die "`nix export' failed"; } + print KNOWNS "$pkghash\n"; + } +} + +close KNOWNS; +close PKGS; + +# Push the prebuilts to the server. !!! FIXME + +system "rsync -av -e ssh '$exportdir' losser:/home/eelco/public_html/nix-prebuilts/"; -- cgit v1.2.3