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

lintian: r23 - in trunk: checks debian



Author: jeroen
Date: 2004-02-09 02:56:45 +0100 (Mon, 09 Feb 2004)
New Revision: 23

Modified:
   trunk/checks/po-debconf
   trunk/checks/po-debconf.desc
   trunk/debian/changelog
   trunk/debian/control
Log:
checks/po-debconf
+ Rewrite in Perl
+ Obsolete PO files are no more checked because po2debconf now
  automatically runs debconf-updatepo if PO files are older than
  templates files.  Of course PO files might be outdated (e.g. when
  downloaded from a BR), but it should occur seldom.
+ PO files are processed through msgfmt to ensure they are valid.
+ Based on patch by Denis Barbier <barbier@debian.org>, Closes: #210576

Tests still needed, but I have not experience with .po files, not enough to
write purposefully wrong .po files etc...


Modified: trunk/checks/po-debconf
===================================================================
--- trunk/checks/po-debconf	2004-02-09 01:01:54 UTC (rev 22)
+++ trunk/checks/po-debconf	2004-02-09 01:56:45 UTC (rev 23)
@@ -1,7 +1,7 @@
-#! /bin/sh
+#!/usr/bin/perl -w
 # po-debconf -- lintian check script
 
-# Copyright (C) 2002 by Denis Barbier <barbier@linuxfr.org>
+# Copyright (C) 2002-2003 by Denis Barbier <barbier@linuxfr.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,40 +19,44 @@
 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 # MA 02111-1307, USA.
 
-[ $# -eq 2 ] || {
-        echo "syntax: po-debconf <pkg> <type>" 1>&2
-        exit 2
-}
+use strict;
 
-pkg=$1
-type=$2
+use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Util;
 
-cd debfiles
+($#ARGV == 1) or fail("syntax: po-debconf <pkg> <type>");
+my $pkg = shift;
+my $type = shift;
 
-[ -f po/POTFILES.in ] || exit 0
-[ -f po/templates.pot ] || exit 0
-
-for lang in po/*.po
-do
-        [ -f $lang ] || continue
-        if sed -e ':t /^msgstr/,${N;/\nmsgid/q;bt;};' $lang | grep charset=CHARSET >/dev/null 2>&1; then
-                echo "W: $pkg $type: unknown-charset-in-po-file $lang"
-        fi
-done
-
-extract_msgid()
-{
-        perl -e 'local $/=undef; $_=<>; s/"\n"//g; for $line (split(/\n/, $_)) {next unless $line=~s/^msgid "([^"])/$1/; $line=~s/"$/\n/; print $line;}' $1 > $2
+#   Exit if package does not seem to use po-debconf
+-d "debfiles/po" or exit(0);
+opendir(DEBIAN, 'debfiles/po')
+        or fail("Can't open debfiles/po directory.");
+if (! -x /usr/bin/msgfmt ) {
+    print "N: Warning: msgfmt (package gettext) not available, not"
+    print "N: going to check *.po syntax"
 }
+while (defined(my $file=readdir(DEBIAN))) {
+        next unless $file =~ m/\.po$/;
+        local ($/) = "\n\n";
+        $_ = '';
+        open(PO, "< debfiles/po/$file")
+                or fail("Can't open debfiles/po/$file file.");
+        while (<PO>) {
+                last if m/^msgstr/m;
+        }
+        close(PO);
+        s/"\n"//g;
+        my $charset = '';
+        if (m/charset=(.*?)\\n/) {
+                $charset = ($1 eq 'CHARSET' ? '' : $1);
+        }
+        print "W: $pkg $type: unknown-charset-in-po-file debian/po/$file\n"
+                unless length($charset);
+	if (-x /usr/bin/msgfmt ) {
+	    system("msgfmt -o /dev/null debfiles/po/$file 2>/dev/null") == 0
+                or print "W: $pkg $type: invalid-po-file debian/po/$file\n";
+	}
+}
 
-rm -rf lintianpo 2>/dev/null
-mkdir lintianpo
-cp po/POTFILES.in lintianpo/
-extract_msgid po/templates.pot lintianpo/msgid.pot
-debconf-updatepo --podir=lintianpo >/dev/null 2>&1 || exit 2
-extract_msgid lintianpo/templates.pot lintianpo/msgid.templates
-cmp lintianpo/msgid.pot lintianpo/msgid.templates >/dev/null || echo "W: $pkg $type: newer-debconf-templates"
-rm -rf lintianpo 2>/dev/null
-
-exit 0
-
+exit(0);

Modified: trunk/checks/po-debconf.desc
===================================================================
--- trunk/checks/po-debconf.desc	2004-02-09 01:01:54 UTC (rev 22)
+++ trunk/checks/po-debconf.desc	2004-02-09 01:56:45 UTC (rev 23)
@@ -12,11 +12,7 @@
 Info: Encoding must be declared in PO files, otherwise charset conversions
  cannot be performed.
 
-Tag: newer-debconf-templates
+Tag: invalid-po-file
 Type: warning
-Info: Some debconf templates files have been updated, but PO files do
- not reflect these changes.
- .
- You should run debconf-updatepo whenever debconf templates files are
- changed so that translators can be warned that their files are
- outdated.
+Info: Some errors are found in PO files and their content will be
+ discarded.  Run 'msgfmt' to see error messages.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-02-09 01:01:54 UTC (rev 22)
+++ trunk/debian/changelog	2004-02-09 01:56:45 UTC (rev 23)
@@ -20,6 +20,14 @@
    * checks/curft:
      + Check for CVS and Subversion cruft in source packages (Closes: #189776,
        also closes: #190067)
+   * checks/po-debconf
+     + Rewrite in Perl
+     + Obsolete PO files are no more checked because po2debconf now
+       automatically runs debconf-updatepo if PO files are older than
+       templates files.  Of course PO files might be outdated (e.g. when
+       downloaded from a BR), but it should occur seldom.
+     + PO files are processed through msgfmt to ensure they are valid.
+     + Based on patch by Denis Barbier <barbier@debian.org>, Closes: #210576
 
   Frank Lichtenheld <djpig@debian.org>
    * checks/debhelper:
@@ -36,9 +44,8 @@
        Choices is only a substitution variable (Closes: #200802,#222648)
      + fix testing of dependencies to eliminate false
        positives of missing-debconf-dependency (Closes: #195201)
-  * 
 
- -- Jeroen van Wolffelaar <jeroen@wolffelaar.nl>  Mon,  9 Feb 2004 01:33:10 +0100
+ -- Jeroen van Wolffelaar <jeroen@wolffelaar.nl>  Mon,  9 Feb 2004 02:49:27 +0100
 
 lintian (1.22.9) unstable; urgency=low
 

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control	2004-02-09 01:01:54 UTC (rev 22)
+++ trunk/debian/control	2004-02-09 01:56:45 UTC (rev 23)
@@ -8,7 +8,7 @@
 Package: lintian
 Architecture: all
 Depends: perl, file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1)
-Suggests: binutils-multiarch
+Suggests: binutils-multiarch, gettext
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy
  violations. It contains automated checks for many aspects of Debian



Reply to: