mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
123 stars 61 forks source link

Package po4a fails to build in OBS #338

Closed vigneshraman closed 2 years ago

vigneshraman commented 2 years ago

Package po4a fails to build in OBS for Debian_11 with the below error,

https://build.opensuse.org/package/show/home:vigneshraman/po4a

Tested with version 0.62 and 0.65

not ok 8 - Provided command (retcode: 256)
# Expected retcode: 0
# FAILED command: PODIFF  core/porefs/_counter.po  tmp/core/porefs/up.po 2>&1 > tmp/core/porefs/_cmd_output
# Command output:
# | --- core/porefs/_counter.po 2020-12-07 15:19:44.000000000 +0000
# | +++ tmp/core/porefs/up.po   2021-12-03 06:08:17.705502421 +0000
# | @@ -1,7 +1,7 @@
# | -# Language up translations for po package
# | -# Copyright (C) 2020 Free Software Foundation, Inc.
# | -# This file is distributed under the same license as the po package.
# | -# Automatically generated, 2020.
# | +# Language up translations for PACKAGE package
# | +# Copyright (C) 2021 Free Software Foundation, Inc.
# | +# This file is distributed under the same license as the PACKAGE package.
# | +# Automatically generated, 2021.
# |  #
# |  msgid ""
# |  msgstr ""
# (end of output)

Reported the issue in https://bugzilla.opensuse.org/show_bug.cgi?id=1193355

As Andreas mentioned replaced po with PACKAGE and 2020 with 2021 for all the failing po files and the build was successful.

diff --git a/t/cfg/multiple-nopo/_multiple.de.po b/t/cfg/multiple-nopo/_multiple.de.po
index 073f261..d598210 100644
--- a/t/cfg/multiple-nopo/_multiple.de.po
+++ b/t/cfg/multiple-nopo/_multiple.de.po
@@ -1,7 +1,7 @@
-# German translations for po package
-# Copyright (C) 2020 Free Software Foundation, Inc.
-# This file is distributed under the same license as the po package.
-# Automatically generated, 2020.
+# German translations for PACKAGE package
+# Copyright (C) 2021 Free Software Foundation, Inc.
+# This file is distributed under the same license as the PACKAGE package.
+# Automatically generated, 2021.
 #
 msgid ""
 msgstr ""
vigneshraman commented 2 years ago

Please could you confirm if we can manually replace the strings (po with PACKAGE and 2020 with 2021) to fix this issue. Thanks.

mquinson commented 2 years ago

msginit is getting annoying. There is no way to control its output in a reliable manner. This is why we ask diff to ignore many lines when checking whether the test passes.

I think that changing 'po' to 'PACKAGE' should be enough. But actually, I'd like to understand why it fails on your setup and not on mine nor on the automated tests here on github, if possible.

A better solution maybe would be to get rid of msginit and generate the empty PO files ourselves. I'm unsure, because I prefer to not dupplicate code, but msginit might be a specific case here.

jnavila commented 2 years ago

This is (again) a problem with /usr/lib/gettext/project-id 's obsolete and dumb heuristic for detecting project name and version from directory names in cwd.

vigneshraman commented 2 years ago

But actually, I'd like to understand why it fails on your setup and not on mine nor on the automated tests here on github, if possible.

It fails only in OBS environment, https://build.opensuse.org/package/show/home:vigneshraman/po4a https://bugzilla.opensuse.org/show_bug.cgi?id=1193355

When I build the package in my local setup (debian 11) it builds fine. I will try to check if there is any difference in the setup which causes the failure only in OBS.

jnavila commented 2 years ago

Let me make an educated guess: the name of the directory containing your project is po4a on your laptop.

Now rename it and try running the tests again:

$  cd ..
$ mv po4a foo
$ cd foo
$ perl Build.PL
$ ./Buid test verbose=1

That's a reproducible failure. Any human will clone the project po4a and get a directory named po4a for the project. From this name, project-id, from /usr/lib/gettext/project-id infers a project name po and a version 4... All our tests depend on this checkout directory name. That's an assumption that is easily broken by automatic build systems.

