* Consolidate upload.pl into create-dist.pl.
svn path=/nixpkgs/trunk/; revision=622
This commit is contained in:
parent
f8554f0b81
commit
8984ebdeb8
@ -4,7 +4,7 @@ use strict;
|
|||||||
|
|
||||||
|
|
||||||
# Global settings.
|
# Global settings.
|
||||||
my $releasesDir = "/home/eelco/public_html/test";
|
my $releasesDir = "/home/eelco/public_html/nix";
|
||||||
|
|
||||||
umask 0002;
|
umask 0002;
|
||||||
|
|
||||||
@ -16,6 +16,16 @@ sub printResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub uploadFileTo {
|
||||||
|
my $path = shift;
|
||||||
|
open OUT, ">$path" or die "cannot create $path: $!";
|
||||||
|
while (<STDIN>) {
|
||||||
|
print OUT "$_" or die;
|
||||||
|
}
|
||||||
|
close OUT or die;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
my $args = $ENV{"PATH_INFO"};
|
my $args = $ENV{"PATH_INFO"};
|
||||||
|
|
||||||
# Parse command.
|
# Parse command.
|
||||||
@ -48,11 +58,7 @@ elsif ($command eq "upload") {
|
|||||||
|
|
||||||
my $fullPath = "$releasesDir/$sessionName/$path";
|
my $fullPath = "$releasesDir/$sessionName/$path";
|
||||||
|
|
||||||
open OUT, ">$fullPath" or die "cannot create $fullPath: $!";
|
uploadFileTo $fullPath;
|
||||||
while (<STDIN>) {
|
|
||||||
print OUT "$_" or die;
|
|
||||||
}
|
|
||||||
close OUT or die;
|
|
||||||
|
|
||||||
printResult "ok";
|
printResult "ok";
|
||||||
}
|
}
|
||||||
@ -110,6 +116,19 @@ elsif ($command eq "exists") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Upload a single file, outside of a release.
|
||||||
|
elsif ($command eq "put") {
|
||||||
|
$args = "/" . $args;
|
||||||
|
die unless $args =~ /^((\/[A-Za-z0-9-][A-Za-z0-9-\.]*)+)$/;
|
||||||
|
my $path = $1;
|
||||||
|
|
||||||
|
my $fullPath = "$releasesDir/$path";
|
||||||
|
|
||||||
|
uploadFileTo $fullPath;
|
||||||
|
|
||||||
|
printResult "ok";
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
die "invalid command";
|
die "invalid command";
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#! /usr/bin/perl -w
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use FileHandle;
|
|
||||||
use File::Spec;
|
|
||||||
use Digest::MD5;
|
|
||||||
|
|
||||||
my $path = $ENV{"PATH_INFO"};
|
|
||||||
|
|
||||||
# Sanitise path.
|
|
||||||
die unless $path =~ /^(\/[A-Za-z0-9-][A-Za-z0-9-\.]+)+$/;
|
|
||||||
|
|
||||||
my $fullpath = "/home/eelco/public_html/nix/$path";
|
|
||||||
|
|
||||||
open FILE, "< $fullpath" or die "cannot open $fullpath";
|
|
||||||
# !!! error checking
|
|
||||||
my $hash = Digest::MD5->new->addfile(*FILE)->hexdigest;
|
|
||||||
close FILE;
|
|
||||||
|
|
||||||
print "Content-Type: text/plain\n\n";
|
|
||||||
print "$hash";
|
|
@ -1,23 +0,0 @@
|
|||||||
#! /usr/bin/perl -w
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
my $uploadpath = $ENV{"PATH_INFO"};
|
|
||||||
|
|
||||||
# Sanitise upload path.
|
|
||||||
die unless $uploadpath =~ /^(\/[A-Za-z0-9-][A-Za-z0-9-\.]*)+$/;
|
|
||||||
|
|
||||||
my $dst = "/home/eelco/public_html/nix/$uploadpath";
|
|
||||||
my $tmp = "${dst}_$$";
|
|
||||||
|
|
||||||
open OUT, ">$tmp" or die;
|
|
||||||
while (<STDIN>) {
|
|
||||||
print OUT "$_" or die;
|
|
||||||
}
|
|
||||||
close OUT or die;
|
|
||||||
|
|
||||||
rename $tmp, $dst or die;
|
|
||||||
|
|
||||||
print "Content-Type: text/plain\n\n";
|
|
||||||
print "upload succesful\n";
|
|
||||||
print "upload path: $uploadpath\n";
|
|
Loading…
x
Reference in New Issue
Block a user