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