]> git.pld-linux.org Git - projects/distfiles.git/blobdiff - request-handler.pl
(Temporarily) support both scp and ftp
[projects/distfiles.git] / request-handler.pl
index 41addcee1e9219f7af0035993510dd44fdd8b85e..347233e9b5b2e7ef1b80e27a7171bc5c24cfb97b 100755 (executable)
@@ -1,7 +1,10 @@
 #!/usr/bin/perl -w
-# $Id$
 # read email with request from stdin and process it
 
+use Sys::Syslog;
+
+openlog("distfiles-rh", "pid", "user"); 
+
 $spool_dir = "./spool";
 $commits_list = "pld-cvs-commit\@lists.pld-linux.org";
 
@@ -23,6 +26,8 @@ sub cleanup()
 sub report_fatal($)
 {
   my $msg = shift;
+
+  syslog("err","FATAL: $msg");
   cleanup();
   open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
   #open(M, "| cat") or die;
@@ -60,7 +65,12 @@ while (<STDIN>) {
   /^X-Flags: ([a-z0-9_ -]+)/i and $flags = $1;
 }
 
-die "ill-formed request" if (!defined $from);
+if (!defined $from) {
+   syslog("err","FATAL: ill-formed request");
+   die "ill-formed request";
+}
+
+syslog("info","got request from $from for $spec at $branch ($flags)");
 
 report_fatal("bad spec name") if (!defined $spec);
 
@@ -80,6 +90,7 @@ if ( $? ) {
 
 chdir($oldcwd);
 
+syslog("info","spooling to tmp/$id/to-spool");
 open(S, "> tmp/$id/to-spool");
 print S "$from\@pld-linux.org\n";
 print S "$spec\n";
@@ -90,7 +101,10 @@ if (system("perl ./specparser.pl \"tmp/$id/$spec\" tmp/$id/sources >> tmp/$id/to
   report_fatal("cannot parse $spec ($branch)")
 }
 
-File::Copy::move("tmp/$id/to-spool", "$spool_dir/$id") or die("move failed: $!");
+if (!File::Copy::move("tmp/$id/to-spool", "$spool_dir/$id")) {
+  syslog("err","FATAL: move failed: $!");
+  die("move failed: $!");
+}
 
 cleanup();
 
This page took 0.213226 seconds and 4 git commands to generate.