about summary refs log tree commit diff
path: root/scripts/nix-push.in
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-26T21·13-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-26T21·13-0400
commite3ce54cceedb9a3144c4eccfbafd63ed765d8913 (patch)
treeb8412b3106ce35f745cef2285dabfc4310d1c025 /scripts/nix-push.in
parent609586a16de90f8964b9c494aad3c1526feb514f (diff)
nix-push: Remove the upload feature
Diffstat (limited to '')
-rwxr-xr-xscripts/nix-push.in75
1 files changed, 24 insertions, 51 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 35ad43d283..45a0695a64 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -24,22 +24,15 @@ $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
 # Parse the command line.
 my $compressionType = "xz";
 my $force = 0;
-
-my $localCopy;
-my $localArchivesDir;
-
-my $archivesPutURL;
-my $archivesGetURL;
-
+my $destDir;
 my @roots;
 
 sub showSyntax {
     print STDERR <<EOF
-Usage: nix-push --copy ARCHIVES_DIR PATHS...
-   or: nix-push --upload ARCHIVES_PUT_URL ARCHIVES_GET_URL PATHS...
+Usage: nix-push --dest DIR PATHS...
 
-`nix-push' copies or uploads the closure of PATHS to the given
-destination.
+`nix-push' packs the closure of PATHS into a set of NAR archives
+stored in DIR.
 EOF
     ; # `
     exit 1;
@@ -54,18 +47,11 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
         $compressionType = "bzip2";
     } elsif ($arg eq "--force") {
         $force = 1;
-    } elsif ($arg eq "--copy") {
+    } elsif ($arg eq "--dest") {
         $n++;
         die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
-        $localCopy = 1;
-        $localArchivesDir = $ARGV[$n];
-        mkpath($localArchivesDir, 0, 0755);
-    } elsif ($arg eq "--upload") {
-        die "$0: `$arg' requires two arguments\n" unless $n + 2 < scalar @ARGV;
-        $localCopy = 0;
-        $archivesPutURL = $ARGV[$n + 1];
-        $archivesGetURL = $ARGV[$n + 2];
-        $n++;
+        $destDir = $ARGV[$n];
+        mkpath($destDir, 0, 0755);
     } elsif (substr($arg, 0, 1) eq "-") {
         showSyntax;
     } else {
@@ -73,7 +59,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
     }
 }
         
-showSyntax if !defined $localCopy;
+showSyntax if !defined $destDir;
 
 
 # From the given store paths, determine the set of requisite store
@@ -134,8 +120,8 @@ while (<READ>) {
 close READ or die "nix-build failed: $?";
 
 
-# Upload the archives and the corresponding info files.
-print STDERR "uploading/copying archives...\n";
+# Copy the archives and the corresponding info files.
+print STDERR "copying archives...\n";
 
 my $totalNarSize = 0;
 my $totalCompressedSize = 0;
@@ -183,24 +169,15 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     printf STDERR "%s [%.2f MiB, %.1f%%]\n", $storePath,
         $compressedSize / (1024 * 1024), $compressedSize / $narSize * 100;
 
-    # Upload the compressed NAR.
-    if ($localCopy) {
-        my $dst = "$localArchivesDir/$narName";
-        if (! -f $dst) {
-            my $tmp = "$localArchivesDir/.tmp.$$.$narName";
-            copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n";
-            rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
-        }
-    } else {
-        die "unimplemented";
-        #if (!archiveExists("$basename")) {
-        #    system("$curl --show-error --upload-file " .
-        #           "'$narArchive' '$archivesPutURL/$basename' > /dev/null") == 0 or
-        #           die "curl failed on $narArchive: $?";
-        #}
+    # Copy the compressed NAR.
+    my $dst = "$destDir/$narName";
+    if (! -f $dst) {
+        my $tmp = "$destDir/.tmp.$$.$narName";
+        copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n";
+        rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
     }
 
-    # Upload the info file.
+    # Write the info file.
     my $info;
     $info .= "StorePath: $storePath\n";
     $info .= "URL: $narName\n";
@@ -220,17 +197,13 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
 
     my $pathHash = substr(basename($storePath), 0, 32);
     
-    if ($localCopy) {
-        my $dst = "$localArchivesDir/$pathHash.narinfo";
-        if ($force || ! -f $dst) {
-            my $tmp = "$localArchivesDir/.tmp.$$.$pathHash.narinfo";
-            open INFO, ">$tmp" or die;
-            print INFO "$info" or die;
-            close INFO or die;
-            rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
-        }
-    } else {
-        die "unimplemented";
+    $dst = "$destDir/$pathHash.narinfo";
+    if ($force || ! -f $dst) {
+        my $tmp = "$destDir/.tmp.$$.$pathHash.narinfo";
+        open INFO, ">$tmp" or die;
+        print INFO "$info" or die;
+        close INFO or die;
+        rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
     }
 }