Package: cvs-autoreleasedeb
Version: 0.12-1

Attached patch number 8 (last for now):
 We add more metadata to package.state, so we can easily generate
 reports:
 - The timestamp when the build began (we can sort a report by this field)
 - The SVN URL.
 - The SVN version that was built.

Thanks again for a really useful tool, I hope these patches will
help improve it further.

-- 
Oron Peled                                 Voice: +972-4-8228492
o...@actcom.co.il                  http://users.actcom.co.il/~oron
Free software: each person contributes a brick, but ultimately each
person receives a house in return.
           -- Brendan Scott
Index: svn-autoreleasedeb
===================================================================
--- svn-autoreleasedeb	(revision 398)
+++ svn-autoreleasedeb	(revision 399)
@@ -3,6 +3,7 @@
 use AptPkg::Config '$_config';
 use AptPkg::System '$_system';
 use AptPkg::Version;
+use URI;
 
 $_config->init;
 $_system = $_config->system;
@@ -176,6 +177,9 @@
 mkdir $::SVNDIR;
 mkdir $::PACKDIR;
 my %failed_packages;
+my %package_urls;
+my %package_svnversion;
+my %package_timestamp;
 my %prev_build_state;
 my %package_names;
 foreach my $s (keys %{$newpacks_struct}) {
@@ -217,8 +221,8 @@
 			system $cmd;
 		}
 		chdir($::SVNDIR.$s);
-                $cmd = "$::SVN checkout ".$conf_struct->{$s}{$p}{svnserver}.q(/).${prefix}.
-                  q(/).$p.q(/).$conf_struct->{$s}{$p}{tag}."/ ".${prefix}.$p;
+                my $url = $package_urls{$s}{$p};
+                $cmd = "$::SVN checkout '$url' '$prefix$p'";
 		print $cmd."\n";
 		unless (system($cmd) == 0) {
 			print "SVN Checkout failed. going to try again in the next run!\n";
@@ -231,6 +235,9 @@
 
 		my $buildopts = $conf_struct->{$s}{$p}{buildopts};
 		chdir($::SVNDIR.$s."/".${prefix}."/".$p);
+		my $svnversion = `svnversion`;
+		chomp $svnversion;
+		$package_svnversion{$s}{$p} = $svnversion;
 		$cmd = "svn-buildpackage --svn-override=buildArea=".$::PACKDIR.$s."/".$p." $buildopts ";
 
 		unless (system($cmd) == 0) {
@@ -238,6 +245,7 @@
 			$failed_packages{$s}{$p} = 'FAILED(buildpackage)';
 			next;
 		}
+		$package_timestamp{$s}{$p} = time;
 
 
                 if ($conf_struct->{$s}{$p}{option}{local}) {
@@ -362,9 +370,11 @@
 		}
 		while (<STATE>) {
 			chomp;
-			my ($s,$p,$v,$buildstate) = split(/;/, $_);
+			my ($s,$p,$v,$buildstate,$url,$ts,$sv) = split(/;/, $_);
 			$state_struct->{$s}{$p} = $v;
 			$prev_build_state{$s}{$p} = (defined $buildstate) ? $buildstate : 'UNKONWN';
+			$package_timestamp{$s}{$p} = $ts;
+			$package_svnversion{$s}{$p} = $sv;
 		}
 		close STATE;
 	}	
@@ -385,9 +395,14 @@
 	foreach my $s (keys %{$state_struct}) {
 		next if ref($state_struct->{$s}) ne "HASH";
 		foreach my $p (keys %{$state_struct->{$s}}) {
+			my $url = $package_urls{$s}{$p};
+			my $v = $state_struct->{$s}{$p};
 			my $buildstate = $failed_packages{$s}{$p};
+			my $ts = $package_timestamp{$s}{$p};
+			$ts = 0 unless defined $ts;
 			$buildstate = (defined $buildstate) ? $buildstate : 'OK';
-			print STATE join(';',($s,$p,$state_struct->{$s}{$p},$buildstate));
+			my $sv = $package_svnversion{$s}{$p};
+			print STATE join(';',($s,$p,$v,$buildstate,$url,$ts,$sv));
 			print STATE "\n";
 		}
 	}
@@ -455,6 +470,13 @@
 	foreach my $s (keys %{$conf_struct}) {
 		next if ref $conf_struct->{$s} ne "HASH";
 		foreach my $p (keys %{$conf_struct->{$s}}) {
+			my $tag = $conf_struct->{$s}{$p}{tag};
+			my $svnserver = $conf_struct->{$s}{$p}{svnserver};
+			my $prefix = $conf_struct->{$s}{$p}{prefix};
+			$prefix = '' unless defined $prefix;
+			my $uri = URI->new("$svnserver/$prefix/$p/$tag/")->canonical;
+			my $url = $uri->as_string;
+			$package_urls{$s}{$p} = $url;
 			if ($vs->compare($newstate_struct->{$s}{$p}, $state_struct->{$s}{$p}) > 0) {
 				# Use the date of the commit here.
 				$newpacks_struct->{$s}{$p} = scalar(localtime);

Reply via email to