]>
Commit | Line | Data |
---|---|---|
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 | # --------------------------------------------------------------- |
14 | sub cleanup() | |
15 | { | |
16 | system("rm -rf tmp/$id"); | |
17 | } | |
18 | ||
19 | sub 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 | |
27 | From: $from <$from\@pld-linux.org> | |
28 | To: $commits_list | |
29 | Cc: $from\@pld-linux.org | |
30 | Message-ID: <$id\@distfiles.pld-linux.org> | |
31 | Subject: DISTFILES: ERROR fetching sources for $spec ($branch) | |
32 | X-distfiles-program: request-handler.pl | |
33 | X-distfiles-version: $version | |
34 | ||
35 | $msg | |
36 | ||
37 | -- | |
38 | Virtually Yours: distfiles. | |
39 | EOF | |
40 | ; | |
41 | close(M) or die; | |
42 | exit 0; | |
43 | } | |
44 | # --------------------------------------------------------------- | |
45 | ||
052c958f MM |
46 | $id = `uuidgen`; |
47 | chomp $id; | |
48 | $id = rand if (!defined $id or $id eq ""); | |
49 | ||
50 | while (<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 | ||
58 | die "ill-formed request" if (!defined $from); | |
59 | ||
60 | report_fatal("bad spec name") if (!defined $spec); | |
61 | ||
62 | mkdir("tmp/$id") or die; | |
63 | chdir("tmp/$id"); | |
64 | ||
65 | $branch = "" if ($branch eq "HEAD"); | |
66 | $branch = "-r \"$branch\"" if ($branch ne ""); | |
67 | ||
9b11afd9 | 68 | if (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 | ||
73 | chdir("../.."); | |
74 | ||
75 | open(S, "> tmp/$id/to-spool"); | |
76 | print S "$from\@pld-linux.org\n"; | |
47f8fda7 | 77 | print S "$flags\n"; |
052c958f MM |
78 | close(S); |
79 | ||
06ea7f33 | 80 | if (system("perl ./specparser.pl \"tmp/$id/SPECS/$spec\" >> tmp/$id/to-spool") != 0) { |
052c958f MM |
81 | report_fatal("cannot parse $spec ($branch)") |
82 | } | |
83 | ||
84 | rename("tmp/$id/to-spool", "$spool_dir/$id"); | |
85 | ||
86 | cleanup(); | |
87 | ||
88 | exit(0); | |
89 |