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