[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#242345: po-debconf: check for outdated templates.pot files



On Tue, Apr 06, 2004 at 08:39:34AM +0200, Denis Barbier wrote:
> here is a patch to check whether templates.pot files are outdated wrt
> debconf templates files.  A similar test appeared in lintian 1.22.9,
> but I asked for its removal in 1.22.11 when the po-debconf stuff was
> rewritten, because I did not like how this test was performed and I
> (wrongly) thought that this problem won't occur anymore after some
> changes in the po-debconf package.
> This new test is much better, so I am quite confident that I won't 
> ask for its removal soon ;)

Hmm, this has gone lost somehow. I revised the patch and applied the
corrections mentioned in the bug report by Jeroen and Denis.
Attached the final patch. If noone has any objections against adding the
additional depends on intltool-debian I will go ahead and commit it.

Gruesse,
-- 
Frank Lichtenheld <djpig@debian.org>
www: http://www.djpig.de/
Index: checks/po-debconf.desc
===================================================================
--- checks/po-debconf.desc	(revision 369)
+++ checks/po-debconf.desc	(working copy)
@@ -37,3 +37,16 @@
 Type: warning
 Info: Some errors are found in PO files and their content will be
  discarded.  Run 'msgfmt' to see error messages.
+
+Tag: newer-debconf-templates
+Type: warning
+Info: debconf-updatepo has not been run since the last change to your
+ debconf template(s).
+ .
+ You should run debconf-updatepo whenever debconf templates files are
+ changed so that translators can be warned that their files are
+ outdated.
+ .
+ This can be ensured by running debconf-updatepo in the 'clean' target
+ of debian/rules, PO files will then always be up-to-date in the source
+ package.
Index: checks/po-debconf
===================================================================
--- checks/po-debconf	(revision 369)
+++ checks/po-debconf	(working copy)
@@ -57,6 +57,7 @@
 #   Exit if package does not seem to use po-debconf
 -d "debfiles/po" or return(0);
 
+my $missing_files = 0;
 if (-f "debfiles/po/POTFILES.in") {
 	open(POTFILES,"debfiles/po/POTFILES.in")
 		or fail("Can't open debfiles/po/POTFILES.in.");
@@ -65,22 +66,36 @@
 		s/.*\]\s*//;
 		#  Cannot check files which are not under debian/
 		next if m,^\.\./, or $_ eq '';
-		tag "missing-file-from-potfiles-in", "$_"
-			 unless -f "debfiles/$_";
+		unless (-f "debfiles/$_") {
+			tag "missing-file-from-potfiles-in", "$_";
+			$missing_files = 1;
+		} 
 	}
 	close(POTFILES);
 } else {
 	tag "missing-potfiles-in", "";
+	$missing_files = 1;
 }
 if (! -f "debfiles/po/templates.pot") {
 	tag "missing-templates-pot", "";
+	$missing_files = 1;
 }
 
-opendir(DEBIAN, 'debfiles/po')
-        or fail("Can't open debfiles/po directory.");
+if (-x "/usr/bin/msgcmp" && -x "/usr/share/intltool-debian/intltool-update" ) {
+	if ($missing_files == 0) {
+		system("cd debfiles/po && /usr/share/intltool-debian/intltool-update --gettext-package=test --pot");
+		system("/usr/bin/msgcmp debfiles/po/test.pot debfiles/po/templates.pot >/dev/null 2>&1") == 0
+                	or tag "newer-debconf-templates";
+	}
+} else {
+	fail("either msgcmp or intltool-update not found");
+}
+
 if (! -x "/usr/bin/msgfmt" ) {
 	fail("msgfmt not found");
 }
+opendir(DEBIAN, 'debfiles/po')
+        or fail("Can't open debfiles/po directory.");
 while (defined(my $file=readdir(DEBIAN))) {
         next unless $file =~ m/\.po$/;
         local ($/) = "\n\n";
@@ -98,10 +113,8 @@
         }
         tag "unknown-encoding-in-po-file", "debian/po/$file"
                 unless length($charset);
-	if (-x "/usr/bin/msgfmt" ) {
-	    system("msgfmt -o /dev/null debfiles/po/$file 2>/dev/null") == 0
-                or tag "invalid-po-file", "debian/po/$file";
-	}
+	system("msgfmt -o /dev/null debfiles/po/$file 2>/dev/null") == 0
+		or tag "invalid-po-file", "debian/po/$file";
 }
 
 }
Index: debian/control
===================================================================
--- debian/control	(revision 369)
+++ debian/control	(working copy)
@@ -8,7 +8,7 @@
 
 Package: lintian
 Architecture: all
-Depends: perl, libdigest-md5-perl | perl (>> 5.8), file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1), gettext
+Depends: perl, libdigest-md5-perl | perl (>> 5.8), file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1), gettext, intltool-debian
 Suggests: binutils-multiarch
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 370)
+++ debian/changelog	(working copy)
@@ -13,6 +13,10 @@
   * checks/menu-format.desc:
     + [FL] Adjust references to the menu documentation. Noted by
       Jack Moffitt (Closes: #277393)
+  * checks/po-debconf{,.desc}:
+    + [FL] Check for outdated .pot files when using po-debconf.
+      Patch by Denis Barbier with corrections by JvW
+      (Closes: #242345)
   * checks/scripts.desc:
     + [FL] Fix copy-and-paste error in description
       of wrong-path-for-gnuplot (Closes: #276945)
Index: testset/tags.debconf
===================================================================
--- testset/tags.debconf	(revision 369)
+++ testset/tags.debconf	(working copy)
@@ -1,4 +1,5 @@
 E: debconf-test: extended-description-is-empty
 E: debconf-test: settitle-requires-versioned-depends config
 W: debconf source: maintainer-script-lacks-debhelper-token debian/debconf-test.postinst
+W: debconf source: newer-debconf-templates
 W: debconf-udeb udeb: missing-debconf-dependency
Index: testset/debconf/debian/debconf-test.templates
===================================================================
--- testset/debconf/debian/debconf-test.templates	(revision 369)
+++ testset/debconf/debian/debconf-test.templates	(working copy)
@@ -1,3 +1,3 @@
 Template: debconf/test
 Type: text
-_description: Foo bar
+_description: Foo bar (2)

Reply to: