2003-07-10 15:41:28 +02:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
2003-08-05 14:30:06 +02:00
|
|
|
my $fixfile = "/tmp/nix-push-tmp.fix";
|
|
|
|
open FIX, ">$fixfile";
|
|
|
|
print FIX "[";
|
|
|
|
my $first = 1;
|
2003-07-10 15:41:28 +02:00
|
|
|
|
2003-07-16 22:00:51 +02:00
|
|
|
foreach my $id (@ARGV) {
|
2003-07-10 15:41:28 +02:00
|
|
|
|
2003-07-16 22:00:51 +02:00
|
|
|
die unless $id =~ /^([0-9a-z]{32})$/;
|
2003-07-10 15:41:28 +02:00
|
|
|
|
|
|
|
# Get all paths referenced by the normalisation of the given
|
|
|
|
# fstate expression.
|
2003-07-21 23:34:56 +02:00
|
|
|
system "nix --install $id";
|
|
|
|
if ($?) { die "`nix --install' failed"; }
|
|
|
|
|
2003-07-10 15:41:28 +02:00
|
|
|
my @paths;
|
2003-07-21 23:34:56 +02:00
|
|
|
|
2003-07-29 17:19:03 +02:00
|
|
|
open PATHS, "nix --query --requisites --include-successors $id 2> /dev/null |" or die "nix -qr";
|
2003-07-10 15:41:28 +02:00
|
|
|
while (<PATHS>) {
|
2003-07-10 21:27:46 +02:00
|
|
|
chomp;
|
2003-07-21 23:34:56 +02:00
|
|
|
die "bad: $_" unless /^\//;
|
2003-07-10 21:27:46 +02:00
|
|
|
push @paths, $_;
|
2003-07-10 15:41:28 +02:00
|
|
|
}
|
|
|
|
close PATHS;
|
|
|
|
|
2003-07-21 23:34:56 +02:00
|
|
|
# Also add all normal forms that are contained in these paths.
|
2003-07-29 17:19:03 +02:00
|
|
|
# open PATHS, "nix --query --generators --path @paths |" or die "nix -qg";
|
|
|
|
# while (<PATHS>) {
|
|
|
|
# chomp;
|
|
|
|
# die "bad: $_" unless /^\//;
|
|
|
|
# push @paths, $_;
|
|
|
|
# }
|
|
|
|
# close PATHS;
|
2003-07-21 23:34:56 +02:00
|
|
|
|
2003-07-10 15:41:28 +02:00
|
|
|
# For each path, create a Fix expression that turns the path into
|
|
|
|
# a Nix archive.
|
|
|
|
foreach my $path (@paths) {
|
|
|
|
|
2003-07-16 22:00:51 +02:00
|
|
|
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
|
2003-08-05 14:30:06 +02:00
|
|
|
print "$path\n";
|
2003-07-16 22:00:51 +02:00
|
|
|
my $pathid = $1;
|
2003-07-10 15:41:28 +02:00
|
|
|
|
2003-07-10 22:13:32 +02:00
|
|
|
# Construct a name for the Nix archive. If the file is an
|
|
|
|
# fstate successor, encode this into the name.
|
2003-07-16 22:00:51 +02:00
|
|
|
my $name = $pathid;
|
2003-07-10 22:13:32 +02:00
|
|
|
if ($path =~ /-s-([0-9a-z]{32}).nix$/) {
|
|
|
|
$name = "$name-s-$1";
|
|
|
|
}
|
2003-07-10 22:34:29 +02:00
|
|
|
$name = $name . ".nar.bz2";
|
2003-07-10 22:13:32 +02:00
|
|
|
|
|
|
|
# Construct a Fix expression that creates a Nix archive.
|
2003-07-10 21:27:46 +02:00
|
|
|
my $fixexpr =
|
2003-07-10 15:41:28 +02:00
|
|
|
"App(IncludeFix(\"nar/nar.fix\"), " .
|
2003-08-28 12:10:12 +02:00
|
|
|
"[ (\"path\", Slice([\"$path\"], [(\"$path\", \"$pathid\", [])]))" .
|
2003-07-10 15:41:28 +02:00
|
|
|
"])";
|
|
|
|
|
2003-08-05 14:30:06 +02:00
|
|
|
print FIX "," unless ($first);
|
|
|
|
$first = 0;
|
2003-07-10 21:27:46 +02:00
|
|
|
print FIX $fixexpr;
|
2003-07-10 15:41:28 +02:00
|
|
|
|
2003-08-05 14:30:06 +02:00
|
|
|
}
|
|
|
|
}
|
2003-07-10 15:41:28 +02:00
|
|
|
|
2003-08-05 14:30:06 +02:00
|
|
|
print FIX "]";
|
|
|
|
close FIX;
|
|
|
|
|
|
|
|
# Instantiate a Nix expression from the Fix expression.
|
|
|
|
my @nids;
|
|
|
|
print STDERR "running fix...\n";
|
|
|
|
open NIDS, "fix $fixfile |" or die "cannot run fix";
|
|
|
|
while (<NIDS>) {
|
|
|
|
chomp;
|
|
|
|
die unless /^([0-9a-z]{32})$/;
|
|
|
|
push @nids, $1;
|
|
|
|
}
|
2003-07-10 15:41:28 +02:00
|
|
|
|
|
|
|
|
2003-08-05 14:30:06 +02:00
|
|
|
# Realise the Nix expression.
|
|
|
|
my @pushlist;
|
|
|
|
print STDERR "creating archives...\n";
|
|
|
|
system "nix --install @nids > /dev/null";
|
|
|
|
if ($?) { die "`nix --install' failed"; }
|
|
|
|
|
|
|
|
open NIDS, "nix --query --list @nids |" or die "cannot run nix";
|
|
|
|
while (<NIDS>) {
|
|
|
|
chomp;
|
|
|
|
die unless (/^\//);
|
|
|
|
print "$_\n";
|
|
|
|
push @pushlist, "$_/*";
|
2003-07-10 15:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Push the prebuilts to the server. !!! FIXME
|
2003-07-10 22:34:29 +02:00
|
|
|
if (scalar @pushlist > 0) {
|
|
|
|
system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/";
|
|
|
|
}
|