]> git.pld-linux.org Git - projects/distfiles.git/blob - request-handler.pl
Use the new cvs list address.
[projects/distfiles.git] / request-handler.pl
1 #!/usr/bin/perl -w
2 # read email with request from stdin and process it
3
4 $spool_dir = "./spool";
5 $commits_list = "pld-cvs-commit\@lists.pld-linux.org";
6
7 $spec = undef;
8 $branch = "";
9 $from = undef;
10 $flags = "";
11
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
45 $id = `uuidgen`;
46 chomp $id;
47 $id = rand if (!defined $id or $id eq "");
48
49 while (<STDIN>) {
50   chomp;
51   /^X-Spec: ([\+a-zA-Z0-9_\-\.]+\.spec)/i and $spec = $1;
52   /^X-Branch: ([a-zA-Z0-9_\-]+)/i and $branch = $1;
53   /^X-Login: ([a-zA-Z0-9_]+)/i and $from = $1;
54   /^X-Flags: ([a-zA-Z0-9\-_ ]+)/i and $flags = $1;
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
67 if (system("cvs -d :pserver:builder\@cvs.pld-linux.org:/cvsroot get $branch \"SPECS/$spec\" >/dev/null 2>&1") != 0) {
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";
76 print S "$flags\n";
77 close(S);
78
79 if (system("perl ./specparser.pl \"tmp/$id/SPECS/$spec\" >> tmp/$id/to-spool") != 0) {
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
This page took 0.084612 seconds and 3 git commands to generate.