forked from lix-project/lix
nix-push: Remove the upload feature
This commit is contained in:
parent
609586a16d
commit
e3ce54ccee
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue