[Collab-qa-commits] r574 - svnbuildstat/trunk/script
goneri-guest at alioth.debian.org
goneri-guest at alioth.debian.org
Wed Dec 12 16:59:37 UTC 2007
Author: goneri-guest
Date: 2007-12-12 16:59:36 +0000 (Wed, 12 Dec 2007)
New Revision: 574
Modified:
svnbuildstat/trunk/script/svnbuildstat_agent.pl
Log:
HTTP upload instead of FTP and some clean up
Modified: svnbuildstat/trunk/script/svnbuildstat_agent.pl
===================================================================
--- svnbuildstat/trunk/script/svnbuildstat_agent.pl 2007-12-12 16:58:52 UTC (rev 573)
+++ svnbuildstat/trunk/script/svnbuildstat_agent.pl 2007-12-12 16:59:36 UTC (rev 574)
@@ -13,9 +13,11 @@
use POSIX ":sys_wait_h";
use File::Basename;
use File::stat;
+use HTTP::Request::Common;
+use LWP::UserAgent;
+use HTTP::Response;
-
###########################################################################
###########################################################################
###########################################################################
@@ -30,33 +32,25 @@
#my $maxjobs = $config->agent_maxjobs;
my $maxjobs = 1;
-my $workplace = $config->agent_vardir."/workplace";
-my $pbuilderplace = $config->agent_vardir."/pbuilder";
-#my $tarballsplace = $config->agent_vardir."/tarballs";
-my $buildarea = $config->agent_vardir."/report";
-my $tmpdir = $config->agent_vardir."/tmp";
-my $ccachedir = $config->agent_vardir."/ccache";
-my $aptcachedir = $config->agent_vardir."/aptcache";
-my $debmirror = $config->agent_debmirror;
-my $buildadminaddr = $config->agent_buildadminaddr;
-my $ftphost = $config->agent_ftphost;
-my $ftplogin = $config->agent_ftplogin;
-my $ftppassword = $config->agent_ftppassword;
-my $serveruri = "http://localhost:3000/packages/tobuildv3";
+my $vardir = "/home/goneri/svnbuildstat/tmp";
+my $workplace = $vardir."/workplace";
+my $pbuilderplace = $vardir."/pbuilder";
+#my $tarballsplace = $vardir."/tarballs";
+my $buildarea = $vardir."/report";
+my $tmpdir = $vardir."/tmp";
+my $ccachedir = $vardir."/ccache";
+my $aptcachedir = $vardir."/aptcache";
+my $debmirror = "http://ftp.fr.debian.org/debian/";
+my $buildadminaddr = "Gonéri Le Bouder <goneri\@rulezlan.org>";
+my $server = "http://localhost:3000";
my $pbuildertgz = "$pbuilderplace/$distro.tar.gz";
-# XXX
-if ($config->agent_vardir !~ /\/.+/) {
- die "vardir not correclty set in the [agent] section";
-}
-
die unless $maxjobs =~ /^\d+$/;
$ENV{LC_ALL} = 'C';
$ENV{LANG} = 'C';
-die "please create: `".$config->agent_vardir unless -d
-$config->agent_vardir;
+die "please create: `".$vardir unless -d $vardir;
# TODO check for running script in background
# Purge
if (-d $workplace) {`rm -r $workplace`;}
@@ -82,6 +76,20 @@
#print CCACHECFG "BUILDRESULT=\"$tmpdir\"\n";
close CCACHECFG;
+sub postFile {
+ my $file = shift;
+
+ my $ua = new LWP::UserAgent;
+
+
+ my $response = $ua->request(POST $server.'/builds/upload',
+ Content_Type => 'form-data',
+ Content => ['file' => [ $file, basename($file) ]]) or die "Upload failed\n";
+
+ print "report sent: ".$response->as_string()."\n";
+
+}
+
sub isFull {
my $path = shift;
@@ -99,23 +107,22 @@
my $p;
my $report = {};
- my $serverOrder = LWP::Simple::get($serveruri.'/'.$arch);
+ my $serverOrder = LWP::Simple::get($server.'/packages/tobuildv3/'.$arch);
return unless $serverOrder;
foreach (split $/, $serverOrder) {
chomp;
- print "->".$_."\n";
$report->{$1} = $2 if (/(.*)=(.*)/);
}
return unless $report->{dsc};
- return unless $report->{package_id};
+ return unless $report->{id};
$report;
}
sub upgradeChroot {
- my $pdebuildparam = "--debootstrap debootstrap --mirror ".$debmirror." --buildplace $pbuilderplace --othermirror 'deb ".$debmirror." $distro main contrib non-free' --distribution $distro --basetgz $pbuildertgz";
+ my $pdebuildparam = "--debootstrap debootstrap --mirror ".$debmirror." --buildplace $pbuilderplace --othermirror 'deb ".$debmirror." $distro main contrib non-free' --distribution $distro --basetgz $pbuildertgz --debootstrap debootstrap";
if (-s $pbuildertgz) {
my $sb = stat($pbuildertgz);
if (time - $sb->ctime > 3600 * 24) {
@@ -139,6 +146,10 @@
}
}
}
+
+ if (! -s $pbuildertgz) {
+ print "No pbuilder tarball\n";
+ }
}
@@ -178,25 +189,26 @@
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
+# 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;
+# $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')) {
- print "sending $_\n";
- $ftp->put($_) or warn "Failed to send the info file\n";
+ $report->{binarypackages} = basename($_).' ';
+ postFile($_);
}
} else {
print "build is nok\n";
- $report->{build} = "ok";
$report->{build} = "nok";
}
@@ -208,11 +220,8 @@
}
print BUILDREPORT "-END-\n";
close BUILDREPORT;
+ postFile ($threadbuildarea."/".$infofile);
-
- $ftp->put($threadbuildarea."/".$infofile) or warn "Failed to send the info file\n";
- $ftp->close or warn "Failed to close the ftp connection to the server\n";
-
}
@@ -268,7 +277,7 @@
}
}
-# upgradeChroot();
+ upgradeChroot();
foreach my $pid (keys %job) {
if (time > $job{$pid} + 3600*4) {
@@ -290,7 +299,7 @@
} else {
my $report = howxsnext ();
if (!exists($report->{dsc})) {
- print "Can't get a package to rebuild\n";
+ print "Can't get a package to rebuild from $server\n";
} else {
build($report);
}
More information about the Collab-qa-commits
mailing list