mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
* 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.
|
||||
my $releasesDir = "/home/eelco/public_html/test";
|
||||
my $releasesDir = "/home/eelco/public_html/nix";
|
||||
|
||||
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"};
|
||||
|
||||
# Parse command.
|
||||
@ -48,11 +58,7 @@ elsif ($command eq "upload") {
|
||||
|
||||
my $fullPath = "$releasesDir/$sessionName/$path";
|
||||
|
||||
open OUT, ">$fullPath" or die "cannot create $fullPath: $!";
|
||||
while (<STDIN>) {
|
||||
print OUT "$_" or die;
|
||||
}
|
||||
close OUT or die;
|
||||
uploadFileTo $fullPath;
|
||||
|
||||
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 {
|
||||
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…
Reference in New Issue
Block a user