From 8984ebdeb896ed0796cd8690eb0d8599adff41a1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 7 Jan 2004 16:08:31 +0000 Subject: [PATCH] * Consolidate upload.pl into create-dist.pl. svn path=/nixpkgs/trunk/; revision=622 --- nix-dist/server-side/cgi-bin/create-dist.pl | 31 +++++++++++++++++---- nix-dist/server-side/cgi-bin/md5.pl | 21 -------------- nix-dist/server-side/cgi-bin/upload.pl | 23 --------------- 3 files changed, 25 insertions(+), 50 deletions(-) delete mode 100755 nix-dist/server-side/cgi-bin/md5.pl delete mode 100755 nix-dist/server-side/cgi-bin/upload.pl diff --git a/nix-dist/server-side/cgi-bin/create-dist.pl b/nix-dist/server-side/cgi-bin/create-dist.pl index 7e23d6221769..23a4e6955c2e 100755 --- a/nix-dist/server-side/cgi-bin/create-dist.pl +++ b/nix-dist/server-side/cgi-bin/create-dist.pl @@ -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 () { + 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 () { - 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"; } diff --git a/nix-dist/server-side/cgi-bin/md5.pl b/nix-dist/server-side/cgi-bin/md5.pl deleted file mode 100755 index a998844410a5..000000000000 --- a/nix-dist/server-side/cgi-bin/md5.pl +++ /dev/null @@ -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"; diff --git a/nix-dist/server-side/cgi-bin/upload.pl b/nix-dist/server-side/cgi-bin/upload.pl deleted file mode 100755 index 63ad085b6177..000000000000 --- a/nix-dist/server-side/cgi-bin/upload.pl +++ /dev/null @@ -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 () { - 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";