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