mquinson commented 2 years ago

Many thanks, @jnavila, I was struggling remembering about this error that already bugged us in the past.

I just had a quick grep at the gettext sources, and it seems that this script is only used in msginit to guess the PACKAGE and VERSION when the Project-Id-Version header is missing in the input POT (or still defined to the default literal string PACKAGE VERSION).

The robust solution would be to:

Does it sound reasonnable?

mquinson commented 2 years ago

Ok, this won't work in split mode, for example for the subtest "Split settings, no po". In this case, we use msginit for each language to turn the POT file into a PO file. Maybe we could circumvent the pb by generating an empty PO file ourselves and then msgmerging it against the POT file, but it's getting hairly, isn't it?

Maybe it'd be more effective to extend the list of patterns that we ignore when diffing PO files (in PODIFF of TestHelper) ?

mquinson commented 2 years ago

@vigneshraman could you please try if the current git version works better? If it's more convinient to you, applying the commit mentionned just above (25d0674) onto the last stable version should do the trick.

vigneshraman commented 2 years ago

@mquinson, Applied the patch to version 0.62 and 0.65 and checked. The build failed in OBS, 0.62 - https://build.opensuse.org/package/show/home:vigneshraman/po4a-fix 0.65 - https://build.opensuse.org/package/show/home:vigneshraman/po4a-65-fix

Renamed the git folder from po4a to foo and built the test. It resulted in same issue.

mquinson commented 2 years ago

@vigneshraman thanks for the quick reaction!

I'm sorry, my patch worked for your previous problem, using "language up" in the header, but when it's in german, the string to ignore is "German" not "Language german". Could you please give it another try with cb13a2679aed19153c7cd16ce865103a1180c60b on top of it?

jnavila commented 2 years ago

TBH I really dislike the way msginit infers these values and would strongly prefer that po4a generate identical pot files wherever it is run.

vigneshraman commented 2 years ago

I'm sorry, my patch worked for your previous problem, using "language up" in the header, but when it's in german, the string to ignore is "German" not "Language german". Could you please give it another try with cb13a26 on top of it?

@mquinson we may need to take care of both, 1) German/Spanish/French/Italian translations for po package 2) Language up translations for po package

The updated patch handles only 1) and it still fails with same issue.

jnavila commented 2 years ago

Another options: override the behavior of project-id

mquinson commented 2 years ago

That would be really cool, @jnavila :)

I think that this would mainly be useful for tests, don't you think? For the normal usage, I guess that we don't really care about the values used by project-id to seed the PO files. But if you want to do so in any case, why not. The packaging will become a bit harder, as the po4a script needs to know where its parts are installed, but that's not such a big deal either.

jnavila commented 2 years ago

I think that this would mainly be useful for tests, don't you think? For the normal usage, I guess that we don't really care about the values used by project-id to seed the PO files.

I have to disagree: users of po4a surely don't want to have their po files changed depending on where they have checked out their source files or even when they are running them (the year copyright change is really annoying). They can run tests that check their po files and may be facing the same issues.

mquinson commented 2 years ago

@jnavila: I did not test it, but as far as I understand its source code, msginit is only using project-id when the POT file provided as an input does not have a Project-Id-Version header. This happens very often in our tests, but much less in the classical workflow of our users. Am I misunderstanding something?

@vigneshraman: I would think that my code deals with both cases you cited. (.*?) should match both German and Language up in the same way. If your test reports a failure with this version too, I'm puzzled.

vigneshraman commented 2 years ago

@vigneshraman: I would think that my code deals with both cases you cited. (.*?) should match both German and Language up in the same way. If your test reports a failure with this version too, I'm puzzled.

This is the failure log - https://build.opensuse.org/build/home:vigneshraman/Debian_11/x86_64/po4a-fix/_log

https://build.opensuse.org/package/show/home:vigneshraman/po4a-fix

mquinson commented 2 years ago

I closed the bug because I tested running the tests from a checkout called aze instead of po4a and it worked with that patch. Feel free to reopen if problems remain.

vigneshraman commented 2 years ago

@mquinson it worked with the updated patch. Thank you :)