[Collab-qa-commits] r820 - in svnbuildstat/trunk: . lib lib/SvnBuildStat lib/SvnBuildStat/Controller lib/SvnBuildStat/Model script

goneri at alioth.debian.org goneri at alioth.debian.org
Sun Apr 27 01:52:37 UTC 2008


Author: goneri
Date: 2008-04-27 01:52:36 +0000 (Sun, 27 Apr 2008)
New Revision: 820

Modified:
   svnbuildstat/trunk/lib/SvnBuildStat.pm
   svnbuildstat/trunk/lib/SvnBuildStat/Common.pm
   svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
   svnbuildstat/trunk/lib/SvnBuildStat/Controller/Packages.pm
   svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm
   svnbuildstat/trunk/script/svnbuildstat_import-new-report.pl
   svnbuildstat/trunk/svnbuildstat.ini
Log:
qa and build upload works fine now

Modified: svnbuildstat/trunk/lib/SvnBuildStat/Common.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Common.pm	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Common.pm	2008-04-27 01:52:36 UTC (rev 820)
@@ -11,8 +11,13 @@
 require Exporter;
 
 our @ISA = "Exporter";
-our @EXPORT = qw(mkTarballFromChangelogentry updateRepositoryentryDebianversion checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getDataFromDebianFtp parseControl parseChangelog createTarballUrlFromTarballlayout getTODO getTarballURLWithWatchfile);
+our @EXPORT = qw(mkTarballFromChangelogentry updateRepositoryentryDebianversion checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getDataFromDebianFtp parseControl parseChangelog createTarballUrlFromTarballlayout getTODO getTarballURLWithWatchfile recurseMkdir updateLastBuildSymlink);
 
+our $archs = "(i386|m68k|sparc|alpha|powerpc|".
+        "arm|mips|mipsel|hppa|ia64|s390|amd64|".
+        "ppc64|sh|armeb|m32r|hurd-i386|kfreebsd-gnu)";
+
+
 sub mkTarballFromChangelogentry {
   my $changelogentry = shift;
 
@@ -73,7 +78,7 @@
     return;
   }
   # TODO, no ini file access in a shared function
-  my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "Can't load config file";
+  my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "Can't load config file";
   my $vcscache = $cfg->val('path', 'vcscache');
   my $watchfile = $vcscache.'/'.$$repositoryentry->repository_id->id.$$repositoryentry->subdir.'/debian/watch';
   return unless -f $watchfile;
@@ -119,7 +124,7 @@
 sub getTarballURLWithWatchfile {
     my ($changelogentry) = shift;
   
-    my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "can't load config file";
+    my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "can't load config file";
 
   my $vcscache = $cfg->val('path', 'vcscache');
   my $watchfile = $vcscache.'/'.$$changelogentry->repositoryentry_id->repository_id->id.$$changelogentry->repositoryentry_id->subdir.'/debian/watch';
@@ -331,45 +336,70 @@
   return $ret;
 }
 
-sub getSourceDirectory {
-    my $changelogentry = shift;
+#sub getSourceDirectory {
+#    my $changelogentry = shift;
+#
+#    my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "can't load config file";
+#    my $repositoryurl = $cfg->val('path', 'repositoryurl');
+#    my $repositorydir = $cfg->val('path', 'repositorydir');
+#
+#
+#    my $path = '/'.$$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$$changelogentry->repositoryentry_id->changelogentry_id->id;
+#
+#    recurseMkdir($repositorydir.$path);
+#    
+#    my $ret = { 
+#        url => $repositoryurl.$path,
+#        dir => $repositorydir.$path
+#    };
+#
+#    return $ret;
+#
+#}
+# return the local directory where to store the files created after a build
+sub getResultDirectory {
+    my $build = shift;
 
-    my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "can't load config file";
-    my $repositoryurl = $cfg->val('path', 'repositoryurl');
-    my $repositorydir = $cfg->val('path', 'repositorydir');
+    my $buildDirectory = '/'.$$build->changelogentry_id->repositoryentry_id->repository_id->team_id->shortname.'/'.$$build->changelogentry_id->repositoryentry_id->sourcepackage_id->name.'/'.$$build->changelogentry_id->repositoryentry_id->changelogentry_id->id.'/build/'.$$build->id;
 
+    return $buildDirectory;
+}
 
-    my $path = '/'.$$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$$changelogentry->repositoryentry_id->changelogentry_id->id;
-
-    recurseMkdir($repositorydir.$path);
+sub getFullResultDirectory {
+    my $build = shift;
     
-    my $ret = { 
-        url => $repositoryurl.$path,
-        dir => $repositorydir.$path
-    };
+    my $resultdirectory = getResultDirectory($build);
+    return unless $resultdirectory;
 
-    return $ret;
+    my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "can't load config file";
+    #my $repositoryurl = $cfg->val('path', 'repositoryurl');
+    my $staticdir = $cfg->val('path', 'staticdir');
 
+    return $staticdir.'/files'.$resultdirectory;
 }
-# return the local directory where to store the files created after a build
-sub getBuildDirectory {
+
+sub updateLastBuildSymlink {
     my $build = shift;
 
-    my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "can't load config file";
-    my $repositoryurl = $cfg->val('path', 'repositoryurl');
-    my $repositorydir = $cfg->val('path', 'repositorydir');
+    my $resultdirectory = getResultDirectory($build);
+    return unless $resultdirectory;
 
+    my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "can't load config file";
+    #my $repositoryurl = $cfg->val('path', 'repositoryurl');
+    my $staticdir = $cfg->val('path', 'staticdir');
 
-    my $path = '/'.$$build->changelogentry_id->repositoryentry_id->repository_id->team_id->shortname.'/'.$$build->changelogentry_id->repositoryentry_id->sourcepackage_id->name.'/'.$$build->changelogentry_id->repositoryentry_id->changelogentry_id->id.'/build/'.$$build->id;
+    my $lastBuilDdir = $staticdir.'/files/'.$$build->changelogentry_id->repositoryentry_id->repository_id->team_id->shortname.'/'.$$build->changelogentry_id->repositoryentry_id->sourcepackage_id->name.'/'.$$build->changelogentry_id->repositoryentry_id->changelogentry_id->id.'/build/lastbuild';
+    recurseMkdir($lastBuilDdir);
 
-    recurseMkdir($repositorydir.$path);
+    my $lastsymlink = $lastBuilDdir."/last";
+    my $archsymlink = $lastBuilDdir."/".$$build->arch_id->name;
+    foreach my $symlink ($lastBuilDdir."/last", $lastBuilDdir."/".$$build->arch_id->name) {
+      unlink $symlink;
+      system ("ln -s ../".$$build->id." ".$symlink);
+      print ("ln -s ../".$$build->id." ".$symlink."\n");
+    }
 
-    my $ret = { 
-        url => $repositoryurl.$path,
-        dir => $repositorydir.$path
-    };
 
-    return $ret;
 }
 
 sub recurseMkdir {
@@ -379,9 +409,9 @@
     foreach ((split '/', $dir)) {
         $t .= "/".$_;
         mkdir $t unless -d $t;
+        return unless -d $t;
     }
-
+  1;
 }
 
-
 1;

Modified: svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm	2008-04-27 01:52:36 UTC (rev 820)
@@ -4,48 +4,17 @@
 use warnings;
 use base 'Catalyst::Controller';
 
-use File::Basename;
+use File::Glob ':glob';
 use File::Copy;
+use File::Basename;
 use Logger::Syslog;
 use SvnBuildStat::Common;
 use File::Glob qw/:glob/;
 
-my $archs = "(i386|m68k|sparc|alpha|powerpc|".
-        "arm|mips|mipsel|hppa|ia64|s390|amd64|".
-        "ppc64|sh|armeb|m32r|hurd-i386|kfreebsd-gnu)";
 
 
-sub loadInfofile {
-    my $infofile = shift;
 
-    my $ret = {};
 
-
-    my $endOfFile;
-    if (open (INFOFILE, "<".$infofile)) {
-        foreach (<INFOFILE>) {
-            $ret->{$1} = $2 if /^(.*?)=(.*)$/;
-#            if (/^-END-$/) {
-#                $endOfFile = 1;
-#                last;
-#            }
-        }
-        close INFOFILE;
-    } else {
-        print "failed to open ".$infofile."\n";
-        return;
-    }
-#    return unless $endOfFile;
-
-    my $basename = basename($infofile);
-    $ret->{packagesrc} = $1 if $basename =~ /^(.*?)_/;
-
-    return unless $ret->{packagesrc} or $ret->{id};
-
-    return $ret;
-}
-
-
 sub getBuildJob : Local {
     my ( $self, $c, $param ) = @_;
 
@@ -62,31 +31,34 @@
 
     }
 
-    if (!(defined ($params->{arch}) && $params->{arch} =~ /($archs)/)) {
+    if (!(defined ($params->{arch}) && $params->{arch} =~ /($SvnBuildStat::Common::archs)/)) {
         die "unspported arch";
     }
 
     my $changelogentry_id = $c->model('SvnBuildStat::Model::DB::Viewtobuild')->search({$params->{arch} => 'true' })->first->changelogentry_id;
+    die "Can't find a package to build" unless $changelogentry_id;
     my $changelogentry = $c->model('SvnBuildStat::Model::DB::Changelogentry')->search ({id => $changelogentry_id})->first;
 
-# lastbuildstart should in changelogentry directly
-    $changelogentry->lastbuildstart('now');
-    $changelogentry->update();
+# lastbuildstart should in changelogentry directly?
+    $changelogentry->lastbuildstart('now'); # TODO uncomment this
+    $changelogentry->update(); # TODO the same
 
 
     my $dscuri = $changelogentry->dscuri;
-    my $repositoryurl = $c->config->{path}->{repositoryurl};
-    $dscuri =~ s/\@REPOSITORY_URL@/$repositoryurl/;
+#    print $dscuri."\n";
+    die unless $c->config->{path}->{weburi};
+    my $repositoryuri = $c->config->{path}->{weburi}."/static/files";
+    $dscuri =~ s/\@REPOSITORY_URL@/$repositoryuri/;
 
-    $c->response->body("action=build\ndsc=$dscuri\nid=".$changelogentry->id);
+    # TODO create the qajob entry here!
 
+    $c->response->body("action=build\ndsc=$dscuri\nid=".$changelogentry->id."\n");
+
 }
 
 sub getQAJob : Local {
     my ( $self, $c, $param ) = @_;
 
-    my @uploadedFiles;
-    my $uploaddir = $c->config->{path}->{uploaddir};
     use Data::Dumper;
     die unless $c->request->body_parameters->{content};
 
@@ -97,49 +69,58 @@
         }
     }
 
-    die "qatool key missing" unless $params->{qatool} && $params->{version} || $params->{target};
+    die "qatool key missing" unless $params->{qatool};
+    die "invalide target" unless $params->{target} =~ /^(source|binary)$/;
 
-    my $qatool = $c->model('SvnBuildStat::Model::DB::Qatool')->find_or_create(name => $params->{qatool}, version => $params->{version});
+    my $qatool = $c->model('SvnBuildStat::Model::DB::Qatool')->find_or_create(name => $params->{qatool});
 
-    my $ret;
-
     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 $request = "select changelogentry.id,changelogentry.dscuri, build.id from build, changelogentry left join qajob on changelogentry.id=qajob.changelogentry_id AND qajob.qatool_id=".$qatool->id." WHERE build.changelogentry_id=changelogentry.id AND buildisok='1' order by changelogentry.date DESC, build.time DESC, lastjobstart IS NULL, lastjobstart, qajob.date LIMIT 1";
+
+    my @array  = $dbh->selectrow_array($request);
     my $changelogentry_id = $array[0];
-    die unless $changelogentry_id;
-    $ret .= "[global]\n";
-    $ret .= "changelogentry_id=".$changelogentry_id."\n";
+    my $dscuri = $array[1];
+    my $build_id = $array[2];
+    my $cookie = int (rand(0xfffffff));
+    die unless $changelogentry_id && $build_id;
+    my $changelogentry = $c->model('SvnBuildStat::Model::DB::Changelogentry')->search({id => $changelogentry_id})->first;
+    die unless $changelogentry;
+    die unless $c->config->{path}->{weburi};
 
-    my $buildh  = $dbh->selectall_arrayref("select build.id,arch.name from build, arch where changelogentry_id = ".$changelogentry_id." and arch_id=arch.id");
+    my $changesfile = bsd_glob($c->config->{path}->{staticdir}.'/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/*.changes");
+    my $changesuri = $c->config->{path}->{weburi}.'/static/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/".basename($changesfile);
 
-    $ret .= "archs=";
-    foreach (@$buildh) {
-        $ret .= $_->[1].", ";
-    }
-    $ret =~ s/, $//;# remove the last ', '
-    $ret .= "\n";
+#    print $dscuri."\n";
+    my $repositoryuri = $c->config->{path}->{weburi}."/static/files";
+    $dscuri =~ s/\@REPOSITORY_URL@/$repositoryuri/;
+    my $ret = "cookie=$cookie\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";
+    if ($params->{target} eq 'source') {
 
-    }
-print STDERR $ret."\n";
-#    $ret = "files=totor\n";
-#    foreach (keys %$tmp) {
-#        $ret .= $_.'='.$tmp->{$_}."\n";
-#    }
+        my $qajob = $c->model('SvnBuildStat::Model::DB::Qajob')->find_or_create(
+            qatool_id => $qatool->id,
+            changelogentry_id => $changelogentry_id,
+            build_id => undef,
+            cookie => $cookie,
+        );
+        $ret .= "qajob_id=".$qajob->id."\ndsc=$dscuri\n";
+        
+    } elsif ($params->{target} eq 'binary') {
 
+        my $qajob = $c->model('SvnBuildStat::Model::DB::Qajob')->find_or_create(
+            qatool_id => $qatool->id,
+            changelogentry_id => $changelogentry_id,
+            build_id => $build_id, 
+            cookie => $cookie
+        );
+
+        $ret .= "qajob_id=".$qajob->id."\nchangesuri=".$changesuri."\n";
+
+    } else {die}
+
+    $qajob->lastjobstart("NOW");
+    $qajob->update;
     $c->response->body($ret);
 
 }
@@ -155,6 +136,8 @@
     my $host = $c->model('SvnBuildStat::Model::DB::Host')->find_or_create(
         ip => $c->request->address
     );
+    $host->lastseen('NOW');
+    $host->update;
 
     die if $host->isblacklisted; 
 
@@ -166,104 +149,6 @@
         $c->response->body("ko ".$!);
     }
 
-
-
-
-    my $infofile;
-    if ($newfile =~ /\.info$/) {
-        $infofile = loadInfofile($newfile);
-
-        if (!-f $uploaddir.'/'.$infofile->{logfile}) { 
-            die("ko can't find the log file ".$uploaddir.'/'.$infofile->{logfile});
-        }
-
-        my $log;  
-        if (open LOGFILE, "<".$uploaddir.'/'.$infofile->{logfile}) {
-
-            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
-            $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;
-                $log .= $_;
-            }
-            close LOGFILE;
-        } else {
-            die ("Can't open ".$uploaddir.'/'.$infofile->{logfile});
-        }
-
-
-        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({
-                changelogentry_id => $changelogentry->id,
-                arch_id => $arch->id,
-                host_id => $host
-                });
-
-        $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->build_log ($log);
-
-        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+?_($archs)\.deb/) {
-                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
-
-                        );
-            }
-
-            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) {
-                print STDERR "file not found during the copy: ".$localfile."\n";
-                debug("file not found during the copy: ".$localfile);
-                die;
-            }
-            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;
-
-    }
     $c->response->body("ok");
 }
 

