2 # read email with request from stdin and process it
6 openlog("distfiles-rh", "pid", "user");
8 $spool_dir = "./spool";
9 $commits_list = "pld-cvs-commit\@lists.pld-linux.org";
16 # ---------------------------------------------------------------
23 system("rm -rf tmp/$id");
30 syslog("err","FATAL: $msg");
34 "From: $from <$from\@pld-linux.org>
35 Subject: DISTFILES: ERROR fetching sources for $spec ($branch)
36 X-distfiles-program: request-handler.pl";
41 Virtually Yours: distfiles.
44 open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
45 #open(M, "| cat") or die;
49 Message-ID: <$$." . time . "$id\@distfiles.pld-linux.org>
52 close(M) or die("problem while sending email");
54 open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
55 #open(M, "| cat") or die;
57 "To: <$from\@pld-linux.org>
59 Message-ID: <$$." . time . "$id\@distfiles.pld-linux.org>
62 close(M) or die("problem while sending email");
65 # ---------------------------------------------------------------
69 $id = rand if (!defined $id or $id eq "");
71 my $ref_pattern='[0-9a-zA-Z][0-9#a-zA-Z._\@/+ :,-]*';
74 /^X-Package: ([a-z0-9_.+-]+)/i and $spec = $1;
75 /^X-Branch: ($ref_pattern)/i and $branch = $1;
76 /^X-Login: ([a-z0-9_.]+)/i and $from = $1;
77 /^X-Flags: ([a-z0-9_ -]+)/i and $flags = $1;
81 syslog("err","FATAL: ill-formed request");
82 die "ill-formed request";
85 syslog("info","got request from $from for $spec at $branch ($flags)");
87 report_fatal("bad spec name") if (!defined $spec);
89 $oldcwd = Cwd::getcwd();
91 mkdir("tmp/$id") or die("cannot create: tmp/$id");
94 my $cvs_get = `~/distfiles/show_spec.sh $spec $branch 2>&1`;
98 $at_branch = " from branch $branch" if $branch;
100 report_fatal("cannot git fetch $spec$at_branch;\n$cvs_get\nexited with code $code");
105 syslog("info","spooling to tmp/$id/to-spool");
106 open(S, "> tmp/$id/to-spool");
107 print S "$from\@pld-linux.org\n";
112 if (system("perl ./specparser.pl \"tmp/$id/$spec\" tmp/$id/sources >> tmp/$id/to-spool") != 0) {
113 report_fatal("cannot parse $spec ($branch)")
116 if (!File::Copy::move("tmp/$id/to-spool", "$spool_dir/$id")) {
117 syslog("err","FATAL: move failed: $!");
118 die("move failed: $!");