[Collab-qa-commits] r826 - svnbuildstat/trunk/script

goneri at alioth.debian.org goneri at alioth.debian.org
Sun Apr 27 18:56:51 UTC 2008


Author: goneri
Date: 2008-04-27 18:56:50 +0000 (Sun, 27 Apr 2008)
New Revision: 826

Modified:
   svnbuildstat/trunk/script/svnbuildstat_agent.pl
Log:
less verbose, use the inifile

Modified: svnbuildstat/trunk/script/svnbuildstat_agent.pl
===================================================================
--- svnbuildstat/trunk/script/svnbuildstat_agent.pl	2008-04-27 14:35:09 UTC (rev 825)
+++ svnbuildstat/trunk/script/svnbuildstat_agent.pl	2008-04-27 18:56:50 UTC (rev 826)
@@ -13,6 +13,7 @@
 use LWP::UserAgent;
 use HTTP::Response;
 use Proc::ProcessTable;
+use Config::IniFiles;
 
 ###########################################################################
 ###########################################################################
@@ -25,28 +26,43 @@
 
 my %job;
 
-#my $maxjobs = $config->agent_maxjobs;
-my $maxjobs = 3;
-my $vardir = "/home/goneri/svnbuildstat";
+die "You must be root!" unless $< == 0;
+
+my $inifile = "/etc/qabuild-agent.ini";
+my $cfg= Config::IniFiles->new( -file => $inifile ) or die "Can't load $inifile";
+my $debmirror = $cfg->val('path', 'debmirror');
+my $server = $cfg->val('path', 'server');
+my $vardir = $cfg->val('path', 'vardir');
+my $adminname = $cfg->val('admin', 'name');
+my $adminemail = $cfg->val('admin', 'email');
+my $adminteam = $cfg->val('admin', 'team');
+
+
+if (!$debmirror) {
+    die "Can't find the debmirror in $inifile";
+}
+if (!$server) {
+    die "Can't find the server in $inifile";
+}
+if (!$vardir || !-d $vardir) {
+    die "Can't find the vardir directory in $inifile";
+}
+
+my $maxjob = 1;
 my $workplace = $vardir."/workplace";
 my $pbuilderplace = $vardir."/pbuilder";
-#my $tarballsplace = $vardir."/tarballs";
 my $buildarea = $vardir."/report";
 my $tmpdir = $vardir."/tmp";
 my $aptcachedir = $vardir."/aptcache";
-my $debmirror = "http://ftp.fr.debian.org/debian/";
-my $admin = "Gonéri Le Bouder <goneri\@rulezlan.org>";
 my $pbuildertgz = "$pbuilderplace/$distro.tar.gz";
-my $server = "http://88.191.78.230:3000";
-my $keeptmpdir = 0;
 my $sigTermCatched = 0;
 my $exit = 0;
 sub sigterm {print "SIGTERM!\n";$sigTermCatched=1};
 $SIG{INT}= 'sigterm';
 
+my $keeptmpdir;
+die unless $maxjob =~ /^\d+$/;
 
-die unless $maxjobs =~ /^\d+$/;
-
 $ENV{LC_ALL} = 'C';
 $ENV{LANG} = 'C';
 
@@ -79,7 +95,9 @@
   my(@procs) =  @{$pt->table};
   my(@kids) = get_pids \@procs, @pids;
   @pids = (@pids, @kids);
-
+  print "pid to kill: ";
+  print $_." " foreach (@pids);
+  print "\n";
   kill $signal, @pids;
 
 } # end killfam
@@ -173,7 +191,9 @@
     Content_Type => 'form-data',
     Content => ['file' => [ $file, basename($file) ]]) or die "Upload failed\n";
 
-  print "report sent: ".$response->as_string()."\n";
+  if ($response->is_error) {
+    print "Failed to post file: ".$response->as_string()."\n";
+  }
 
 }
 
@@ -214,7 +234,7 @@
   my $req = POST $server."/controls/getBuildJob", Content_Type => 'form-data',
   Content      => [
   submit => 1,
-  content => "version=1\narch=$arch\n",
+  content => "arch=$arch\n",
   ];
   my $response = $ua->request($req);
   return unless $response->is_success();
@@ -276,9 +296,11 @@
   print "sending result that are in $threadbuildarea\n";
 
   $report->{'arch'} = $arch;
-  $report->{'admin'} = $admin;
   $report->{hostname} = $hostname;
   $report->{distro} = $distro;
+  $report->{adminname} = $adminname;
+  $report->{adminemail} = $adminemail;
+  $report->{adminteam} = $adminteam;
 
   $report->{'agent_release'} = $RELEASE;
   $report->{'pbuilder_release'} = `dpkg-query -W -f='\${Version}' pbuilder`;
@@ -401,12 +423,13 @@
     }
   }
 
-  if (keys %job < $maxjobs) {
+  if (keys %job < $maxjob) {
     my $newpid = fork;
     if ($newpid) { # Father
       $job{$newpid} = time;
     } else { # Son
       my $report = getBuildJob ();
+      print $report->{dsc}."\n";
       if (!exists($report->{dsc})) {
         print "Can't get a package to build from $server\n";
       } else {




More information about the Collab-qa-commits mailing list