Modified: svnbuildstat/trunk/lib/SvnBuildStat/Controller/Packages.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Controller/Packages.pm	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Controller/Packages.pm	2008-04-27 01:52:36 UTC (rev 820)
@@ -21,17 +21,17 @@
 
 =cut
 
-sub mkTarballFromPackage {
-  my $package = shift;
+#sub mkTarballFromPackage {
+#  my $package = shift;
+#
+#  my $majorrelease = $$package->svndebrelease;
+#  $majorrelease =~ s/-[0-9A-Za-z\.~]*$//;
+#  # remove the EPOCH if exists
+#  $majorrelease =~ s/^\d+://;
+#
+#  $$package->name.'_'.$majorrelease.".orig.tar.gz";
+#}
 
-  my $majorrelease = $$package->svndebrelease;
-  $majorrelease =~ s/-[0-9A-Za-z\.~]*$//;
-  # remove the EPOCH if exists
-  $majorrelease =~ s/^\d+://;
-
-  $$package->name.'_'.$majorrelease.".orig.tar.gz";
-}
-
 sub index : Private {
   my ( $self, $c ) = @_;
 
@@ -74,108 +74,15 @@
 #    return;
   }
 
-  $c->stash->{template} = 'packages/main.tt2';
 
-}
 
-sub info : Local {
-  my ($self, $c, $name) = @_;
 
-  # Retrieve all of the book records as book model objects and store in the
-  # stash where they can be accessed by the TT template
-  my $package = $c->model('SvnBuildStat::Model::DB::Package')->search({name => $name})->first;
-  if (!$package) {
-    $c->response->redirect($c->uri_for('/'));
-    return;
-  }
+  $c->stash->{template} = 'packages/main.tt2';
 
-  my @currentchangelogentry = split $/, $package->currentchangelogentry;
-  my @todo = split $/, $package->todo;
-  $c->stash->{package} = $package->name;
-  $c->stash->{bugpic} = $package->name;
-  $c->stash->{bugpic} =~ s!^(.)(.+)$!http://people.debian.org/~glandium/bts/$1/$1$2.png! ;
-  $c->stash->{istarballpresent} = $package->istarballpresent;
-  $c->stash->{isindebian} = $package->isindebian;
-  $c->stash->{tarballuri} = $package->tarballuri;
-  $c->stash->{svndebrelease} = $package->svndebrelease;
-  $c->stash->{iswatchfilebroken} = $package->iswatchfilebroken;
-  $c->stash->{vcsuri} = $package->vcsuri;
-  $c->stash->{weburi} = $package->vcsuri;
-  $c->stash->{weburi} =~ s!svn://svn.debian.org/svn!http://svn.debian.org/wsvn!;
-  $c->stash->{isuptodate} = $package->isuptodate;
-  $c->stash->{upstreamrelease} = $package->upstreamrelease;
-  $c->stash->{currentchangelogentry} = \@currentchangelogentry;
-  $c->stash->{todo} = \@todo;
-  ############ Maintainers list
-  my $packagemaintainer_rs = $c->model('SvnBuildStat::Model::DB::PackageMaintainer')->search({package_id => $package->id});
-  $c->stash->{maintainers} = [ $packagemaintainer_rs->search_related("maintainer_id")->all ];
-
-  #############
-  my $bug_rs = $c->model('SvnBuildStat::Model::DB::Bug')->search(package_id => $package->id);
-  while (my $bug = $bug_rs->next) {
-  my $bugerror;
-  my $bugwarning;
-  $bugerror = 1 if ($bug->severity_id->name =~ /important|serious|grave|critical/);
-  $bugwarning = 1 if ($bug->severity_id->name =~ /normal/);
-  push @{$c->stash->{bugs}}, {
-  id => $bug->id,
-  name => $bug->name,
-  severity => $bug->severity_id->name,
-  error => $bugerror,
-  warning => $bugwarning }
-  }
-
-##########
-my $build = $c->model('SvnBuildStat::Model::DB::Build')->search({package_id => $package->id},{order_by => "id DESC"})->first;
-if ($build) {
-foreach (split $/, $build->lintian_log) {
-my $error;
-$error = 1 if /^E/;    
-push @{$c->stash->{lintians}}, { text => $_, error => $error };
 }
 
-foreach (split $/, $build->linda_log) {
-my $error;
-$error = 1 if /^E/;    
-push @{$c->stash->{lindas}}, { text => $_, error => $error } ;
-}
 
-$c->stash->{piupartsisok}  = $build->piupartsisok;
-}
-##############
 
-my $build_rs = $c->model('SvnBuildStat::Model::DB::Build')->search({package_id => $package->id},{order_by => "id DESC"});
-my $cpt;
-while (($cpt++ < 10) && (my $build = $build_rs->next)) {
-my $failedstep;
-if (!$build->buildisok) {
-		$failedstep = "build";
-}
-
-  push @{$c->stash->{builds}}, {
-    id => $build->id,
-    buildisok => $build->buildisok,
-    rev => $build->rev,
-    duration => $build->duration,
-    arch => $build->arch_id->name,
-    failedstep =>  $failedstep,
-    time => $build->time, 
-  }
-}
-
-
-
-# Set the TT template to use.  You will almost always want to do this
-# in your action methods (actions methods respond to user input in
-# your controllers).
-$c->stash->{template} = 'packages/info.tt2';
-
-}
-
-
-
-
-
 =head1 AUTHOR
 
 Goneri Le Bouder,,,

