[Collab-qa-commits] r662 - svnbuildstat/trunk/lib/SvnBuildStat/Controller
goneri-guest at alioth.debian.org
goneri-guest at alioth.debian.org
Sun Jan 20 21:29:40 UTC 2008
Author: goneri-guest
Date: 2008-01-20 21:29:40 +0000 (Sun, 20 Jan 2008)
New Revision: 662
Modified:
svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
Log:
save the binary package but I still have a bug with DBIx::Class to fix first
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-01-19 17:51:08 UTC (rev 661)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-01-20 21:29:40 UTC (rev 662)
@@ -5,8 +5,8 @@
use base 'Catalyst::Controller';
use File::Basename;
+use File::Copy;
-
sub loadInfofile {
my $infofile = shift;
@@ -17,17 +17,17 @@
if (open (INFOFILE, "<".$infofile)) {
foreach (<INFOFILE>) {
$ret->{$1} = $2 if /^(.*?)=(.*)$/;
- if (/^-END-$/) {
- $endOfFile = 1;
- last;
- }
+# if (/^-END-$/) {
+# $endOfFile = 1;
+# last;
+# }
}
close INFOFILE;
} else {
print "failed to open ".$infofile."\n";
return;
}
- return unless $endOfFile;
+# return unless $endOfFile;
my $basename = basename($infofile);
$ret->{packagesrc} = $1 if $basename =~ /^(.*?)_/;
@@ -47,7 +47,6 @@
my @uploadedFiles;
my $uploaddir = $c->config->{path}->{uploaddir};
- use Data::Dumper;
die unless $c->request->body_parameters->{content};
my $params = {};
@@ -76,7 +75,6 @@
$c->response->body("action=build\ndsc=$dscuri\nid=".$changelogentry->id);
-
}
sub getQAJob : Local {
@@ -120,19 +118,20 @@
my @uploadedFiles;
my $uploaddir = $c->config->{path}->{uploaddir};
my $upload = $c->request->upload('file');
- my $target = $uploaddir.'/'.basename($upload->filename);
- if (!$upload->copy_to($target)) {
+ my $newfile = $uploaddir.'/'.basename($upload->filename);
+ if (!$upload->copy_to($newfile)) {
$c->response->body("ko ".$!);
}
my $infofile;
- if ($target =~ /\.info$/) {
- $infofile = loadInfofile($target);
+ if ($newfile =~ /\.info$/) {
+ $infofile = loadInfofile($newfile);
# just in case a file is missing
if (exists $infofile->{binarypackages}) {
foreach (split(' ', $uploaddir.'/'.$infofile->{binarypackages})) {
+ # TODO add a checksum control here
next unless -f $uploaddir.'/'.$_;
die("ko can't find all the binary files");
}
@@ -157,7 +156,6 @@
die ("Can't open ".$uploaddir.'/'.$infofile->{logfile});
}
-# TODO move the files on the correct directoy
my $host = $c->model('SvnBuildStat::Model::DB::Host')->find_or_create(name => $infofile->{hostname},
arch => $infofile->{arch});
my $arch = $c->model('SvnBuildStat::Model::DB::Arch')->find_or_create(name => $infofile->{arch});
@@ -171,10 +169,42 @@
$build->time('now');
$build->svndebrelease ($infofile->{release});
$build->buildisok ($infofile->{build} eq "ok"?"true":"false");
- $build->duration
- ($infofile->{'stamp_build-end'}-$infofile->{'stamp_build-start'});
+ $build->duration($infofile->{'stamp_build-end'}-$infofile->{'stamp_build-start'});
$build->build_log ($log);
+
+ my $repositoryurl = $c->config->{path}->{repositoryurl};
+ my $debdist = $repositoryurl.'/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id;
+ foreach (split(' ', $infofile->{binarypackages})) {
+ if (/^(\S+?)_/) {
+ my $name = $1;
+ print STDERR "name: ".$name."\n";
+ my $binarypackage = $c->model('SvnBuildStat::Model::DB::Binarypackage')->find_or_create(name => $name);
+ print STDERR "binarypackage_id => ".$binarypackage->id.",\n".
+ "build_id => ".$build->id."\n";
+ my $binarypackage_build = $c->model('SvnBuildStat::Model::DB::BinarypackageBuild')->find_or_create(
+ binarypackage_id => $binarypackage->id,
+ build_id => $build->id
+ );
+ } else {
+ debug("malformed binary package name: $_");
+ }
+
+ if (!-d $debdist) {
+ debug("destdir $debdist doesn't exist anymore");
+ next;
+ }
+
+ my $localfile = $uploaddir.'/'.basename($_);
+ if (!-f $localfile) {
+ debug ("Can't find $localfile");
+ next;
+ }
+ if (!move ($localfile, $debdist.'/'.basename($_))) {
+ debug ("Can't move $localfile in ".$debdist.'/'.basename($_).": ".$!);
+ }
+ }
+
$build->update;
}
More information about the Collab-qa-commits
mailing list