[Collab-qa-commits] r717 - svnbuildstat/trunk/script
goneri-guest at alioth.debian.org
goneri-guest at alioth.debian.org
Sun Feb 17 16:03:27 UTC 2008
Author: goneri-guest
Date: 2008-02-17 16:03:27 +0000 (Sun, 17 Feb 2008)
New Revision: 717
Added:
svnbuildstat/trunk/script/lintian_agent.pl
Log:
initial import of the script
Added: svnbuildstat/trunk/script/lintian_agent.pl
===================================================================
--- svnbuildstat/trunk/script/lintian_agent.pl (rev 0)
+++ svnbuildstat/trunk/script/lintian_agent.pl 2008-02-17 16:03:27 UTC (rev 717)
@@ -0,0 +1,122 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+#use lib "/home/sites/svnbuildstat.debian.net/svnbuildstat/lib";
+
+use Data::Dumper;
+use Net::FTP;
+use File::Glob ':glob';
+use Sys::Hostname;
+#use SvnBuildStat::Config;
+use LWP::Simple;
+use POSIX ":sys_wait_h";
+use File::Basename;
+use File::stat;
+use HTTP::Request::Common;
+use LWP::UserAgent;
+use HTTP::Response;
+
+my $hostname = hostname();
+my $server = "http://wawax.info:3000";
+my $admin = "Gonéri Le Bouder <goneri\@rulezlan.org>";
+chomp (my $arch = `dpkg-architecture -qDEB_HOST_ARCH`);
+
+sub getQAJob {
+ my $p;
+ my $report = {};
+
+ my $ua = LWP::UserAgent->new();
+ my $req = POST $server."/controls/getQAJob", Content_Type => 'form-data',
+ Content => [
+ submit => 1,
+ content => "version=1\narch=$arch\nqatool=lintian\ntarget=build\n",
+ ];
+ my $response = $ua->request($req);
+ return unless $response->is_success();
+
+ foreach (split $/, $response->content) {
+ chomp;
+
+ $report->{$1} = $2 if (/(.*)=(.*)/);
+ }
+ print Dumper($report);
+ return unless $report->{files};
+ return unless $report->{id};
+ $report;
+}
+
+
+sub sendReport {
+
+ my ($report, $threadbuildarea) = @_;
+
+ print "sending result that are in $threadbuildarea\n";
+
+ $report->{'arch'} = $arch;
+ $report->{'admin'} = $admin;
+ $report->{hostname} = $hostname;
+ #$report->{distro} = $distro;
+
+ #$report->{'agent_release'} = $RELEASE;
+ $report->{'pbuilder_release'} = `dpkg-query -W -f='\${Version}' pbuilder`;
+
+ my $tmp = basename($report->{dsc});
+ $tmp =~ s/\.dsc//;
+ my $prefix = $tmp."_".$arch."_$hostname";
+ my $logfile = $prefix.'.log';
+ my $infofile = $prefix.'.info';
+
+ open (BUILDLOGTMP, "<","$threadbuildarea/build.log.tmp") or die;
+ seek(BUILDLOGTMP, -20000, 2); # I just keep the end of the logfile
+ open (BUILDLOG, ">", "$threadbuildarea/".$logfile) or die;
+ # If I'm not at the end of BUILDLOGTMP it means that seek moved me
+ print BUILDLOG "(log file truncated) ... " if tell(BUILDLOGTMP);
+
+ foreach (<BUILDLOGTMP>) {
+ # To avoid strange breakage I do some clean up in the log file
+ s/[[:cntrl:]]//g;
+ print BUILDLOG $_."\n";
+ }
+ close BUILDLOGTMP;
+ close BUILDLOG;
+ unlink "$threadbuildarea/build.log.tmp";
+
+# Prepare and send the report
+# my $ftp = Net::FTP->new($ftphost, Debug => 0) or die "Cannot connect
+# to ".$ftphost.": $@";
+# $ftp->login($ftplogin,$ftppassword) or die "Cannot login ", $ftp->message;
+# $ftp->binary or die "Cannot switch to binary mode ", $ftp->message;
+# my $dir = $report->{package_id}.'-'.time;
+# $ftp->mkdir($dir); # Do not die since mkdir fails if the
+ # directory exist
+# $ftp->cwd($dir) or die "Can't cwd ", $ftp->message;
+
+ postFile($threadbuildarea."/".$logfile);
+ $report->{logfile} = $logfile;
+ if (bsd_glob($threadbuildarea.'/*.changes')) {
+ print "build is ok\n";
+ $report->{build} = "ok";
+ foreach (bsd_glob($threadbuildarea.'/*.deb'), bsd_glob($threadbuildarea.'/*.udeb')) {
+ $report->{binarypackages} = basename($_).' ';
+ postFile($_);
+ }
+ } else {
+ print "build is nok\n";
+ $report->{build} = "nok";
+ }
+
+
+ open (BUILDREPORT,">",$threadbuildarea."/".$infofile) or die "Can't open infofile";
+ foreach (sort keys %$report) {
+ chomp $report->{$_};
+ print BUILDREPORT $_."=".$report->{$_}."\n";
+ }
+ print BUILDREPORT "-END-\n";
+ close BUILDREPORT;
+ postFile ($threadbuildarea."/".$infofile);
+
+}
+
+
+print Dumper (getQAJob());
Property changes on: svnbuildstat/trunk/script/lintian_agent.pl
___________________________________________________________________
Name: svn:executable
+ *
More information about the Collab-qa-commits
mailing list