[Collab-qa-commits] r663 - in svnbuildstat/trunk/lib/SvnBuildStat: . Model Vcs
goneri-guest at alioth.debian.org
goneri-guest at alioth.debian.org
Sun Jan 20 21:30:26 UTC 2008
Author: goneri-guest
Date: 2008-01-20 21:30:26 +0000 (Sun, 20 Jan 2008)
New Revision: 663
Removed:
svnbuildstat/trunk/lib/SvnBuildStat/Config.pm
Modified:
svnbuildstat/trunk/lib/SvnBuildStat/Common.pm
svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm
svnbuildstat/trunk/lib/SvnBuildStat/Vcs/Svn.pm
Log:
save some commited pending changes
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Common.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Common.pm 2008-01-20 21:29:40 UTC (rev 662)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Common.pm 2008-01-20 21:30:26 UTC (rev 663)
@@ -4,69 +4,96 @@
use warnings;
use LWP::UserAgent;
+use Config::IniFiles;
require Exporter;
our @ISA = "Exporter";
-our @EXPORT = qw(mkTarballFromPackage checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getDataFromDebianFtp parseControl parseChangelog createTarballUrlFromTarballlayout);
+our @EXPORT = qw(mkTarballFromChangelogentry checkRepositoryentryWatchfile testUrl mkRootdirectoryFromRepositoryentry getDataFromDebianFtp parseControl parseChangelog createTarballUrlFromTarballlayout getTODO getTarballURLWithWatchfile);
-sub mkTarballFromRepositoryentry {
- my $repositoryentry = shift;
+sub mkTarballFromChangelogentry {
+ my $changelogentry = shift;
- my $majorrelease = $$repositoryentry->svndebrelease;
- return unless $majorrelease;
- $majorrelease =~ s/^\d+://;
- $majorrelease =~ s/-[+0-9A-Za-z\.~]*$//;
-
- $$repositoryentry->sourcepackage_id->name.'_'.$majorrelease.".orig.tar.gz";
+ $$changelogentry->repositoryentry_id->sourcepackage_id->name.'_'.$$changelogentry->version.".orig.tar.gz";
}
-# The name of this function sucks
-sub checkRepositoryentryWatchfile {
- my ($repositoryentry) = shift;
- my $cmd;
+sub getTarballURLWithWatchfile {
+ my ($changelogentry) = shift;
+
+ my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "can't load config file";
- # TODO, no ini file access in a shared function
- my $cfg = Config::IniFiles->new( -file => "../svnbuildstat.ini" ) or die "Can't load config file";
my $vcscache = $cfg->val('path', 'vcscache');
- my $watchfile = $vcscache.'/'.$$repositoryentry->repository_id->id.$$repositoryentry->subdir.'/debian/watch';
+ my $watchfile = $vcscache.'/'.$$changelogentry->repositoryentry_id->repository_id->id.$$changelogentry->repositoryentry_id->subdir.'/debian/watch';
return unless -f $watchfile;
- my $majorrelease = $$repositoryentry->svndebrelease;
- return unless $majorrelease;
-
- $majorrelease =~ s/^\d+://;
- $majorrelease =~ s/-[0-9A-Za-z\.~]*$//;
- $majorrelease =~ s/dfsg.*//;
- $majorrelease =~ s/\d+://;
- $cmd = "uscan --package ".$$repositoryentry->sourcepackage_id->name." --dehs --upstream-version ".$majorrelease." --watchfile ".$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
my $tarballuri;
my $isuptodate = 'f';
my $iswatchfilebroken = 'f';
- my $upstreamrelease;
foreach (@uscan) {
$tarballuri = $1 if (/^<upstream-url>(.+tar\.gz)<\/upstream-url>$/i);
$isuptodate = 't' if (/^<status>up to date<\/status>$/);
- $upstreamrelease = $1 if (/^<upstream-version>(.+)<\/upstream-version>$/);
$iswatchfilebroken = 't' if (/^<errors>/);
}
- $iswatchfilebroken = 't' unless $upstreamrelease;
-
- $$repositoryentry->upstreamrelease($upstreamrelease);
- $$repositoryentry->isuptodate($isuptodate);
- $$repositoryentry->iswatchfilebroken($iswatchfilebroken);
- if ($isuptodate eq 't' && !$$repositoryentry->isindebian && $tarballuri =~ /(\.tar\.gz|tgz)$/i) {
- $$repositoryentry->tarballuri($tarballuri);
+
+ if ($isuptodate eq 't' && $tarballuri && $iswatchfilebroken eq 'f') {
+ return $tarballuri;
}
- $$repositoryentry->lastwatchcheck('now');
- $$repositoryentry->update();
+ return;
}
+## The name of this function sucks
+#sub checkrepositoryentrywatchfile {
+# my ($repositoryentry) = shift;
+# my $cmd;
+#
+# # todo, no ini file access in a shared function
+# my $cfg = config::inifiles->new( -file => "../svnbuildstat.ini" ) or die "can't load config file";
+# my $vcscache = $cfg->val('path', 'vcscache');
+# my $watchfile = $vcscache.'/'.$$repositoryentry->repository_id->id.$$repositoryentry->subdir.'/debian/watch';
+# return unless -f $watchfile;
+#
+# my $majorrelease = $$repositoryentry->svndebrelease;
+# return unless $majorrelease;
+#
+# $majorrelease =~ s/^\d+://;
+# $majorrelease =~ s/-[0-9a-za-z\.~]*$//;
+# $majorrelease =~ s/dfsg.*//;
+# $majorrelease =~ s/\d+://;
+# $cmd = "uscan --package ".$$repositoryentry->sourcepackage_id->name." --dehs --upstream-version ".$majorrelease." --watchfile ".$watchfile;
+# my @uscan = `$cmd`;
+# return unless @uscan > 2; # empty output
+#
+# my $tarballuri;
+# my $isuptodate = 'f';
+# my $iswatchfilebroken = 'f';
+# my $upstreamrelease;
+# foreach (@uscan) {
+# $tarballuri = $1 if (/^<upstream-url>(.+tar\.gz)<\/upstream-url>$/i);
+# $isuptodate = 't' if (/^<status>up to date<\/status>$/);
+# $upstreamrelease = $1 if (/^<upstream-version>(.+)<\/upstream-version>$/);
+# $iswatchfilebroken = 't' if (/^<errors>/);
+# }
+# $iswatchfilebroken = 't' unless $upstreamrelease;
+#
+# $$repositoryentry->upstreamrelease($upstreamrelease);
+# $$repositoryentry->isuptodate($isuptodate);
+# $$repositoryentry->iswatchfilebroken($iswatchfilebroken);
+# if ($isuptodate eq 't' && !$$repositoryentry->isindebian && $tarballuri =~ /(\.tar\.gz|tgz)$/i) {
+# $$repositoryentry->tarballuri($tarballuri);
+# }
+# $$repositoryentry->lastwatchcheck('now');
+#
+# $$repositoryentry->update();
+#}
+
+
# Return true if the file pointed by the URL exists
sub testUrl {
my $url = shift;
@@ -98,7 +125,7 @@
return unless $$repositoryentry->repository_id->tarballlayout;
my $packagename = $$repositoryentry->sourcepackage_id->name;
- my $tarball = SvnBuildStat::Common::mkTarballFromPackage($repositoryentry);
+ my $tarball = SvnBuildStat::Common::mkTarballFromChangelogentry($repositoryentry);
my $tarballuri = $$repositoryentry->repository_id->tarballlayout;
$tarballuri =~ s/\@TARBALL@/$tarball/;
$tarballuri =~ s/\@PACKAGE@/$packagename/;
@@ -107,10 +134,7 @@
}
sub getDataFromDebianFtp {
- my $repositoryentry = shift;
- return unless $$repositoryentry->svndebrelease;
- my $svndebrelease = $$repositoryentry->svndebrelease;
- $svndebrelease =~ s/^\d+://; # remove the EPOCH
+ my $changelogentry = shift;
my $ret = {};
$ret->{isindebian} = 'f';
@@ -120,12 +144,12 @@
$ua->agent("SvnBuildStat/0.1 ");
my $debmirror = 'http://ftp.debian.org/debian';
- my $debdiff .= $$repositoryentry->sourcepackage_id->name."_".$svndebrelease.".diff.gz";
- my $tarball = SvnBuildStat::Common::mkTarballFromRepositoryentry($repositoryentry);
+ my $debdiff .= $$changelogentry->repositoryentry_id->sourcepackage_id->name."_".$$changelogentry->version."-".$$changelogentry->debrevision.".diff.gz";
+ my $tarball = mkTarballFromChangelogentry($changelogentry);
if ($tarball) {
foreach my $section (qw/main contrib non-free/) {
- my $tmp = "$1/".$$repositoryentry->sourcepackage_id->name if $$repositoryentry->sourcepackage_id->name =~ /^(lib.|.)/;
+ 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)) {
@@ -141,8 +165,11 @@
}
sub parseControl {
- my $controlfile = shift;
+ my $localdir = shift;
+ my $controlfile = $localdir.'/debian/control';
+ return unless -f $controlfile;
+
my $ret = { maintainers => []};
open CONTROL, "<:encoding(UTF-8)", $controlfile or return;
@@ -177,47 +204,83 @@
}
sub parseChangelog {
- my $changelogfile = shift;
+ my $localdir = shift;
my $ret;
+ my $changelogfile = $localdir.'/debian/changelog';
+ return unless -f $changelogfile;
+
open CHANGELOG, "<:encoding(UTF-8)", $changelogfile or return;
my @changelog = <CHANGELOG>;
return unless (@changelog);
- if ($changelog[0] =~ /^\S+\s\((.*?)\)/) {
- $ret->{realsvndebrelease} = $1;
+ if ($changelog[0] =~ /^\S+\s\((\S+?)\)/) {
+ my $version = $1;
+ if ($version =~ /(\d+):\S+/) {
+ $ret->{epoch} = $1;
+ }
+ if ($version =~ /-(\S+)$/) {
+ $ret->{debrevision} = $1;
+ }
+ if ($version =~ /(|\d:)(\S+)$/) {
+ $ret->{version} = $2;
+ $ret->{version} =~s/-.*$//;
+ }
}
foreach (@changelog) {
s/[[:cntrl:]]//g;
- if (/^\S/ && $ret->{currentchangelogentry}) {
+ if (/^\S/ && $ret->{debchangelogentry}) {
# I ignore svn-bp empty template entry
- if ($ret->{currentchangelogentry} =~ /^.*\n\s\s\*\sNOT RELEASED YET\n\n\s--.*/m) {
- $ret->{currentchangelogentry} = '';
+ if ($ret->{debchangelogentry} =~ /^.*\n\s\s\*\sNOT RELEASED YET\n\n\s--.*/m) {
+ $ret->{debchangelogentry} = undef;
} else {
last;
}
}
- $ret->{currentchangelogentry} .= $_;
+ $ret->{debchangelogentry} .= $_;
}
- if ($ret->{currentchangelogentry} =~ /^\S+\s\((.*)\)/) {
- $ret->{svndebrelease} = $1;
- }
+# if ($ret->{text} =~ /^\S+\s\((\S+)\)/) {
+# $ret->{effectivedebrelease} = $1;
+# }
# looks for bug closed in the changelog entry
# the regex come from the BTS documentation
# TODO dpkg-parsechangelog is probably more suitable for the job :D
- # TODO do not store the bugs inline
- foreach ($ret->{currentchangelogentry} =~ /closes:\s*(?:bug)?\#\s*\d+(?:,\s*(?:bug)?\#\s*\d+)*/ig) {
- s/([A-Za-z]|#|:|\s)//g;
- $ret->{currentpendingbug} .= $_.',' if $_;
+ $ret->{currentpendingbug} = [];
+ foreach my $block ($ret->{debchangelogentry} =~ /closes:\s*(?:bug)?\#\s*\d+(?:,\s*(?:bug)?\#\s*\d+)*/ig) {
+ $block =~ s/([A-Za-z]|#|:|\s)//g;
+ if ($block) {
+ foreach (split /,/, $block) {
+ push @{$ret->{currentpendingbug}}, $1 if (/(\d+)/);
+ }
+ }
}
return $ret;
}
+sub getTODO {
+ my $localdir = shift;
+ my $ret;
+ my @todofiles = ('TODO.Debian', 'todo.Debian', 'TODO', 'todo');
+ foreach (@todofiles) {
+ my $todofile = $localdir.'/debian/'.$_;
+ if( -f $todofile) {
+ open TODO, "<:encoding(UTF-8)", $todofile or next;
+ $ret .= $_ foreach (<TODO>);
+ close TODO;
+ last;
+ }
+ }
+ return $ret;
+}
+
+
+
+
1;
Deleted: svnbuildstat/trunk/lib/SvnBuildStat/Config.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Config.pm 2008-01-20 21:29:40 UTC (rev 662)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Config.pm 2008-01-20 21:30:26 UTC (rev 663)
@@ -1,43 +0,0 @@
-package SvnBuildStat::Config;
-
-use AppConfig qw(:expand :argcount);
-
-sub new {
-
- my $file = "~/.svnbuildstat.conf";
- $file = "/usr/local/etc/svnbuildstat.conf" unless -f $file;
- $file = "/etc/svnbuildstat.conf" unless -f $file;
- die "Can't open config file" unless $file;
-
- my $self;
-
- $self = AppConfig->new({
- GLOBAL => {
- DEFAULT => "<unset>",
- ARGCOUNT => ARGCOUNT_ONE,
- },});
-
- # report injector
- $self->define( "report_sourcedir" => { ARGCOUNT => ARGCOUNT_ONE, });
- $self->define( "report_workdir" => { ARGCOUNT => ARGCOUNT_ONE, });
- $self->define( "report_rejecteddir" => { ARGCOUNT => ARGCOUNT_ONE, });
- # DB
- $self->define( "db_dsn" => { ARGCOUNT => ARGCOUNT_ONE, });
- $self->define( "db_user" => { ARGCOUNT => ARGCOUNT_ONE, });
- $self->define( "db_password" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- # Agent
- $self->define( "agent_ftphost" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_ftplogin" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_ftppassword" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_source" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_buildadminaddr" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_vardir" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "agent_debmirror" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- # Server
- $self->define( "server_repositorydir" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "" });
- $self->define( "server_repositoryurl" => {ARGCOUNT => ARGCOUNT_ONE, DEFAULT => "http://localhost/debian" });
-
- $self->file($file) or die "Can't load `$file'";
- return $self;
-}
-1;
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm 2008-01-20 21:29:40 UTC (rev 662)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Model/DB.pm 2008-01-20 21:30:26 UTC (rev 663)
@@ -4,17 +4,15 @@
use base 'Catalyst::Model::DBIC::Schema';
-use lib "/home/goneri/svn/pkg-games/people/goneri/svnbuildstat";
-use SvnBuildStat::Config;
+use Config::IniFiles;
+my $cfg = Config::IniFiles->new( -file => $ENV{HOME}."/.svnbuildstat.ini" ) or die "Can't load config file";
-
-my $config = new SvnBuildStat::Config;
__PACKAGE__->config(
schema_class => 'SvnBuildStat::Schema',
connect_info => [
- $config->db_dsn,
- $config->db_user,
- $config->db_password,
+ $cfg->val('db', 'dsn'),
+ $cfg->val('db', 'user'),
+ $cfg->val('db', 'password'),
{AutoCommit => 1, debug => 1}
]
);
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Vcs/Svn.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Vcs/Svn.pm 2008-01-20 21:29:40 UTC (rev 662)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Vcs/Svn.pm 2008-01-20 21:30:26 UTC (rev 663)
@@ -88,8 +88,9 @@
return unless $dir;
my $cmd = "cp -r $self->{localdir}/* $dir";
+ print " ->".$cmd."\n";
`$cmd`;
- $cmd = "find $dir -type d -name '.svn' -exec rm -Rf {} \\;";
+ $cmd = "find $dir -type d -name '.svn' -exec rm -Rf {} \\; 2>&1";
`$cmd`;
}
More information about the Collab-qa-commits
mailing list