2003-07-10 13:41:28 +00:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
my @pushlist;
|
|
|
|
|
2003-07-16 20:00:51 +00:00
|
|
|
foreach my $id (@ARGV) {
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-16 20:00:51 +00:00
|
|
|
die unless $id =~ /^([0-9a-z]{32})$/;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
|
|
|
# Get all paths referenced by the normalisation of the given
|
|
|
|
# fstate expression.
|
2003-07-16 21:24:02 +00:00
|
|
|
system "nix -ih $id";
|
|
|
|
if ($?) { die "`nix -ih' failed"; }
|
2003-07-10 13:41:28 +00:00
|
|
|
my @paths;
|
2003-07-16 20:00:51 +00:00
|
|
|
open PATHS, "nix -qrh $id 2> /dev/null |" or die "nix -qrh";
|
2003-07-10 13:41:28 +00:00
|
|
|
while (<PATHS>) {
|
2003-07-10 19:27:46 +00:00
|
|
|
chomp;
|
|
|
|
next unless /^\//;
|
|
|
|
push @paths, $_;
|
2003-07-10 13:41:28 +00:00
|
|
|
}
|
|
|
|
close PATHS;
|
|
|
|
|
|
|
|
# For each path, create a Fix expression that turns the path into
|
|
|
|
# a Nix archive.
|
|
|
|
foreach my $path (@paths) {
|
|
|
|
|
2003-07-16 20:00:51 +00:00
|
|
|
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
|
|
|
|
my $pathid = $1;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-10 20:13:32 +00:00
|
|
|
# Construct a name for the Nix archive. If the file is an
|
|
|
|
# fstate successor, encode this into the name.
|
2003-07-16 20:00:51 +00:00
|
|
|
my $name = $pathid;
|
2003-07-10 20:13:32 +00:00
|
|
|
if ($path =~ /-s-([0-9a-z]{32}).nix$/) {
|
|
|
|
$name = "$name-s-$1";
|
|
|
|
}
|
2003-07-10 20:34:29 +00:00
|
|
|
$name = $name . ".nar.bz2";
|
2003-07-10 20:13:32 +00:00
|
|
|
|
|
|
|
# Construct a Fix expression that creates a Nix archive.
|
2003-07-10 19:27:46 +00:00
|
|
|
my $fixexpr =
|
2003-07-10 13:41:28 +00:00
|
|
|
"App(IncludeFix(\"nar/nar.fix\"), " .
|
2003-07-16 20:00:51 +00:00
|
|
|
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
|
2003-07-10 20:13:32 +00:00
|
|
|
", (\"name\", \"$name\")" .
|
2003-07-10 13:41:28 +00:00
|
|
|
"])";
|
|
|
|
|
2003-07-10 19:27:46 +00:00
|
|
|
my $fixfile = "/tmp/nix-push-tmp.fix";
|
|
|
|
open FIX, ">$fixfile";
|
|
|
|
print FIX $fixexpr;
|
|
|
|
close FIX;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-10 19:27:46 +00:00
|
|
|
# Instantiate a Nix expression from the Fix expression.
|
2003-07-16 20:00:51 +00:00
|
|
|
my $nid = `fix $fixfile`;
|
2003-07-10 19:27:46 +00:00
|
|
|
$? and die "instantiating Nix archive expression";
|
2003-07-16 20:00:51 +00:00
|
|
|
chomp $nid;
|
|
|
|
die unless $nid =~ /^([0-9a-z]{32})$/;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-10 19:27:46 +00:00
|
|
|
# Realise the Nix expression.
|
2003-07-16 21:24:02 +00:00
|
|
|
system "nix -ih $nid";
|
|
|
|
if ($?) { die "`nix -ih' failed"; }
|
2003-07-16 20:00:51 +00:00
|
|
|
my $npath = `nix -qph $nid 2> /dev/null`;
|
2003-07-10 19:27:46 +00:00
|
|
|
$? and die "creating Nix archive";
|
|
|
|
chomp $npath;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-10 19:27:46 +00:00
|
|
|
push @pushlist, $npath;
|
2003-07-10 13:41:28 +00:00
|
|
|
|
2003-07-10 19:27:46 +00:00
|
|
|
print "$path -> $npath\n";
|
2003-07-10 13:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Push the prebuilts to the server. !!! FIXME
|
2003-07-10 20:34:29 +00:00
|
|
|
if (scalar @pushlist > 0) {
|
|
|
|
system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/";
|
|
|
|
}
|