Modified: svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm	2008-04-27 01:52:36 UTC (rev 820)
@@ -18,13 +18,6 @@
 );
 
 
-sub count_users {
-  my $self = shift;
-  my $dbh = $self->dbh;
-  my $rows = $dbh->
-  selectall_arrayref('SELECT COUNT(id) FROM maintainer');
-  return $rows->[0]->[0]; # first row, then the first column
-}
 =head1 NAME
 
 SvnBuildStat::odel::DB - Catalyst DBIC Schema Model

Modified: svnbuildstat/trunk/lib/SvnBuildStat.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat.pm	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/lib/SvnBuildStat.pm	2008-04-27 01:52:36 UTC (rev 820)
@@ -27,8 +27,8 @@
 # with a external configuration file acting as an override for
 # local deployment.
 
-__PACKAGE__->config(name => 'SvnBuildStat');
-__PACKAGE__->config('Plugin::ConfigLoader' => { file => 'svnbuildstat.ini' } ); 
+#__PACKAGE__->config(name => 'SvnBuildStat');
+__PACKAGE__->config('Plugin::ConfigLoader' => { file => $ENV{HOME}.'/.svnbuildstat.ini' } ); 
 # Start the application
 __PACKAGE__->setup;
 

Modified: svnbuildstat/trunk/script/svnbuildstat_import-new-report.pl
===================================================================
--- svnbuildstat/trunk/script/svnbuildstat_import-new-report.pl	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/script/svnbuildstat_import-new-report.pl	2008-04-27 01:52:36 UTC (rev 820)
@@ -43,9 +43,9 @@
   $ret->{packagesrc} = $1 if $basename =~ /^(.*?)_/;
   $ret->{infofile} = basename($infofile);
   # to avoid error with split on undef value
