[Collab-qa-commits] r1185 - buildstat/trunk/buildstat-server/lib/SvnBuildStat

goneri at alioth.debian.org goneri at alioth.debian.org
Fri Aug 29 18:51:28 UTC 2008


Author: goneri
Date: 2008-08-29 18:51:27 +0000 (Fri, 29 Aug 2008)
New Revision: 1185

Modified:
   buildstat/trunk/buildstat-server/lib/SvnBuildStat/Common.pm
Log:
rename getTarballURLWithWatchfile to getTarballURLFromWatchfile


Modified: buildstat/trunk/buildstat-server/lib/SvnBuildStat/Common.pm
===================================================================
--- buildstat/trunk/buildstat-server/lib/SvnBuildStat/Common.pm	2008-08-29 18:50:28 UTC (rev 1184)
+++ buildstat/trunk/buildstat-server/lib/SvnBuildStat/Common.pm	2008-08-29 18:51:27 UTC (rev 1185)
@@ -11,7 +11,7 @@
 require Exporter;
 
 our @ISA = "Exporter";
-our @EXPORT = qw(mkTarballFromChangelogentry updateRepositoryentryDebianversion checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getDataFromDebianFtp parseControl parseChangelog createTarballUrlFromTarballlayout getTODO getTarballURLWithWatchfile recurseMkdir updateLastBuildSymlink getQajobResultDirectory getFullQajobResultDirectory);
+our @EXPORT = qw(mkTarballFromChangelogentry updateRepositoryentryDebianversion checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getTarballURLFromDebianFtp parseControl parseChangelog getTarballURLFromTarballlayout getTODO getTarballURLFromWatchfile recurseMkdir updateLastBuildSymlink getQajobResultDirectory getFullQajobResultDirectory);
 
 our $archs = "(i386|m68k|sparc|alpha|powerpc|".
         "arm|mips|mipsel|hppa|ia64|s390|amd64|".
@@ -121,7 +121,8 @@
 
 
 
-sub getTarballURLWithWatchfile {
+sub getTarballURLFromWatchfile {
+# TODO store a cache for uscan returns in the DB
     my ($changelogentry) = shift;
   
     my $cfg = Config::IniFiles->new( -file => "/etc/buildstat-server/buildstat.ini" ) or die "can't load config file";
@@ -129,22 +130,24 @@
   my $vcscache = $cfg->val('path', 'vcscache');
   my $watchfile = $vcscache.'/'.$$changelogentry->repositoryentry_id->repository_id->id.$$changelogentry->repositoryentry_id->subdir.'/debian/watch';
   return unless -f $watchfile;
+  debug ("watchfile found at ".$watchfile);
 
   my $version =  $$changelogentry->version;
     my $cmd = "uscan --package ".$$changelogentry->repositoryentry_id->sourcepackage_id->name." --dehs --upstream-version ".$version." --watchfile ".$watchfile;
   my @uscan = `$cmd`;
   return unless @uscan > 2; # empty output
+  debug ("uscan return is ok");
 
   my $tarballuri;
   my $isuptodate = 'f';
   my $iswatchfilebroken = 'f';
   foreach (@uscan) {
-    $tarballuri = $1 if (/^<upstream-url>(.+tar\.gz)<\/upstream-url>$/i);
+    $tarballuri = $1 if (/^<upstream-url>(.+\.(tgz|tar\.gz))<\/upstream-url>$/i);
     $isuptodate = 't' if (/^<status>up to date<\/status>$/);
     $iswatchfilebroken = 't' if (/^<errors>/);
   }
 
-  if ($isuptodate eq 't' && $tarballuri && $iswatchfilebroken eq 'f') {
+  if ($isuptodate eq 't' && testUrl($tarballuri)) {
     return $tarballuri;
   }
 
@@ -177,7 +180,7 @@
 
 
 
-sub createTarballUrlFromTarballlayout {
+sub getTarballURLFromTarballlayout {
   my ($repositoryentry) = @_;
 
   return unless $$repositoryentry->repository_id->tarballlayout;
@@ -187,38 +190,35 @@
   $tarballuri =~ s/\@TARBALL@/$tarball/;
   $tarballuri =~ s/\@PACKAGE@/$packagename/;
 
-  return $tarballuri;
+  return $tarballuri if testUrl($tarballuri);
+  return;
 }
 
-sub getDataFromDebianFtp {
+sub getTarballURLFromDebianFtp {
   my $changelogentry = shift;
 
-  my $ret = {};
-  $ret->{isindebian} = 'f';
-  $ret->{tarballuri} = '';
-
+# TODO rewrite this part to be more efficiant by using mirror index files
   my $ua = LWP::UserAgent->new;
-  $ua->agent("SvnBuildStat/0.1 ");
+  $ua->agent("BuildStat/0.1 ");
 
-    my $debmirror = 'http://ftp.debian.org/debian';
-    my $debdiff .= $$changelogentry->repositoryentry_id->sourcepackage_id->name."_".$$changelogentry->version."-".$$changelogentry->debrevision.".diff.gz";
+   my $cfg = Config::IniFiles->new( -file => "/etc/buildstat-server/buildstat.ini" ) or die "can't load config file";
+
+    my $debmirror = $cfg->val('path', 'debmirror');
+    die "debmirror is unset!" unless $debmirror;
+
     my $tarball = mkTarballFromChangelogentry($changelogentry);
 
     if ($tarball) {
       foreach my $section (qw/main contrib non-free/) {
         my $tmp = "$1/".$$changelogentry->repositoryentry_id->sourcepackage_id->name if $$changelogentry->repositoryentry_id->sourcepackage_id->name =~ /^(lib.|.)/;
-        my $debdiffuri = $debmirror.'/pool/'.$section.'/'.$tmp.'/'.$debdiff;
         my $tmp_tarballuri = $debmirror.'/pool/'.$section.'/'.$tmp.'/'.$tarball;
-        if (testUrl($debdiffuri)) {
-          $ret->{isindebian} = 't';
-        }
         if (testUrl($tmp_tarballuri)) {
           $tmp_tarballuri =~ s/^$debmirror/\@DEBMIRROR@/;
-          $ret->{tarballuri} = $tmp_tarballuri;
+          return $tmp_tarballuri;
         }
       }
   }
-  $ret;
+  return;
 }
 
 sub parseControl {




More information about the Collab-qa-commits mailing list