[Po4a-devel] Summary of changes for po4a-build methods

Neil Williams codehelp at debian.org
Tue Nov 10 20:41:51 UTC 2009


(The list doesn't seem to like attachments - that Makefile never made
it, so these are included directly.)

These are just for review, there are some extra files that actually
make the whole thing work, as well as a few updates in po4a-build
itself.

First, the changes to Build.PL - mainly simplification.

(Module::Build insists on foo.1p.gz and foo.3pm.gz, despite po4a-build
doing the right thing, so there's a simple `find -delete` to ensure the
po4a-build versions are used. The changes also leave the compression to
debhelper.)

diff -u po4a-cvs/Build.PL po4a-adapt/Build.PL
--- po4a-cvs/Build.PL	2009-07-21 17:38:56.000000000 +0100
+++ po4a-adapt/Build.PL	2009-11-10 18:31:49.000000000 +0000
@@ -13,12 +13,8 @@
 	    $self->depends_on('code');
 	    $self->depends_on('docs');
 	    $self->depends_on('distmeta'); # regenerate META.yml
-	    $self->depends_on('man');
 	    $self->depends_on('postats');
-	}
-	sub perl_scripts {
-	    return ('po4a-gettextize', 'po4a-updatepo', 'po4a-translate',
-	            'po4a-normalize', 'po4a', 'scripts/msguntypot');
+	    $self->depends_on('shell');
 	}
 	sub ACTION_install {
 	    my $self = shift;
@@ -32,169 +28,26 @@
 	    $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); 
+	    system ("cp -R _build/po4a/man/* $mandir");
+	    system ("find . -name '*.1p' -delete");
+	    system ("find . -name '*.3pm' -delete");
 	}
-	sub ACTION_binpo {
-	    my $self = shift;
-
-	    my @files = sort((perl_scripts(), @{$self->rscan_dir('lib',qr{\.pm$})}));
 
-	    unless ($self->up_to_date(\@files, "po/bin/po4a.pot")) {
-		print "XX Update po/bin/po4a.pot\n";
-		my $podfiles = join ("", map {" ../../".$_ } @files);
-		my $cmd = "cd po/bin; xgettext ";
-		$cmd .= "--from-code=utf-8 ";
-		$cmd .= "-L Perl ";
-		$cmd .= "--msgid-bugs-address po4a-devel\@lists.alioth.debian.org ";
-		$cmd .= "--package-name po4a ";
-		$cmd .= "--package-version ".$self->dist_version()." ";
-		$cmd .= "$podfiles ";
-		$cmd .= "-o po4a.pot.new";
-		system($cmd) && 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
-	    @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 cvs 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_manpo {
-	    my $self = shift;
-
-	    my $cmd = "PERL5LIB=lib perl po4a "; # Use this version of po4a
-	    $cmd .= "--previous ";
-	    $cmd .= "--no-translations ";
-	    $cmd .= "--msgid-bugs-address po4a-devel\@lists.alioth.debian.org ";
-	    $cmd .= "--package-name po4a ";
-	    $cmd .= "--package-version ".$self->dist_version()." ";
-	    $cmd .= "po/pod.cfg";
-	    system($cmd)
-		and die;
-	}
-	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);
+	sub ACTION_shell {
+	    my ($self) = @_;
 
-	    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;
-	    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;
+	    system ("cp -R share/doc/po4a/* blib/");
 	    foreach $file (@{$self->rscan_dir('blib/man',qr{\.1$})}) {
-		system ("gzip -9 -f $file") and die;
+#		system ("gzip -9 -f $file") and die;
 	    }
 	}
-	sub ACTION_dist {
-	    my ($self) = @_;
-
-	    $self->depends_on('test');
-	    $self->depends_on('distdir');
-
-	    my $dist_dir = $self->dist_dir;
-
-	    if ( -e "$dist_dir.tar.gz") {
-		# Delete the distfile if it already exists
-		system ("rm $dist_dir.tar.gz") && die;
-	    }
-
-	    $self->make_tarball($dist_dir);
-	    $self->delete_filetree($dist_dir);
-	} 
 	sub ACTION_postats {
 	    my $self = shift;
-	    $self->depends_on('binpo');
-	    $self->depends_on('manpo');
 	    $self->postats("po/bin");
 	    $self->postats("po/pod");
 	}
@@ -235,12 +88,14 @@
                     },
       script_files => ['po4a-gettextize', 'po4a-updatepo',
 	  'po4a-translate', 'po4a-normalize', 'po4a', 'scripts/msguntypot',
-	  'scripts/po4aman-display-po', 'scripts/po4apod-display-po'],
+	  'scripts/po4aman-display-po', 'scripts/po4apod-display-po',
+	  'share/po4a-build'],
       add_to_cleanup => ['t/tmp','messages.mo', 'blib',
 	  'po/pod/po4a-pod.pot~', 'po4a.log'],
       dist_abstract => 'Tools for helping translation of documentation',
       dist_author => ['Martin Quinson (mquinson#debian.org)',
-	  'Denis Barbier <barbier at linuxfr.org>']
+	  'Denis Barbier <barbier at linuxfr.org>',
+	  'Neil Williams <linux at codehelp.co.uk>']
   );
 
 $b->create_build_script;

A few changes in the Makefile (using new files in po/bin, mostly copied
from the share/ examples):

Only in po4a-adapt/po/bin/: LINGUAS
Only in po4a-adapt/po/bin/: Makefile
Only in po4a-adapt/po/bin/: Makevars
Only in po4a-adapt/po/bin/: POTFILES.in

