about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-13T15·35-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-13T15·35-0400
commitb14717ab9003452fda7afe0f9627673b9f331569 (patch)
treeb2eaea17f4945a484cf5875918afd39bc55e096e /scripts
parent6c4ac299173e3b9772c96bef1e6463b22dcd0227 (diff)
Delete manifests in "nix-channel --remove" or when a binary cache is available
Diffstat (limited to 'scripts')
-rw-r--r--scripts/download-from-binary-cache.pl.in1
-rwxr-xr-xscripts/nix-channel.in4
-rwxr-xr-xscripts/nix-pull.in17
3 files changed, 8 insertions, 14 deletions
diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in
index f16434d0a391..cbac177623d4 100644
--- a/scripts/download-from-binary-cache.pl.in
+++ b/scripts/download-from-binary-cache.pl.in
@@ -20,6 +20,7 @@ my $maxParallelRequests = int($Nix::Config::config{"binary-caches-parallel-conne
 $maxParallelRequests = 1 if $maxParallelRequests < 1;
 
 my $debug = ($ENV{"NIX_DEBUG_SUBST"} // "") eq 1;
+open(STDERR, ">>/dev/tty") if $debug;
 
 my ($dbh, $queryCache, $insertNAR, $queryNAR, $insertNARExistence, $queryNARExistence);
 
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index e057cc91671a..7e50dac1e3a9 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -4,6 +4,7 @@ use strict;
 use File::Basename;
 use File::Path qw(mkpath);
 use Nix::Config;
+use Nix::Manifest;
 
 my $manifestDir = $Nix::Config::manifestDir;
 
@@ -65,6 +66,8 @@ sub addChannel {
 sub removeChannel {
     my ($name) = @_;
     readChannels;
+    my $url = $channels{$name};
+    deleteOldManifests($url . "/MANIFEST", undef) if defined $url;
     delete $channels{$name};
     writeChannels;
 
@@ -101,6 +104,7 @@ sub update {
         my $extraAttrs = "";
         if ($? == 0 && $binaryCacheURL ne "") {
             $extraAttrs .= "binaryCacheURL = \"$binaryCacheURL\"; ";
+            deleteOldManifests($origUrl, undef);
         } else {
             # No binary cache, so pull the channel manifest.
             mkdir $manifestDir, 0755 unless -e $manifestDir;
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index e59a38eec79f..fbd90c2b257d 100755
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -76,26 +76,15 @@ sub processURL {
     open URL, ">$urlFile" or die "cannot create `$urlFile'";
     print URL $origUrl;
     close URL;
-    
+
     my $finalPath = "$manifestDir/$baseName-$hash.nixmanifest";
 
     unlink $finalPath if -e $finalPath;
-        
+
     symlink("$manifest", "$finalPath")
         or die "cannot link `$finalPath to `$manifest'";
 
-    # Delete all old manifests downloaded from this URL.
-    for my $urlFile2 (glob "$manifestDir/*.url") {
-        next if $urlFile eq $urlFile2;
-        open URL, "<$urlFile2" or die;
-        my $url2 = <URL>;
-        chomp $url2;
-        close URL;
-        next unless $origUrl eq $url2;
-        my $base = $urlFile2; $base =~ s/.url$//;
-        unlink "${base}.url";
-        unlink "${base}.nixmanifest";
-    }
+    deleteOldManifests($origUrl, $urlFile);
 }
 
 while (@ARGV) {