[Collab-qa-commits] r1181 - buildstat/trunk/buildstat-server/script
goneri at alioth.debian.org
goneri at alioth.debian.org
Thu Aug 28 19:41:10 UTC 2008
Author: goneri
Date: 2008-08-28 19:41:09 +0000 (Thu, 28 Aug 2008)
New Revision: 1181
Modified:
buildstat/trunk/buildstat-server/script/svnbuildstat_update-db.pl
buildstat/trunk/buildstat-server/script/svnbuildstat_update-repository.pl
Log:
fix the git support and remove the tarball script
Modified: buildstat/trunk/buildstat-server/script/svnbuildstat_update-db.pl
===================================================================
--- buildstat/trunk/buildstat-server/script/svnbuildstat_update-db.pl 2008-08-28 19:18:39 UTC (rev 1180)
+++ buildstat/trunk/buildstat-server/script/svnbuildstat_update-db.pl 2008-08-28 19:41:09 UTC (rev 1181)
@@ -103,6 +103,19 @@
return $lastchange;
}
+sub repositoryentryHadBeenDelete {
+ my $repositoryentry = shift;
+
+ my $vcscache = $cfg->val('path', 'vcscache');
+ my $finaldir = $vcscache.'/'.$$repositoryentry->repository_id->id.$$repositoryentry->subdir;
+ if (-d $finaldir) {
+ info ("this repositoryentry doesn't exist anymore: ".$finaldir);
+ return;
+ }
+
+ return 1;
+}
+
sub updateRepositoryentry {
my $repositoryentry = shift;
@@ -268,13 +281,31 @@
updateChangelogentry($repositoryentry);
$$repositoryentry->lastcheck('now');
$$repositoryentry->update();
+
+ }
+
+
+# Delete removed repository entry
+ my $repositoryentry_rs = $schema->resultset('Repositoryentry')->search({
+ repository_id => $repository->id
+ });
+ while (my $repositoryentry = $repositoryentry_rs->next) {
+ if (repositoryentryHadBeenDelete(\$repositoryentry)) {
+ $repositoryentry->delete();
+ }
}
+
+
$repository->rev($currentrev);
$repository->lastcheck(DateTime::Format::Pg->format_timestamp_with_time_zone($begin));
$repository->update();
debug ($repository->name." updated in ".(time-$begin->epoch)." seconde(s)");
}
+
+
+
+
info ("stopping");
Modified: buildstat/trunk/buildstat-server/script/svnbuildstat_update-repository.pl
===================================================================
--- buildstat/trunk/buildstat-server/script/svnbuildstat_update-repository.pl 2008-08-28 19:18:39 UTC (rev 1180)
+++ buildstat/trunk/buildstat-server/script/svnbuildstat_update-repository.pl 2008-08-28 19:41:09 UTC (rev 1181)
@@ -56,25 +56,61 @@
sub fetchAndPrepareDirectoryForMergeWithUpstream {
- my ($repositoryentry, $workdir) = @_;
+ my ($repositoryentry, $workdir, $logfile) = @_;
+ open LOG, ">>$logfile" or warn;
- my $tarball = $$repositoryentry->changelogentry_id->tarball_id->name;
+ my $tarballdir = $cfg->val('path', 'tarballdir');
+ if (! -d $tarballdir) {
+ print "the tarball directory (`$tarballdir') doesn't exit\n";
+ error ("the tarball directory (`$tarballdir') doesn't exit");
+ exit 1;
+ }
+ my $tarball = mkTarballFromChangelogentry(\$$repositoryentry->changelogentry_id);
- debug("looks for the tarball");
+ debug("looks for a tarball");
+ print LOG ("try to find a tarball for the package:\n");
-# TODO Will always fails because I should check the
-# package repository directly
- if (!-f "$tarballdir/$tarball") {
- $$repositoryentry->changelogentry_id->tarball_id(undef);
+ my $tarballurl = getTarballURLFromDebianFtp(\$$repositoryentry->changelogentry_id);
+ if (!-s "$tarballdir/$tarball" && $tarballurl) {
+ if (getstore ($tarballurl, $tarballdir.'/'.$tarball.'.part') && move($tarballdir.'/'.$tarball.'.part', $tarballdir.'/'.$tarball)) {
+ info ("$tarball downloaded from Debian FTP");
+ print LOG (" tarball downloaded from Debian FTP\n");
+ $$repositoryentry->changelogentry_id->isindebian(1);
+ $$repositoryentry->changelogentry_id->update();
+ } else {
+ unlink $tarballdir.'/'.$tarball.'.part';
}
+ }
- my $cmd = "cp -lv $tarballdir/$tarball $workdir/$tarball";
- `$cmd`;
- if (!-f "$workdir/$tarball") {
- debug ("Failed to copy $tarballdir/$tarball to $workdir/$tarball");
- return;
+ # I only store tarball from Debian ftp on the tarballdir
+ if (-f "$tarballdir/$tarball") {
+ my $cmd = "cp -lv $tarballdir/$tarball $workdir/$tarball";
+ `$cmd`;
+ # TODO catch $cmd return code here
+ if (!-f "$workdir/$tarball") {
+ debug ("Failed to copy $tarballdir/$tarball to $workdir/$tarball");
+ print LOG ("Failed to copy $tarballdir/$tarball to $workdir/$tarball\n");
+ return;
+ }
+ print LOG (" use a cached tarball from Debian FTP\n");
+ } elsif ($tarballurl = getTarballURLFromTarballlayout(\$$repositoryentry) && getstore($tarballurl, "$workdir/$tarball")) {
+ debug ("$tarball downloaded thinks to the Tarball Layout");
+ print LOG (" tarball downloaded thinks to the tarball layout\n ($tarballurl)\n");
+
+ } elsif ($tarballurl = getTarballURLFromWatchfile(\$$repositoryentry->changelogentry_id) && getstore($tarballurl, "$workdir/$tarball")) {
+ debug ("$tarball downloaded thinks to the watchfile");
+ print LOG (" tarball downloaded fro upstream website thinks to the watchfile\n ($tarballurl)\n");
+ } else {
+ debug ("Failed to download $tarball.");
+ print LOG (" failed to find a tarball. This may be normal (upstream source in VCS or native package).\n\n");
+ # TODO : scan the repository for a tarball
+ return;
}
+
+
+
+
my $cwd = getcwd;
chdir $workdir or die;
my $pkgrootdirectory;
@@ -82,6 +118,8 @@
if (/^(.\/|)(.*?)\//) {
if ($pkgrootdirectory && $pkgrootdirectory ne $2) {
info("tarball has more than one root directory! I ignore it");
+ print LOG (" the tarball has more than one root directory! I ignore it.\n");
+ chdir $cwd;
return;
}
$pkgrootdirectory = $2;
@@ -90,8 +128,12 @@
`tar xf $tarball 2>&1`;
if (($? >> 8)!=0) {
info("failed to untar $tarball");
+ print LOG (" Failed to untar the tarball\n");
+ chdir $cwd;
return;
}
+ print LOG "\n\n";
+ close LOG;
# fix the rights of the files and directories in the tarball
`find $pkgrootdirectory -exec chmod +rw {} \\;`;
chdir $cwd;
@@ -110,12 +152,21 @@
my ($repositoryentry) = @_;
debug("prepareFromSvn: ".$$repositoryentry->sourcepackage_id->name);
+ my $destdir = $repositorydir.'/'.
+ $$repositoryentry->repository_id->id.'/'.
+ $$repositoryentry->sourcepackage_id->name.'/'.
+ $$repositoryentry->changelogentry_id->id;
+ `mkdir -p $destdir` unless -d $destdir;
+ my $logfile = $destdir."/sourcepackage-build.log"; # TODO Improve the log
+ unlink $logfile;
+
my $vcscache = $cfg->val('path', 'vcscache');
- my $localdir = $vcscache.'/'.$$repositoryentry->repository_id->id.$$repositoryentry->subdir;
+ my $localdir = $vcscache.'/'.$$repositoryentry->repository_id->id;
my $vcsname = $$repositoryentry->repository_id->vcs_id->name;
my $vcs = new SvnBuildStat::Vcs({
vcstype => $$repositoryentry->repository_id->vcs_id->name,
+ subdir => $$repositoryentry->subdir,
localdir => $localdir,
});
@@ -124,18 +175,12 @@
my $workdir = $tmpdir."/update-repository";
`rm -Rf $workdir; mkdir -p $workdir`;
-# chdir $workdir or die;
- my $pkgrootdirectory;
- if (!$$repositoryentry->changelogentry_id->isnative) {
- $pkgrootdirectory = fetchAndPrepareDirectoryForMergeWithUpstream($repositoryentry, $workdir);
- if (!$pkgrootdirectory) {
- debug ("Can't prepare ".$$repositoryentry->changelogentry_id->tarball_id->name);
- return;
- }
- } else {
+ my $pkgrootdirectory = fetchAndPrepareDirectoryForMergeWithUpstream($repositoryentry, $workdir, $logfile);
+ if (!$pkgrootdirectory) {
+ `rm -Rf $workdir; mkdir -p $workdir`;
$pkgrootdirectory = $$repositoryentry->sourcepackage_id->name.'-'.$$repositoryentry->changelogentry_id->version;
- `mkdir -p $workdir."/".$pkgrootdirectory`;
+ `mkdir -p $workdir/$pkgrootdirectory`;
}
my $vcsrev = $vcs->currentRev;
@@ -150,18 +195,15 @@
my $cwd = getcwd;
chdir $workdir or die;
- print `dpkg-source -b -W $pkgrootdirectory 2>&1`;
+ print `dpkg-source -b -W $pkgrootdirectory >> $logfile 2>&1`;
if (($? >> 8)!=0) {
debug ("failed to create .dsc for ".$$repositoryentry->sourcepackage_id->name);
+ chdir $cwd;
return;
}
chdir $cwd;
- my $destdir = $repositorydir.'/'.
- $$repositoryentry->repository_id->id.'/'.
- $$repositoryentry->sourcepackage_id->name.'/'.
- $$repositoryentry->changelogentry_id->id;
- `mkdir -p $destdir` unless -d $destdir;
+
my $dscfile;
foreach my $file (bsd_glob($workdir.'/*')) {
next unless -f $file;
@@ -215,18 +257,31 @@
#purgeOutDated();
-my $repositoryentry_rs = $schema->resultset('Repositoryentry');
+my $repositoryentry_rs = $schema->resultset('Repositoryentry')->search({
+-and => [
+ 'changelogentry_id.dscuri' => undef,
+ -or => [
+ 'changelogentry_id.dpkgsrcfaileddate' => { '<', "yesterday()"},
+ #'changelogentry_id.dpkgsrcfaileddate' => { '<', "now()"},
+ 'changelogentry_id.dpkgsrcfaileddate' => undef,
+ ],
+ ]},
+{
+join => [qw/ changelogentry_id /],
+}
+);
while (my $repositoryentry = $repositoryentry_rs->next) {
- if ($repositoryentry->changelogentry_id && !$repositoryentry->changelogentry_id->dscuri && $repositoryentry->changelogentry_id->tarball_id && !$repositoryentry->changelogentry_id->dpkgsrcfaileddate) {
+ #if ($repositoryentry->changelogentry_id && !$repositoryentry->changelogentry_id->dscuri && $repositoryentry->changelogentry_id->tarball_id && !$repositoryentry->changelogentry_id->dpkgsrcfaileddate) {
+
+ print "getcwd". getcwd . "\n";
print "prepare ".$repositoryentry->sourcepackage_id->name."\n";
if (!prepare(\$repositoryentry)) {
- print "“”dpkgsrcfailed for ".$repositoryentry->sourcepackage_id->name."\n";
+ print "pkgsrcfailed for ".$repositoryentry->sourcepackage_id->name."\n";
$repositoryentry->changelogentry_id->tarball_id(undef);
$repositoryentry->changelogentry_id->dpkgsrcfaileddate('now');
$repositoryentry->changelogentry_id->update;
}
- }
}
More information about the Collab-qa-commits
mailing list