Hi!

On Mon, 2020-05-18 at 11:04:27 +0200, Martin Quinson wrote:
> I tried to reproduce your bug with the integrated tests, but I failed
> to do so:
> https://travis-ci.org/github/mquinson/po4a/jobs/688267439#L2702
> 
> In the test, I have a line "[po_directory] po" in the config file, and
> it works with --srcdir and --destdir, all combinaisons:
> 
> Test44: 
>   Change directory to cfg/single-podirectory
>   perl po4a -f BUILDPATH/t/cfg/single-podirectory/po4a.conf --destdir 
> t/tmp/cfg/single-podirectory
> Test45:
>   Change directory to tmp/cfg/single-podirectory-src  
>   perl po4a -f BUILDPATH/t/cfg/single-podirectory/po4a.conf --srcdir 
> t/cfg/single-podirectory
> Test46:
>   perl po4a -f BUILDPATH/t/cfg/single-podirectory/po4a.conf --srcdir 
> cfg/single-podirectory --destdir tmp/cfg/single-podirectory-srcdst
> Test47: 
>   Change directory to tmp/cfg/single-podirectory-cur
>   perl po4a -f BUILDPATH/t/cfg/single-podirectory/po4a.conf
> 
> Maybe it's because I use the full path to the conf file, but it seems
> from your logs that this file is found, so I'm not sure.

Sven Joachim noticed that this was also happening while building dpkg,
when the man/po/dpkg-man.pot was newer than man/po/po4a.cfg, then also
noticed this bug report.

I started checking the code, and got the two attached patches which
fixes this for us. I've not checked further, whether any other
find_*_file() calls are swapped, nor whether there are other directory
creations missing, though, so that might be worth having a look over.

Thanks,
Guillem
From eaf4f65d4e57a06def62bf89db4f00dd4871be08 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Mon, 18 May 2020 23:39:11 +0200
Subject: [PATCH 1/2] po4a: Find the input .pot file for msgmerge in the srcdir
 too

The .pot file was being looked only in the destdir locations, but in
this particular call this is in fact an input file.
---
 po4a | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/po4a b/po4a
index 479d2aae..3426589a 100755
--- a/po4a
+++ b/po4a
@@ -1510,7 +1510,7 @@ if ( not $po4a_opts{"no-update"} ) {
         foreach $lang ( sort keys %po_filename ) {
             my ( $infile, $outfile ) =
               ( find_input_file( $po_filename{$lang} ), find_output_file( $po_filename{$lang} ) );
-            my $updated_potfile = find_output_file($pot_filename);
+            my $updated_potfile = find_input_file($pot_filename);
 
             if ( -e $infile ) {
 
-- 
2.26.2.761.g0e0b3e54be

From 496662828737d9080dd94ac7166a7f3a761e8601 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Mon, 18 May 2020 23:40:09 +0200
Subject: [PATCH 2/2] po4a: Generate the directory for the .po file for the
 msgmerge call

This is an output file, and if its directory is missing we need to
create it, otherwise msgmerge will fail.
---
 po4a | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/po4a b/po4a
index 3426589a..f831e3b4 100755
--- a/po4a
+++ b/po4a
@@ -1513,6 +1513,10 @@ if ( not $po4a_opts{"no-update"} ) {
             my $updated_potfile = find_input_file($pot_filename);
 
             if ( -e $infile ) {
+                my $dir = dirname( $outfile );
+                if ( not -d $dir ) {
+                    mkdir $dir or die wrap_msg( gettext("Can't create directory '%s': %s"), $dir, $! );
+                }
 
                 my $msgmerge_opt = $po4a_opts{"msgmerge-opt"};
                 $msgmerge_opt =~ s/\$lang\b/$lang/g if scalar @langs;
-- 
2.26.2.761.g0e0b3e54be

Reply via email to