]> git.pld-linux.org Git - projects/distfiles.git/blame - request-handler.pl
- allow commas in url
[projects/distfiles.git] / request-handler.pl
CommitLineData
a04817ac 1#!/usr/bin/perl -w
b396edfa 2# $Id$
052c958f
MM
3# read email with request from stdin and process it
4
5$spool_dir = "./spool";
7a0595ea 6$commits_list = "pld-cvs-commit\@lists.pld-linux.org";
052c958f
MM
7
8$spec = undef;
9$branch = "";
10$from = undef;
47f8fda7 11$flags = "";
052c958f 12
a04817ac
MM
13# ---------------------------------------------------------------
14sub cleanup()
15{
16 system("rm -rf tmp/$id");
17}
18
19sub report_fatal($)
20{
21 my $msg = shift;
22 cleanup();
23 open(M, "| /usr/sbin/sendmail -t") or die;
24 #open(M, "| cat") or die;
25 my $version = '$Id$';
26 print M <<EOF
27From: $from <$from\@pld-linux.org>
28To: $commits_list
29Cc: $from\@pld-linux.org
30Message-ID: <$id\@distfiles.pld-linux.org>
31Subject: DISTFILES: ERROR fetching sources for $spec ($branch)
32X-distfiles-program: request-handler.pl
33X-distfiles-version: $version
34
35$msg
36
37--
38Virtually Yours: distfiles.
39EOF
40;
41 close(M) or die;
42 exit 0;
43}
44# ---------------------------------------------------------------
45
052c958f
MM
46$id = `uuidgen`;
47chomp $id;
48$id = rand if (!defined $id or $id eq "");
49
50while (<STDIN>) {
47f8fda7 51 chomp;
f37967dc 52 /^X-Spec: ([\+a-zA-Z0-9_\-\.]+\.spec)/i and $spec = $1;
052c958f
MM
53 /^X-Branch: ([a-zA-Z0-9_\-]+)/i and $branch = $1;
54 /^X-Login: ([a-zA-Z0-9_]+)/i and $from = $1;
47f8fda7 55 /^X-Flags: ([a-zA-Z0-9\-_ ]+)/i and $flags = $1;
052c958f
MM
56}
57
58die "ill-formed request" if (!defined $from);
59
60report_fatal("bad spec name") if (!defined $spec);
61
62mkdir("tmp/$id") or die;
63chdir("tmp/$id");
64
65$branch = "" if ($branch eq "HEAD");
66$branch = "-r \"$branch\"" if ($branch ne "");
67
9b11afd9 68if (system("cvs -d :pserver:builder\@cvs.pld-linux.org:/cvsroot get $branch \"SPECS/$spec\" >/dev/null 2>&1") != 0) {
052c958f
MM
69 chdir("../..");
70 report_fatal("cannot cvs get $spec at $branch")
71}
72
73chdir("../..");
74
75open(S, "> tmp/$id/to-spool");
76print S "$from\@pld-linux.org\n";
47f8fda7 77print S "$flags\n";
052c958f
MM
78close(S);
79
06ea7f33 80if (system("perl ./specparser.pl \"tmp/$id/SPECS/$spec\" >> tmp/$id/to-spool") != 0) {
052c958f
MM
81 report_fatal("cannot parse $spec ($branch)")
82}
83
84rename("tmp/$id/to-spool", "$spool_dir/$id");
85
86cleanup();
87
88exit(0);
89
This page took 0.034506 seconds and 4 git commands to generate.