diff -u po4a-cvs/Makefile po4a-adapt/Makefile
--- po4a-cvs/Makefile	2005-02-26 23:38:15.000000000 +0000
+++ po4a-adapt/Makefile	2009-11-10 19:00:32.000000000 +0000
@@ -1,4 +1,6 @@
 all: Build
+	./share/po4a-build -f share/po4a-build.conf
+	./share/po4a-build -f po4a-build.conf
 	@./Build
 
 Build: Build.PL
@@ -6,11 +8,17 @@
 
 install: Build
 	@./Build install destdir=$(DESTDIR)
+	make -C po/bin install DESTDIR=$(DESTDIR)
 
 clean: Build
 	@./Build realclean
+	$(MAKE) -C share clean
+	$(MAKE) -C po/bin clean
 
 dist: Build
+	./share/po4a-build --pot-only -f ./share/po4a-build.conf
+	./share/po4a-build --pot-only -f ./po4a-build.conf
+	$(MAKE) -C po/bin pot
 	@./Build dist
 
 stats: Build

(It may be worth moving po4a-build into scripts/ but that doesn't
affect the translation of the other shell scripts - doclifter can
generate XML and po4a can then translate it and po4a-build keep the
translated manpages in line.)

Add the po4a-build files to the manifest:

diff -u po4a-cvs/MANIFEST po4a-adapt/MANIFEST
--- po4a-cvs/MANIFEST	2009-11-10 19:43:30.000000000 +0000
+++ po4a-adapt/MANIFEST	2009-11-10 12:29:26.000000000 +0000
@@ -91,6 +91,20 @@
 po4a-normalize
 po4a-translate
 po4a-updatepo
+share/po4a-build
+
+# support files
+share/Makevars-perl.example
+share/po4a-build.conf
+share/ChangeLog
+share/Makevars-shell.example
+share/po4a-build.make
+share/README
+share/po4a-build.conf.example
+share/doc/po4a-build.xml
+share/po/Makevars
+share/po/POTFILES.in
+share/po/Makefile
 
 # the random additional cool scripts
 scripts/msguntypot

Changes in debian/control: (po4a-build, being shell, uses an XML
manpage and therefore build-depends are needed for xsltproc and the
XSL. This can also add support for the other shell scripts which are
translated by hand, AFAICT.

diff -u po4a-cvs/debian/control po4a-adapt/debian/control
--- po4a-cvs/debian/control	2009-08-30 15:34:19.000000000 +0100
+++ po4a-adapt/debian/control	2009-11-10 18:46:36.000000000 +0000
@@ -2,9 +2,11 @@
 Section: text
 Priority: optional
 Maintainer: Nicolas FRANCOIS (Nekral) <nicolas.francois at centraliens.net>
-Uploaders: Martin Quinson <mquinson at debian.org>, Pierre Machard <pmachard at debian.org>
+Uploaders: Martin Quinson <mquinson at debian.org>, Pierre Machard <pmachard at debian.org>,
+ Neil Williams <codehelp at debian.org>
 Standards-Version: 3.8.3
-Build-Depends-Indep: perl-modules (>= 5.10.0-16), libmodule-build-perl, gettext (>= 0.16)
+Build-Depends-Indep: perl-modules (>= 5.10.0-16), libmodule-build-perl, gettext (>= 0.16),
+ xsltproc, docbook-xsl
 Build-Depends: debhelper (>> 7.0.0)
 Homepage: http://po4a.alioth.debian.org/
 Vcs-Cvs: :pserver:anonymous at cvs.alioth.debian.org:/cvsroot/po4a

A few changes in debian/rules:

diff -u po4a-cvs/debian/rules po4a-adapt/debian/rules
--- po4a-cvs/debian/rules	2009-07-21 18:13:09.000000000 +0100
+++ po4a-adapt/debian/rules	2009-11-10 18:52:39.000000000 +0000
@@ -27,16 +27,15 @@
 	fi;
 
 	$(PERL) Build.PL installdirs=vendor create_packlist=0
-	$(PERL) Build
+	$(MAKE)
 	touch build-stamp
 
 clean:
 	dh_testdir
 	dh_testroot
-
-	-$(PERL) Build clean
+	$(RM) -r html t/tmp po/www
 	rm -rf _build build-stamp Build
-
+	$(MAKE) clean
 	dh_clean
 
 install: build
@@ -44,14 +43,8 @@
 	dh_testroot
 	dh_prep
 	dh_installdirs
-
+	$(MAKE) install DESTDIR=$(DESTDIR) prefix=/usr
 #	$(PERL) Build test
-	$(PERL) Build install destdir=$(DESTDIR)
-
-	for man in $(DESTDIR)/usr/share/man/man3/*.3pm; do \
-	    sed -i -e "s/ç/\\[,c]/g;s/Ç/\\[,C]/g" \
-	           -e "s/ü/\\[:u]/g;s/é/\\['e]/g" $$man; \
-	done
 
 # Build architecture-independent files here.
 binary-indep: build install
@@ -60,6 +53,9 @@
 	dh_installdocs NEWS
 	dh_installchangelogs changelog
 	dh_installexamples
+	dh_lintian
 	dh_compress
 	dh_fixperms
 	dh_installdeb

(lintian is to override the results of #555330)

Overall, these changes aren't that large and mainly involve removing
the duplication that arises from adding a build method to the package
that can be used by the package itself.

These look OK?

-- 


Neil Williams
=============
http://www.data-freedom.org/
http://www.linux.codehelp.co.uk/
http://e-mail.is-not-s.ms/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/po4a-devel/attachments/20091110/96ae6086/attachment.pgp>


More information about the Po4a-devel mailing list