[Po4a-commits] r2327 - in /trunk: Build.PL Makefile

barbier-guest at users.alioth.debian.org barbier-guest at users.alioth.debian.org
Fri Nov 19 22:05:54 UTC 2010


Author: barbier-guest
Date: Fri Nov 19 22:05:54 2010
New Revision: 2327

URL: http://svn.debian.org/wsvn/po4a/?sc=1&rev=2327
Log:
Move po4a-build call from Makefile to Build.PL

This is a work in progress; in po4a 0.41, I want to
remove the Makefile and do not let Build.PL call
po/bin/Makefile, see
  https://bugzilla.redhat.com/show_bug.cgi?id=629931

The proper way to let xgettext deal with different
languages is to call xgettext once for each language
and concatenate POT files.

Symlinking po4a-build.sh is no more needed.

Modified:
    trunk/Build.PL
    trunk/Makefile

Modified: trunk/Build.PL
URL: http://svn.debian.org/wsvn/po4a/trunk/Build.PL?rev=2327&op=diff
==============================================================================
--- trunk/Build.PL (original)
+++ trunk/Build.PL Fri Nov 19 22:05:54 2010
@@ -4,7 +4,6 @@
 use strict;
 use warnings;
 
-symlink ("share/po4a-build", "po4a-build.sh");
 my $builder = Module::Build->subclass
 (
     class => 'My::Builder',
@@ -12,10 +11,113 @@
 	sub ACTION_build {
 	    my $self = shift;
 	    $self->depends_on('code');
+	    $self->depends_on('po4a_build');
 	    $self->depends_on('docs');
 	    $self->depends_on('distmeta'); # regenerate META.yml
+	    $self->depends_on('man');
 	    $self->depends_on('postats');
 	}
+	sub ACTION_po4a_build {
+	    my $self = shift;
+	    system("./share/po4a-build -f po4a-build.conf") and die;
+	}
+
+	sub perl_scripts {
+	    return ('po4a-gettextize', 'po4a-updatepo', 'po4a-translate',
+	            'po4a-normalize', 'po4a', 'scripts/msguntypot');
+	}
+	sub shell_scripts {
+	    return ('share/po4a-build');
+	}
+	# Update po/bin/*.po files
+	sub ACTION_binpo {
+	    my $self = shift;
+
+	    my @perl_files = sort((perl_scripts(), @{$self->rscan_dir('lib',qr{\.pm$})}));
+	    my @shell_files = sort(shell_scripts());
+	    my @all_files = (@perl_files, @shell_files);
+	    unless ($self->up_to_date(\@all_files, "po/bin/po4a.pot")) {
+		print "XX Update po/bin/po4a-perl.pot\n";
+		my $podfiles = join ("", map {" ../../".$_ } @perl_files);
+		my $cmd = "cd po/bin; xgettext ";
+		$cmd .= "--from-code=utf-8 ";
+		$cmd .= "-L Perl ";
+		$cmd .= "--add-comments ";
+		$cmd .= "--msgid-bugs-address po4a\@packages.debian.org ";
+		$cmd .= "--package-name po4a ";
+		$cmd .= "--package-version ".$self->dist_version()." ";
+		$cmd .= "$podfiles ";
+		$cmd .= "-o po4a-perl.pot";
+		system($cmd) && die;
+
+		print "XX Update po/bin/po4a-shell.pot\n";
+		$podfiles = join ("", map {" ../../".$_ } @shell_files);
+		$cmd = "cd po/bin; xgettext ";
+		$cmd .= "--from-code=utf-8 ";
+		$cmd .= "-L shell ";
+		$cmd .= "--add-comments ";
+		$cmd .= "--msgid-bugs-address po4a\@packages.debian.org ";
+		$cmd .= "--package-name po4a ";
+		$cmd .= "--package-version ".$self->dist_version()." ";
+		$cmd .= "$podfiles ";
+		$cmd .= "-o po4a-shell.pot";
+		system($cmd) && die;
+
+		$cmd = "msgcat po/bin/po4a-perl.pot po/bin/po4a-shell.pot -o po/bin/po4a.pot.new";
+		system($cmd) && die;
+
+		unlink "po/bin/po4a-perl.pot" || die;
+		unlink "po/bin/po4a-shell.pot" || die;
+
+		if ( -e "po/bin/po4a.pot") {
+		    $diff = qx(diff -q -I'#:' -I'POT-Creation-Date:' -I'PO-Revision-Date:' po/bin/po4a.pot po/bin/po4a.pot.new);
+		    if ( $diff eq "" ) {
+			unlink "po/bin/po4a.pot.new" || die;
+			# touch it
+			my ($atime, $mtime) = (time,time);
+			utime $atime, $mtime, "po/bin/po4a.pot";
+		    } else {
+			rename "po/bin/po4a.pot.new", "po/bin/po4a.pot" || die;
+		    }
+		} else {
+		    rename "po/bin/po4a.pot.new", "po/bin/po4a.pot" || die;
+		}
+	    } else {
+		print "XX po/bin/po4a.pot uptodate.\n";
+	    }
+
+	    # update languages
+	    my @files = @{$self->rscan_dir('po/bin',qr{\.po$})};
+	    foreach (@files) {
+		next if m|/.#|;
+		$_ =~ /.*\/(.*)\.po$/;
+		my $lang = $1;
+
+		unless ($self->up_to_date("po/bin/po4a.pot","po/bin/$lang.po")) {
+		    print "XX Sync po/bin/$lang.po: ";
+		    system("msgmerge --previous po/bin/$lang.po po/bin/po4a.pot -o po/bin/$lang.po.new") && die;
+		    # Typically all that changes was a date. I'd
+		    # prefer not to commit such changes, so detect
+		    # and ignore them.
+		    $diff = qx(diff -q -I'#:' -I'POT-Creation-Date:' -I'PO-Revision-Date:' po/bin/$lang.po po/bin/$lang.po.new);
+		    if ($diff eq "") {
+			unlink "po/bin/$lang.po.new" || die;
+			# touch it
+			my ($atime, $mtime) = (time,time);
+			utime $atime, $mtime, "po/bin/$lang.po";
+		    } else {
+			rename "po/bin/$lang.po.new", "po/bin/$lang.po" || die;
+		    }
+		} else {
+		    print "XX po/bin/$lang.po uptodate.\n";
+		}
+		unless ($self->up_to_date("po/bin/$lang.po","blib/po/$lang/LC_MESSAGES/po4a.mo")) {
+		    system("mkdir -p blib/po/$lang/LC_MESSAGES") && die;
+		    system("msgfmt -o blib/po/$lang/LC_MESSAGES/po4a.mo po/bin/$lang.po") && die;
+		} 
+	    }
+	}
+
 	sub ACTION_install {
 	    my $self = shift;
 
@@ -27,13 +129,70 @@
 	    my $mandir = $self->install_map->{'blib/bindoc'};
 	    $mandir =~ s/\/man1$//;
 	    $install_map{'blib/man'} = $mandir;
+
+	    my $localedir = $mandir;
+	    $localedir =~ s/\/man$/\/locale/;
+	    $install_map{'blib/po'} = $localedir;
+
+	    ExtUtils::Install::install(\%install_map, 1, 0, $self->{args}{uninst}||0); 
+	}
+	sub ACTION_man {
+	    my $self = shift;
+
+	    use Pod::Man;
+	    use Encode;
+
+	    # Translate binaries manpages
+	    my %options;
+	    $options{utf8} = 1;
+	    my $parser = Pod::Man->new (%options);
+
+	    system("PERL5LIB=lib perl po4a --previous po/pod.cfg") and die;
 	    system("mkdir -p blib/man/man7") and die;
 	    system("mkdir -p blib/man/man1") and die;
-
-	    ExtUtils::Install::install(\%install_map, 1, 0, $self->{args}{uninst}||0); 
-	    system ("cp -R _build/po4a/man/* $mandir");
-	    system ("find . -name '*.1p' -delete");
-	    system ("find . -name '*.3pm' -delete");
+	    system("cp doc/po4a.7.pod blib/man/man7") and die;
+
+	    foreach $file (@{$self->rscan_dir('blib/man',qr{\.pod$})}) {
+		next if $file =~ m/^man7/;
+		my $out = $file;
+		$out =~ s/\.pod$//;
+		$section = $2;
+		$parser->{name} = $out;
+		$parser->{name} =~ s/^.*\///;
+		$parser->{name} =~ s/^(.*).(1p|3pm|7)/$1/;
+		$parser->{section} = $2;
+		if ($parser->{section} ne "3pm") {
+		    $parser->{name} = uc $parser->{name};
+		}
+
+		my $lang = $out;
+		$lang =~ s/^blib\/man\/([^\/]*)\/.*$/$1/;
+
+		if ($lang eq "man7") {
+			$parser->{release} = $parser->{center} = "Po4a Tools";
+		} else {
+			my $command;
+			$command = "msggrep -K -E -e \"Po4a Tools\" po/pod/$lang.po |";
+			$command .= "msgconv -t UTF-8 | ";
+			$command .= "msgexec /bin/sh -c '[ -n \"\$MSGEXEC_MSGID\" ] ";
+			$command .= "&& cat || cat > /dev/null'";
+
+			my $title = `$command 2> /dev/null`;
+			$title = "Po4a Tools" unless length $title;
+			$title = Encode::decode_utf8($title);
+			$parser->{release} = $parser->{center} = $title;
+		}
+		$parser->parse_from_file ($file, $out);
+
+		system("gzip -9 -f $out") and die;
+		system("rm -f $file") and die;
+	    }
+
+	    # Install the manpages of the Shell scripts
+	    system ("cp scripts/po4aman-display-po.1 scripts/po4apod-display-po.1 blib/man/man1/") and die;
+	    foreach $file (@{$self->rscan_dir('blib/man',qr{\.1$})}) {
+		system ("gzip -9 -f $file") and die;
+	    }
 	}
 
 	sub ACTION_dist {
@@ -41,6 +200,8 @@
 
 	    $self->depends_on('test');
 	    $self->depends_on('distdir');
+
+	    system("./share/po4a-build --pot-only -f ./po4a-build.conf") and die;
 
 	    my $dist_dir = $self->dist_dir;
 
@@ -54,6 +215,7 @@
 	} 
 	sub ACTION_postats {
 	    my $self = shift;
+	    $self->depends_on('binpo');
 	    $self->postats("po/bin");
 	    $self->postats("po/pod");
 	    $self->postats("po/www") if -d "po/www";

Modified: trunk/Makefile
URL: http://svn.debian.org/wsvn/po4a/trunk/Makefile?rev=2327&op=diff
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Fri Nov 19 22:05:54 2010
@@ -1,12 +1,11 @@
 all: Build
-	./share/po4a-build -f po4a-build.conf
 	@./Build
 
 Build: Build.PL
 	perl Build.PL
 
 update-po: Build
-	$(MAKE) -C po/bin update-po
+	./Build binpo
 
 install: Build
 	@./Build install destdir=$(DESTDIR)
@@ -17,10 +16,8 @@
 	@./Build realclean
 	$(MAKE) -C share clean
 	$(MAKE) -C po/bin clean
-	$(RM) po4a-build.sh
 
 dist: Build
-	./share/po4a-build --pot-only -f ./po4a-build.conf
 	$(MAKE) -C po/bin pot
 	@./Build dist
 




More information about the Po4a-commits mailing list