3 # read email with request from stdin and process it
5 $spool_dir = "./spool";
6 $commits_list = "pld-cvs-commit\@lists.pld-linux.org";
13 # ---------------------------------------------------------------
20 system("rm -rf tmp/$id");
27 open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
28 #open(M, "| cat") or die;
31 From: $from <$from\@pld-linux.org>
33 Cc: $from\@pld-linux.org
34 Message-ID: <$id\@distfiles.pld-linux.org>
35 Subject: DISTFILES: ERROR fetching sources for $spec ($branch)
36 X-distfiles-program: request-handler.pl
37 X-distfiles-version: $version
42 Virtually Yours: distfiles.
45 close(M) or die("problem while sending email");
48 # ---------------------------------------------------------------
52 $id = rand if (!defined $id or $id eq "");
54 my $ref_pattern='[0-9a-zA-Z][0-9#a-zA-Z._\@/+ :,-]*';
57 /^X-Package: ([a-z0-9_.+-]+)/i and $spec = $1;
58 /^X-Branch: ($ref_pattern)/i and $branch = $1;
59 /^X-Login: ([a-z0-9_.]+)/i and $from = $1;
60 /^X-Flags: ([a-z0-9_ -]+)/i and $flags = $1;
63 die "ill-formed request" if (!defined $from);
65 report_fatal("bad spec name") if (!defined $spec);
67 $oldcwd = Cwd::getcwd();
69 mkdir("tmp/$id") or die("cannot create: tmp/$id");
72 my $cvs_get = `~/distfiles/show_spec.sh $spec $branch 2>&1`;
76 $at_branch = " from branch $branch" if $branch;
78 report_fatal("cannot git fetch $spec$at_branch;\n$cvs_get\nexited with code $code");
83 open(S, "> tmp/$id/to-spool");
84 print S "$from\@pld-linux.org\n";
89 if (system("perl ./specparser.pl \"tmp/$id/$spec\" tmp/$id/sources >> tmp/$id/to-spool") != 0) {
90 report_fatal("cannot parse $spec ($branch)")
93 File::Copy::move("tmp/$id/to-spool", "$spool_dir/$id") or die("move failed: $!");