[Collab-qa-commits] r724 - svnbuildstat/trunk/lib/SvnBuildStat/Controller
goneri-guest at alioth.debian.org
goneri-guest at alioth.debian.org
Sun Feb 17 22:42:23 UTC 2008
Author: goneri-guest
Date: 2008-02-17 22:42:22 +0000 (Sun, 17 Feb 2008)
New Revision: 724
Modified:
svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
Log:
build upload works fine, the buildhost can be blacklisted and the qa upload begin to be usuable
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-02-17 22:41:20 UTC (rev 723)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-02-17 22:42:22 UTC (rev 724)
@@ -6,6 +6,9 @@
use File::Basename;
use File::Copy;
+use Logger::Syslog;
+use SvnBuildStat::Common;
+use File::Glob qw/:glob/;
sub loadInfofile {
my $infofile = shift;
@@ -90,21 +93,51 @@
if (/(\S*)=(\S+)/) {
$params->{$1} = $2;
}
-
}
+ die "qatool key missing" unless $params->{qatool} && $params->{version} || $params->{target};
+ my $qatool = $c->model('SvnBuildStat::Model::DB::Qatool')->find_or_create(name => $params->{qatool}, version => $params->{version});
- die "checks key invalid" unless $params->{checks};
+ my $ret;
- my $tmp = {};
- $tmp = pickPackageToCheck($self, $c, $params);
+ my $dbh = $c->model('DB')->storage->dbh;
+ $dbh->do("SELECT * FROM qatool");
+ my @array = $dbh->selectrow_array("select changelogentry.id from changelogentry,build where build.changelogentry_id=changelogentry.id and changelogentry.id not in (select changelogentry_id from qajob where qatool_id=3 and lastjobstart < (now() - '03:00:00'::interval));");
+ my $changelogentry_id = $array[0];
+ die unless $changelogentry_id;
+ $ret .= "[global]\n";
+ $ret .= "changelogentry_id=".$changelogentry_id."\n";
- my $ret;
- foreach (keys %$tmp) {
- $ret .= $_.'='.$tmp->{$_}."\n";
+ my $buildh = $dbh->selectall_arrayref("select build.id,arch.name from build, arch where changelogentry_id = ".$changelogentry_id." and arch_id=arch.id");
+
+ $ret .= "archs=";
+ foreach (@$buildh) {
+ $ret .= $_->[1].", ";
}
+ $ret =~ s/, $//;# remove the last ', '
+ $ret .= "\n";
+ foreach (@$buildh) {
+ $ret .= "[".$_->[1]."]\n";
+ $ret .= "build_id=".$_->[0]."\n";
+ my $build = $c->model('SvnBuildStat::Model::DB::Build')->search(id => $_->[0])->first;
+ my $builddir = SvnBuildStat::Common::getBuildDirectory(\$build);
+ print STDERR "builddir".$builddir."\n";
+ $ret .= "files=";
+ foreach my $file (bsd_glob($builddir->{dir}.'/*')) {
+ $ret .= $builddir->{url}.'/'.basename($file).", ";
+ }
+ $ret =~ s/, $//;# remove the last ', '
+ $ret .= "\n";
+
+ }
+print STDERR $ret."\n";
+# $ret = "files=totor\n";
+# foreach (keys %$tmp) {
+# $ret .= $_.'='.$tmp->{$_}."\n";
+# }
+
$c->response->body($ret);
}
@@ -116,7 +149,15 @@
my ( $self, $c, $param ) = @_;
my @uploadedFiles;
- my $uploaddir = $c->config->{path}->{uploaddir};
+
+ my $host = $c->model('SvnBuildStat::Model::DB::Host')->find_or_create(
+ ip => $c->request->address
+ );
+
+ die if $host->isblacklisted;
+
+ my $uploaddir = $c->config->{path}->{uploaddir}."/".$host->ip;
+ SvnBuildStat::Common::recurseMkdir($uploaddir);
my $upload = $c->request->upload('file');
my $newfile = $uploaddir.'/'.basename($upload->filename);
if (!$upload->copy_to($newfile)) {
@@ -124,20 +165,14 @@
}
+
+
my $infofile;
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");
- }
- }
if (!-f $uploaddir.'/'.$infofile->{logfile}) {
- die("ko can't find the log file");
+ die("ko can't find the log file ".$uploaddir.'/'.$infofile->{logfile});
}
my $log;
@@ -145,7 +180,7 @@
seek(LOGFILE, -20000, 2); # I just keep the end of the logfile
# If I'm not at the end of BUILDLOGTMP means that seek moved the cursor
- $infofile->{log_file} = "(log file truncated) ... " if tell(LOGFILE);
+ $log = "(log file truncated) ... " if tell(LOGFILE);
foreach (<LOGFILE>) {
# To avoid strange breakage I do some clean up in the log file
s/[[:cntrl:]]//g;
@@ -156,8 +191,7 @@
die ("Can't open ".$uploaddir.'/'.$infofile->{logfile});
}
- 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});
my $changelogentry = $c->model('SvnBuildStat::Model::DB::Changelogentry')->search(id => $infofile->{id})->first;
my $build = $c->model('SvnBuildStat::Model::DB::Build')->find_or_create({
@@ -173,38 +207,58 @@
$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
+ my $debdist = SvnBuildStat::Common::getBuildDirectory(\$build);
+ if (!-d $debdist->{dir}) {
+ print STDERR ("destdir ".$debdist->{dir}." doesn't exist anymore");
+ debug("destdir ".$debdist->{dir}." doesn't exist anymore");
+ die;
+ }
+
+ my @localfile;
+ foreach (($infofile->{logfile}, split(' ', $infofile->{files}))) {
+ print STDERR $_."\n";
+ if (/^(\S+?)_\S+?_(amd64|i386|all|sparc|powerpc)\.deb/) {# TODO extend
+ my $deb = $c->model('SvnBuildStat::Model::DB::Deb')->find_or_create(name => $1);
+ my $arch = $c->model('SvnBuildStat::Model::DB::Arch')->find_or_create(name => $2);
+ my $build_deb = $c->model('SvnBuildStat::Model::DB::BuildDeb')->find_or_create(
+ deb_id => $deb->id,
+ build_id => $build->id,
+ arch_id => $arch->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) {
+ print STDERR "file not found during the copy: ".$localfile."\n";
+ debug("file not found during the copy: ".$localfile);
+ die;
}
+ push @localfile, $localfile;
+ }
+
+ foreach (split(' ', $infofile->{otherfiles})) {
my $localfile = $uploaddir.'/'.basename($_);
if (!-f $localfile) {
- debug ("Can't find $localfile");
- next;
+ print STDERR "file not found during the copy: ".$localfile."\n";
+ debug("file not found during the copy: ".$localfile);
+ die;
}
- if (!move ($localfile, $debdist.'/'.basename($_))) {
- debug ("Can't move $localfile in ".$debdist.'/'.basename($_).": ".$!);
- }
+ push @localfile, $localfile;
}
+ foreach my $localfile (@localfile) {
+ if (!move ($localfile, $debdist->{dir}.'/'.basename($localfile))) {
+ print STDERR ("Can't move $localfile in ".$debdist->{dir}.'/'.basename($localfile).": ".$!);
+ debug ("Can't move $localfile in ".$debdist->{dir}.'/'.basename($localfile).": ".$!);
+ system ("/bin/rm -r ".$debdist->{dir});
+ $build->delete();
+ die;
+ }
+ }
+
+
$build->update;
}
More information about the Collab-qa-commits
mailing list