about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T20·13+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T20·13+0000
commit9bcc31c94168717c8bd27b83bfab686264f63745 (patch)
treecafe0444d1a7a30740e59ee36f48686a74c34f0c /scripts
parent81304a6bb595e64d868ef4eb4bfcc08014ced939 (diff)
* Working derivate sharing.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/nix-pull15
-rw-r--r--scripts/nix-push12
2 files changed, 23 insertions, 4 deletions
diff --git a/scripts/nix-pull b/scripts/nix-pull
index 86d9f4b1144e..6404cb79a17a 100644
--- a/scripts/nix-pull
+++ b/scripts/nix-pull
@@ -7,6 +7,7 @@ my $tmpfile = "$prefix/var/nix/pull.tmp";
 my $conffile = "$etcdir/prebuilts.conf";
 
 my @subs;
+my @sucs;
 
 open CONFFILE, "<$conffile";
 
@@ -30,8 +31,9 @@ while (<CONFFILE>) {
             my $fn = $1;
             next if $fn =~ /\.\./;
             next if $fn =~ /\//;
-            next unless $fn =~ /([0-9a-z]{32})-([0-9a-z]{32})\.nar/;
-            my $hash = $2;
+            next unless $fn =~ /-([0-9a-z]{32})(-s-([0-9a-z]{32}))?\.nar/;
+            my $hash = $1;
+            my $fshash = $3;
 
             print "registering $hash -> $url/$fn\n";
 
@@ -60,6 +62,12 @@ while (<CONFFILE>) {
             push @subs, $hash;
             push @subs, $nhash;
 
+            # Does the name encode a successor relation?
+            if (defined $fshash) {
+                print "NORMAL $fshash -> $hash\n";
+                push @sucs, $fshash;
+                push @sucs, $hash;
+            }
         }
 
         close INDEX;
@@ -71,3 +79,6 @@ while (<CONFFILE>) {
 
 system "nix --substitute @subs";
 if ($?) { die "`nix --substitute' failed"; }
+
+system "nix --successor @sucs";
+if ($?) { die "`nix --successor' failed"; }
diff --git a/scripts/nix-push b/scripts/nix-push
index 731532f1e9a4..248a3b9174d6 100644
--- a/scripts/nix-push
+++ b/scripts/nix-push
@@ -27,11 +27,19 @@ foreach my $hash (@ARGV) {
         chomp $phash;
         die unless $phash =~ /^([0-9a-z]{32})$/;
 
-        # Construct a Fix expression that creates a Nar archive.
+        # Construct a name for the Nix archive.  If the file is an
+        # fstate successor, encode this into the name.
+        my $name = $phash;
+        if ($path =~ /-s-([0-9a-z]{32}).nix$/) {
+            $name = "$name-s-$1";
+        }
+        $name = $name . ".nar";
+
+        # Construct a Fix expression that creates a Nix archive.
         my $fixexpr = 
           "App(IncludeFix(\"nar/nar.fix\"), " .
           "[ (\"path\", Path(\"$path\", Hash(\"$phash\"), [Include(\"$hash\")]))" .
-          ", (\"name\", \"$phash.nar\")" .
+          ", (\"name\", \"$name\")" .
           "])";
 	
         my $fixfile = "/tmp/nix-push-tmp.fix";