]> git.pld-linux.org Git - projects/distfiles.git/blame_incremental - request-handler.pl
Back to original dir (works even if tmp is a symlink)
[projects/distfiles.git] / request-handler.pl
... / ...
CommitLineData
1#!/usr/bin/perl -w
2# $Id$
3# read email with request from stdin and process it
4
5$spool_dir = "./spool";
6$commits_list = "pld-cvs-commit\@lists.pld-linux.org";
7
8$spec = undef;
9$branch = "";
10$from = undef;
11$flags = "";
12
13# ---------------------------------------------------------------
14use File::Basename;
15use Cwd;
16
17sub cleanup()
18{
19 system("rm -rf tmp/$id");
20}
21
22sub report_fatal($)
23{
24 my $msg = shift;
25 cleanup();
26 open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
27 #open(M, "| cat") or die;
28 my $version = '$Id$';
29 print M <<EOF
30From: $from <$from\@pld-linux.org>
31To: $commits_list
32Cc: $from\@pld-linux.org
33Message-ID: <$id\@distfiles.pld-linux.org>
34Subject: DISTFILES: ERROR fetching sources for $spec ($branch)
35X-distfiles-program: request-handler.pl
36X-distfiles-version: $version
37
38$msg
39
40--
41Virtually Yours: distfiles.
42EOF
43;
44 close(M) or die("problem while sending email");
45 exit 0;
46}
47# ---------------------------------------------------------------
48
49$id = `uuidgen`;
50chomp $id;
51$id = rand if (!defined $id or $id eq "");
52
53while (<STDIN>) {
54 chomp;
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;
59}
60
61die "ill-formed request" if (!defined $from);
62
63report_fatal("bad spec name") if (!defined $spec);
64
65$cwd = Cwd::getcwd();
66
67mkdir("tmp/$id") or die("cannot create: tmp/$id");
68chdir("tmp/$id");
69
70$branch = "" if ($branch eq "HEAD");
71$branch = "-r \"$branch\"" if ($branch ne "");
72
73$specdir = File::Basename::basename($spec,('.spec'));
74if (system("cvs -d :pserver:cvs\@cvs.pld-linux.org:/cvsroot get $branch \"packages/$specdir/$spec\" >/dev/null 2>&1") != 0) {
75 chdir("../..");
76 report_fatal("cannot cvs get $spec at $branch")
77}
78
79chdir($cwd);
80
81open(S, "> tmp/$id/to-spool");
82print S "$from\@pld-linux.org\n";
83print S "$flags\n";
84close(S);
85
86if (system("perl ./specparser.pl \"tmp/$id/packages/$specdir/$spec\" >> tmp/$id/to-spool") != 0) {
87 report_fatal("cannot parse $spec ($branch)")
88}
89
90rename("tmp/$id/to-spool", "$spool_dir/$id");
91
92cleanup();
93
94exit(0);
95
This page took 0.030001 seconds and 4 git commands to generate.