-  $ret->{packages} = "" unless $ret->{packages};
+  $ret->{files} = "" unless $ret->{files};
 
-  return unless $ret->{packagesrc} or $ret->{id};
+#  return unless $ret->{packagesrc} or $ret->{id};
 
   return $ret;
 }
@@ -53,14 +53,56 @@
 sub cleanUp {
   my ($dir, $infofile) = @_;
 
-  debug ("purge of ".$infofile->{packagesrc});
-  foreach ($infofile->{infofile}, $infofile->{logfile}, split(' ', $infofile->{packages})) {
-    print " ->".$dir."/".$_."\n";
-    unlink $dir.'/'.$_;
+
+  unlink $dir.'/'.$infofile->{infofile} if $infofile->{infofile};
+  unlink $dir.'/'.$infofile->{logfile} if $infofile->{logfile};
+  unlink $dir.'/'.$infofile->{resultfile} if $infofile->{resultfile};
+
+  if ( $infofile->{files} =~ /\s/) {
+      foreach (split(' ', $infofile->{files})) {
+          next unless $_ && -f $_;
+          unlink $dir.'/'.$_;
+      }
+  } else {
+      unlink $dir.'/'.$infofile->{files} if $infofile->{files};
+
   }
 
 }
 
+sub parseQaResult {
+    my $resultfile = shift;
+
+    my $result = [];
+    if (!open RESULT, "<$resultfile") {
+        debug ("parseQaResult(): Failed to open $resultfile: $!");
+        return;
+    }
+    foreach (<RESULT>) {
+
+        my $qaseverity;
+        my $qatag;
+        my $qaresultentry;
+        if (/^(\w):\s(\S+)(| source):\s(\S+)\s(.*)/) {
+            $qaseverity = $1;
+            $qatag = $4;
+            $qaresultentry = $5;
+
+            push @$result, {
+                qaseverity => $1,
+                qatag => $4,
+                qaresultentry => $5
+            };
+        }
+
+    }
+
+    close RESULT;
+
+    return $result;
+}
+
+
 sub importBuild {
   return unless /\.info$/;
 
@@ -111,7 +153,7 @@
 
 
   my @localfile;
-  foreach (split(' ', $infofile->{packages})) {
+  foreach (split(' ', $infofile->{files})) {
     next unless /(deb|diff\.gz|dsc|changes)$/;
     
     if (/^(\S+?)_\S+?_($SvnBuildStat::Common::archs)\.(udeb|deb)/) {
@@ -138,8 +180,8 @@
     copy ($dir.'/'.$_, $debTargetDirectory."/".$_) or warn;
   }
 
-#  cleanUp ($dir, $infofile);
-#  $build->update;
+  cleanUp ($dir, $infofile);
+  $build->update;
   my $tarball = glob ($debTargetDirectory."/../../../*.orig.tar.gz");
   if ($tarball) {
     print $tarball."\n";
@@ -150,8 +192,55 @@
 }
 
 sub importQaJob {
-  return unless /\.job$/;
+  return unless /\.jobfile$/;
 
+  my $dir = $File::Find::dir;
+
+  print $File::Find::name."\n";
+
+  my $infofile = loadInfofile($File::Find::name);
+  if (!$infofile->{'resultfile'} || $infofile->{'qajob_id'} !~ /^\d+$/ || $infofile->{'cookie'} !~ /^\d+$/) {
+    cleanUp ($dir, $infofile);
+    return;
+  }
+  my $result = parseQaResult($infofile->{'resultfile'});
+  if (!$result) {
+      #cleanUp ($dir, $infofile);
+    return;
+  }
+
+  
+  my $changelogentry = $schema->resultset('Qajob')->search(id => $infofile->{'qajob_id'}, cookie => $infofile->{'cookie'})->first;
+
+  if (!$changelogentry) {
+      #cleanUp ($dir, $infofile);
+    return;
+  }
+
+
+  foreach (@$result) {
+      
+      my $qaseverity = $schema->resultset('Qaseverity')->find_or_create(letter => $_->{'qaseverity'});
+
+      my $qatag = $schema->resultset('Qatag')->find_or_create(name => $_->{'qatag'});
+      
+      my $qaresultentry = $schema->resultset('Qaresultentry')->find_or_create(
+          qatag_id => $qatag->id,
+          text => $_->{qaresultentry},
+          qajob_id => $changelogentry->id
+      );
+  }
+
+
+  $qajob->date("NOW");
+  $qajob->update;
+
+
+  #cleanUp ($dir, $infofile);
+
+
+
+
 }
 
 

Modified: svnbuildstat/trunk/svnbuildstat.ini
===================================================================
--- svnbuildstat/trunk/svnbuildstat.ini	2008-04-26 23:10:09 UTC (rev 819)
+++ svnbuildstat/trunk/svnbuildstat.ini	2008-04-27 01:52:36 UTC (rev 820)
@@ -1,13 +1,13 @@
 [db]
 dsn = DBI:Pg:host=127.0.0.1;dbname=svnbuildstat
 user = svnbuildstat
-password = XXXXX
+password = XXXXXXXX 
 
 [path]
+weburi = http://88.191.78.230:3000
 debmirror = http://ftp.fr.debian.org
-repositorydir = /home/goneri/public_html/debian
-repositoryurl = http://wawax.info/~goneri/debian
-uploaddir = /home/goneri/cache/svnbuildstat/uploads
+uploaddir = /home/goneri/cache/uploads
 vcscache = /home/goneri/cache/vcscache
 tarballdir = /home/goneri/cache/tarball
-webroot = /home/goneri/public_html/svnbuildstat
+tmpdir = /home/goneri/cache/tmp
+staticdir = /home/goneri/svn_svnbuildstat/trunk/root/static




More information about the Collab-qa-commits mailing list