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