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