On 2011-08-13 17:12, Niels Thykier wrote: > On 2011-08-08 07:06, Josh Triplett wrote: >> On Sat, Aug 06, 2011 at 03:23:12PM +0200, Niels Thykier wrote: >>> [...] > > Hi, > > I think that is really outside the scope of a Lintian backport. If such > a package was created for backports, I would consider it, but I will not > introduce one in(/for) Lintian. > > Also as far as I can tell, all packages can drop their private C.UTF-8 > maintenance scripts at wheezy + 1 if they migrate correctly during Wheezy. > > ~Niels > >
Hi I am suggesting this patch that makes lintian use the C.UTF-8 locale if provided by libc-bin (checks for presence of /usr/lib/locale/C.UTF-8). If it is not present, lintian will fall back to (generating and using) its en_US.UTF-8. I would have used a C.UTF-8 locale, but it cannot be generated without a newer libc as far as I can tell. Peer review welcome; I will commit it later this week if there are no problems with it. ~Niels
>From baf1f710546d61a1cb5e3f068b976c0a5b6bf175 Mon Sep 17 00:00:00 2001 From: Niels Thykier <ni...@thykier.net> Date: Mon, 22 Aug 2011 21:32:02 +0200 Subject: [PATCH] Migrate to C.UTF-8 if libc-bin provides it --- checks/manpages | 19 +++++++++++++++---- checks/manpages.desc | 2 +- debian/control | 2 +- debian/dirs | 1 - debian/postinst | 12 +++++++++++- debian/prerm | 6 ++++-- frontend/lintian | 21 ++++++++++++++------- private/runtests | 19 ++++++++++++------- 8 files changed, 58 insertions(+), 24 deletions(-) diff --git a/checks/manpages b/checks/manpages index 0c63688..dc22e45 100644 --- a/checks/manpages +++ b/checks/manpages @@ -218,8 +218,13 @@ foreach my $file (@{$info->sorted_index}) { if (not defined $pid) { fail("cannot run lexgrog: $!"); } elsif ($pid == 0) { - my %newenv = (LC_ALL => 'en_US.UTF-8', PATH => $ENV{PATH}, - LOCPATH => $ENV{LOCPATH}); + my %newenv = (LC_ALL => 'C.UTF-8', PATH => $ENV{PATH}); + # Fall back to "en_US.UTF-8" if we are using a "private" + # locale. + if ($ENV{'LOCPATH'} ) { + $newenv{LC_ALL} = 'en_US.UTF-8'; + $newenv{LOCPATH} = $ENV{LOCPATH}; + } undef %ENV; %ENV = %newenv; exec "lexgrog \Q$path\E 2>&1" @@ -252,8 +257,14 @@ foreach my $file (@{$info->sorted_index}) { if (not defined $pid) { fail("cannot run man -E UTF-8 -l: $!"); } elsif ($pid == 0) { - my %newenv = (LC_ALL => 'en_US.UTF-8', PATH => $ENV{PATH}, - MANWIDTH => 80, LOCPATH => $ENV{LOCPATH}); + my %newenv = (LC_ALL => 'C.UTF-8', PATH => $ENV{PATH}, + MANWIDTH => 80); + # Fall back to "en_US.UTF-8" if we are using a "private" + # locale. + if ($ENV{'LOCPATH'} ) { + $newenv{LC_ALL} = 'en_US.UTF-8'; + $newenv{LOCPATH} = $ENV{LOCPATH}; + } undef %ENV; %ENV = %newenv; exec "($cmd >/dev/null) 2>&1" diff --git a/checks/manpages.desc b/checks/manpages.desc index d7d1443..66bde96 100644 --- a/checks/manpages.desc +++ b/checks/manpages.desc @@ -174,7 +174,7 @@ Info: This man page provokes warnings or errors from man. "Debugging" in the groff manual. . To test this for yourself you can use the following command: - LC_ALL=en_US.UTF-8 MANWIDTH=80 man --warnings -E UTF-8 -l <file> >/dev/null + LC_ALL=C.UTF-8 MANWIDTH=80 man --warnings -E UTF-8 -l <file> >/dev/null Tag: manpage-has-errors-from-pod2man Severity: normal diff --git a/debian/control b/debian/control index 651c575..e1707cd 100644 --- a/debian/control +++ b/debian/control @@ -22,6 +22,7 @@ Build-Depends: binutils, intltool-debian, javahelper (>= 0.32~), libapt-pkg-perl, + libc-bin (>= 2.13) | locales, libclass-accessor-perl, libdpkg-perl, libdigest-sha-perl, @@ -37,7 +38,6 @@ Build-Depends: binutils, libtext-template-perl, libtimedate-perl, liburi-perl, - locales, xz-lzma | lzma, man-db, perl, diff --git a/debian/dirs b/debian/dirs index 419b920..ea49a65 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,5 +1,4 @@ etc usr/bin usr/share/lintian -var/lib/lintian var/spool/lintian diff --git a/debian/postinst b/debian/postinst index fd7c783..19b1511 100644 --- a/debian/postinst +++ b/debian/postinst @@ -17,6 +17,17 @@ gen_locale() { fi } +#DEBHELPER# + +# Do nothing if there is a system locale. +if [ -d '/usr/lib/locale/C.UTF-8' ] ; then + if [ "$1" = 'configure' -a -d "$locale_dir/" ] ; then + # except clean up our unused private locale + rm -rf "$locale_dir" + fi + exit 0 +fi + if [ "$1" = "configure" ]; then if [ ! -f "$locale_dir/en_US.UTF-8/LC_CTYPE" ] && [ -f /usr/share/locale/locale.alias ]; then @@ -39,4 +50,3 @@ if [ "$1" = "triggered" ]; then fi fi -#DEBHELPER# diff --git a/debian/prerm b/debian/prerm index 698ed52..7e21104 100644 --- a/debian/prerm +++ b/debian/prerm @@ -3,9 +3,11 @@ set -e # -# Remove our generated locale unless we're only upgrading. +# Remove our generated locale if we are not upgrading or +# we are upgrading into a system with a libc provided +# C.UTF-8 (libc-bin >= 2.13-1) -if [ 'upgrade' != "$1" ] ; then +if [ 'upgrade' != "$1" -o -d '/usr/lib/locale/C.UTF-8' ] ; then rm -rf /var/lib/lintian/ fi diff --git a/frontend/lintian b/frontend/lintian index 595539c..e8cc1d4 100755 --- a/frontend/lintian +++ b/frontend/lintian @@ -692,13 +692,20 @@ if ($ENV{'LINTIAN_INTERNAL_TESTSUITE'}){ $opt{'verbose'} = 1 if $debug; $ENV{'LINTIAN_DEBUG'} = $debug; -# Use our custom-generated locale for programs we call, if it's available. We -# first look in the Lintian root and then in /var/lib/lintian, which is the -# standard location for the install-time-generated locale. -if (-d "$LINTIAN_ROOT/locale/en_US.UTF-8") { - $ENV{LOCPATH} = "$LINTIAN_ROOT/locale"; -} elsif (-d '/var/lib/lintian/locale/en_US.UTF-8') { - $ENV{LOCPATH} = '/var/lib/lintian/locale'; +# Use our custom-generated locale for programs we call, if it's available +# and the system-wide one is not. If the system-wide one is not available +# it is most-likely a system wihtout libc-bin >= 2.13-1. +if ( ! -d '/usr/lib/locale/C.UTF-8/') { + if (-d "$LINTIAN_ROOT/locale/C.UTF-8") { + $ENV{LOCPATH} = "$LINTIAN_ROOT/locale"; + } elsif (-d '/var/lib/lintian/locale/C.UTF-8') { + $ENV{LOCPATH} = '/var/lib/lintian/locale'; + } +} else { + # Clear LOCPATH so checks/manpages uses the C locale + # (in the presence of $ENV{LOCPATH}, it will use en_US + # because we cannot create C.UTF-8 locales in Squeeze) + delete $ENV{LOCPATH}; } # }}} diff --git a/private/runtests b/private/runtests index 071f2c3..92a46bd 100755 --- a/private/runtests +++ b/private/runtests @@ -19,7 +19,6 @@ LC_ALL="C" LINTIAN_ROOT="" LINTIAN_PROFILE=debian LINTIAN_INTERNAL_TESTSUITE=1 -LOCPATH="$(pwd)/debian/test.locale" NO_PKG_MANGLE=true [ "$TEST_WORK_DIR" ] || TEST_WORK_DIR="debian/test-out" @@ -28,7 +27,6 @@ export LC_ALL export LINTIAN_ROOT export LINTIAN_PROFILE export LINTIAN_INTERNAL_TESTSUITE -export LOCPATH export NO_PKG_MANGLE fail(){ @@ -36,14 +34,21 @@ fail(){ exit 1 } -if [ ! -e "$LOCPATH"/en_US.UTF-8 ] ; then - echo "Generating en_US.UTF-8 locale for the test suite" - mkdir -p "$LOCPATH" - localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias \ - --quiet "$LOCPATH"/en_US.UTF-8 || fail "Locale generation failed" +if [ ! -d '/usr/lib/locale/en_US.UTF-8' ] ; then + LOCPATH="$(pwd)/debian/test.locale" + export LOCPATH + if [ ! -e "$LOCPATH"/en_US.UTF-8 ] ; then + echo "Generating en_US.UTF-8 locale for the test suite" + mkdir -p "$LOCPATH" + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias \ + --quiet "$LOCPATH"/en_US.UTF-8 || fail "Locale generation failed" + fi +else + unset LOCPATH fi t/runtests --dump-logs -k $PARALLEL_ARGS t "$TEST_WORK_DIR" "$@" if [ "$TAG" = "" ] ; then testset/runtests -k testset "$TEST_WORK_DIR" "$@" fi + -- 1.7.5.4