[Fai-commit] r6239 - in trunk: . dev-utils

Michael Tautschnig mt at alioth.debian.org
Fri Dec 17 09:42:59 UTC 2010


Author: mt
Date: 2010-12-17 09:42:59 +0000 (Fri, 17 Dec 2010)
New Revision: 6239

Added:
   trunk/dev-utils/
   trunk/dev-utils/README
   trunk/dev-utils/setup-storage_deps-graph.pl
   trunk/dev-utils/svnlog2dch
Log:
New directory for scripts which are helpful for development of FAI but need not
end up in the binary packages. Initial contents (besides README explaining
usage):

- svnlog2dch: See "generate debian changelog from svn log" thread on
  linux-fai-devel
- setup-storage_deps-graph.pl: Build graphviz dot files from command sequence
  generated by setup-storage; helps to debug dependency errors


Added: trunk/dev-utils/README
===================================================================
--- trunk/dev-utils/README	                        (rev 0)
+++ trunk/dev-utils/README	2010-12-17 09:42:59 UTC (rev 6239)
@@ -0,0 +1,8 @@
+- svnlog2dch usage:
+  svn log -v -r"{`date +'%F %T %z' -r debian/changelog`}":HEAD | dev-utils/svnlog2dch
+
+- setup-storage_deps-graph.pl usage:
+  * Copy the Trying to add CMD, PRE, POST lines from a debug log to cmds.txt
+  * dev-utils/setup-storage_deps-graph.pl < cmds.txt > cmds.dot
+  * dot -Teps -ocmds.eps cmds.dot ; epstopdf cmds.eps
+

Added: trunk/dev-utils/setup-storage_deps-graph.pl
===================================================================
--- trunk/dev-utils/setup-storage_deps-graph.pl	                        (rev 0)
+++ trunk/dev-utils/setup-storage_deps-graph.pl	2010-12-17 09:42:59 UTC (rev 6239)
@@ -0,0 +1,56 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $latest_cmd = undef;
+my $latest_pre = undef;
+my $latest_post = undef;
+my %lines = ();
+
+while (<>) {
+  if (/^Trying to add CMD: (.*)$/) {
+    defined($latest_cmd) and die;
+    defined($latest_pre) and die;
+    defined($latest_post) and die;
+    $latest_cmd = $1;
+    $latest_cmd =~ s/"/\\"/g;
+  } elsif (/^PRE: ?(.+)?$/) {
+    defined($latest_cmd) or die;
+    defined($latest_pre) and die;
+    defined($latest_post) and die;
+    if (defined($1)) {
+      $latest_pre = $1;
+    } else {
+      $latest_pre = "START";
+    }
+  } elsif (/^POST: ?(.+)?$/) {
+    defined($latest_cmd) or die;
+    defined($latest_pre) or die;
+    defined($latest_post) and die;
+    if (defined($1)) {
+      $latest_post = $1;
+    } else {
+      $latest_post = "END";
+    }
+  } else {
+    die;
+  }
+  
+  if (defined($latest_post)) {
+    foreach my $pre (split(/,/, $latest_pre)) {
+      $pre =~ s/\//__/g;
+      foreach my $post (split(/,/, $latest_post)) {
+        $post =~ s/\//__/g;
+        $lines{"$pre -> $post [label=\"$latest_cmd\"];"} = ();
+      }
+    }
+    $latest_cmd = undef;
+    $latest_pre = undef;
+    $latest_post = undef;
+  }
+}
+
+print "digraph D {\n";
+print "$_\n" foreach(keys %lines);
+print "}\n";
+


Property changes on: trunk/dev-utils/setup-storage_deps-graph.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/dev-utils/svnlog2dch
===================================================================
--- trunk/dev-utils/svnlog2dch	                        (rev 0)
+++ trunk/dev-utils/svnlog2dch	2010-12-17 09:42:59 UTC (rev 6239)
@@ -0,0 +1,94 @@
+#! /usr/bin/perl
+
+#use Data::Dumper;
+
+# create Debian changelog from svn log -v -rX:Y output
+# Thomas Lange, lange at informatik.uni-koeln.de
+# 11/2010
+
+#    This program is free software; you can redistribute it and/or modify it
+#    under the same terms as Perl itself.
+
+# subroutine _do_log_commandline stolen from SVN::Log, http://search.cpan.org/~nikc/SVN-Log-0.03/lib/SVN/Log.pm
+# modified to get information we need
+
+# ==================================================
+
+sub _do_log_commandline {
+  my ($repos, $start_rev, $end_rev, $callback) = @_;
+
+#  open my $log, "svn log -v -r $start_rev:$end_rev $repos|"
+#    or die "couldn't open pipe to svn process: $!";
+
+#  my ($paths, $rev, $author, $date, $msg);
+
+  my $state = 'start';
+
+  my $seprule  = qr/^-{72}$/;
+  my $headrule = qr/r(\d+) \| (\w+) \| (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/;
+
+  # XXX i'm sure this can be made much much cleaner...
+  while (<>) {
+    if ($state eq 'start' or $state eq 'message' and m/$seprule/) {
+      if ($state eq 'start') {
+        $state = 'head';
+      } elsif ($state eq 'message') {
+        $state = 'head';
+        ####       $callback->($paths, $rev, $author, $date, $msg);
+        # print Dumper($paths);
+
+	# remove path from files, keep only file name
+	foreach (@files) { s#.+/##}
+	$fi = join ",", at files;
+	$msg = (split /\n/,$msg)[0]; # only first line of commit message
+	#DEBUG	print "FILES: $f\nAUT: $author\nMSG: $msg\n";
+	push @{$all{$author}},"$fi: $msg\n";
+      }
+    } elsif ($state eq 'head' and m/$headrule/) {
+      $rev = $1;
+      $author = $2;
+      $date = $3;
+      $paths = {};
+      @files=();
+      $msg = "";
+
+      $state = 'paths';
+    } elsif ($state eq 'paths') {
+      unless (m/^Changed paths:$/) {
+        if (m/^$/) {
+          $state = 'message';
+        } else {
+          if (m/^\s+(\w+) (.+)$/) {
+	    my $action = $1;
+	    my $str    = $2;
+
+	    # If a copyfrom_{path,rev} is listed then include it,
+	    # otherwise just note the path and the action.
+	    if($str =~ /^(.*?) \(from (.*?):(\d+)\)$/) {
+	      push @files,$1;
+	      $paths->{$1}{action} = $action;
+	      $paths->{$1}{copyfrom_path} = $2;
+	      $paths->{$1}{copyfrom_rev} = $3;
+	    } else {
+	      push @files,$str;
+	      $paths->{$str}{action} = $action;
+	    }
+          }
+        }
+      }
+    } elsif ($state eq 'message') {
+      $msg .= $_;
+    }
+  }
+}
+
+_do_log_commandline;
+
+# print changelog entries
+foreach (keys %all) {
+  print "  [ $_ ]\n"; #author
+  foreach (@{$all{$_}}) {
+    print "  * $_";
+  }
+  print "\n\n";
+}


Property changes on: trunk/dev-utils/svnlog2dch
___________________________________________________________________
Added: svn:executable
   + *




More information about the Fai-commit mailing list