]>
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 | 13 | # --------------------------------------------------------------- |
91ff13d3 AM |
14 | use File::Basename; |
15 | ||
a04817ac MM |
16 | sub cleanup() |
17 | { | |
18 | system("rm -rf tmp/$id"); | |
19 | } | |
20 | ||
21 | sub report_fatal($) | |
22 | { | |
23 | my $msg = shift; | |
24 | cleanup(); | |
b5160615 | 25 | open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found"; |
a04817ac MM |
26 | #open(M, "| cat") or die; |
27 | my $version = '$Id$'; | |
28 | print M <<EOF | |
29 | From: $from <$from\@pld-linux.org> | |
30 | To: $commits_list | |
31 | Cc: $from\@pld-linux.org | |
32 | Message-ID: <$id\@distfiles.pld-linux.org> | |
33 | Subject: DISTFILES: ERROR fetching sources for $spec ($branch) | |
34 | X-distfiles-program: request-handler.pl | |
35 | X-distfiles-version: $version | |
36 | ||
37 | $msg | |
38 | ||
39 | -- | |
40 | Virtually Yours: distfiles. | |
41 | EOF | |
42 | ; | |
b5160615 | 43 | close(M) or die("problem while sending email"); |
a04817ac MM |
44 | exit 0; |
45 | } | |
46 | # --------------------------------------------------------------- | |
47 | ||
052c958f MM |
48 | $id = `uuidgen`; |
49 | chomp $id; | |
50 | $id = rand if (!defined $id or $id eq ""); | |
51 | ||
52 | while (<STDIN>) { | |
47f8fda7 | 53 | chomp; |
576dff03 ER |
54 | /^X-Spec: ([a-z0-9_.+-]+\.spec)/i and $spec = $1; |
55 | /^X-Branch: ([a-z0-9_-]+)/i and $branch = $1; | |
56 | /^X-Login: ([a-z0-9_.]+)/i and $from = $1; | |
57 | /^X-Flags: ([a-z0-9_ -]+)/i and $flags = $1; | |
052c958f MM |
58 | } |
59 | ||
60 | die "ill-formed request" if (!defined $from); | |
61 | ||
62 | report_fatal("bad spec name") if (!defined $spec); | |
63 | ||
b5160615 | 64 | mkdir("tmp/$id") or die("cannot create: tmp/$id"); |
052c958f MM |
65 | chdir("tmp/$id"); |
66 | ||
67 | $branch = "" if ($branch eq "HEAD"); | |
68 | $branch = "-r \"$branch\"" if ($branch ne ""); | |
69 | ||
91ff13d3 | 70 | $specdir = File::Basename::basename($spec,('.spec')); |
d9fd3020 | 71 | if (system("cvs -d :pserver:cvs\@cvs.pld-linux.org:/cvsroot get $branch \"packages/$specdir/$spec\" >/dev/null 2>&1") != 0) { |
052c958f MM |
72 | chdir("../.."); |
73 | report_fatal("cannot cvs get $spec at $branch") | |
74 | } | |
75 | ||
76 | chdir("../.."); | |
77 | ||
78 | open(S, "> tmp/$id/to-spool"); | |
79 | print S "$from\@pld-linux.org\n"; | |
47f8fda7 | 80 | print S "$flags\n"; |
052c958f MM |
81 | close(S); |
82 | ||
91ff13d3 | 83 | if (system("perl ./specparser.pl \"tmp/$id/packages/$specdir/$spec\" >> tmp/$id/to-spool") != 0) { |
052c958f MM |
84 | report_fatal("cannot parse $spec ($branch)") |
85 | } | |
86 | ||
87 | rename("tmp/$id/to-spool", "$spool_dir/$id"); | |
88 | ||
89 | cleanup(); | |
90 | ||
91 | exit(0); | |
92 |