Package: debhelper
Version: 6.0.4
Severity: wishlist

I uploaded man-db 2.5.1-1 to incoming this morning, so I think we can
now proceed with the plan we discussed a while back:

  http://lists.debian.org/debian-i18n/2007/10/msg00063.html

I've attached a patch against git HEAD that recodes all manual pages to
UTF-8 on installation. I've tested this with debconf and it seems to be
doing the right thing. I suspect a small number of packages that have
inconsistently-encoded manual pages will fail to build as a result of
this, but I believe that these are rather few and I contend that they
were buggy anyway (as man would fail to display those pages).

The reason for the slightly baroque installation method (install file,
man --recode to .new, mv back) is that this allows man to guess the
encoding based on the installation directory.

Note that the original (non-.UTF-8) installation directories are
retained, per the latest discussion in #440420.

Thanks,

-- 
Colin Watson                                       [EMAIL PROTECTED]
diff --git a/debian/control b/debian/control
index 1b707b2..1a8ffe8 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Homepage: http://kitenet.net/~joey/code/debhelper/
 
 Package: debhelper
 Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, file (>= 3.23-1), dpkg-dev (>= 1.14.15), html2text, binutils, po-debconf
+Depends: ${perl:Depends}, ${misc:Depends}, file (>= 3.23-1), dpkg-dev (>= 1.14.15), html2text, binutils, po-debconf, man-db (>= 2.5.1-1)
 Suggests: dh-make
 Conflicts: dpkg-cross (<< 1.18), python-support (<< 0.5.3), python-central (<< 0.5.6)
 Description: helper programs for debian/rules
diff --git a/dh_installman b/dh_installman
index 2ce0e37..55c5737 100755
--- a/dh_installman
+++ b/dh_installman
@@ -38,6 +38,11 @@ like /usr/share/man/pl/man1/, that is because your program has a
 name like "foo.pl", and dh_installman assumes that means it is translated
 into Polish. Use --language=C to avoid this.
 
+dh_installman will use man to guess the character encoding of each manual
+page and convert it to UTF-8. If the guesswork fails for some reason, you
+can override it using an encoding declaration. See L<manconv(1)> for
+details.
+
 Any man page filenames specified as parameters will be installed into the
 first package dh_installman is told to act on. By default, this is the
 first binary package in debian/control, but if you use -p, -i, or -a flags,
@@ -162,16 +167,23 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$destdir="$tmp/usr/share/man/$langcode/man$realsection/";
 		}
 		$destdir=~tr:/:/:s; # just for looks
+		my $instpage="$destdir/$instname.$section";
 
-		next if -l "$destdir/$instname.$section";
-		next if compat(5) && -e "$destdir/$instname.$section";
+		next if -l $instpage;
+		next if compat(5) && -e $instpage;
 
 		if (! -d $destdir) {
 			doit "install","-d",$destdir;
 		}
-		doit "install","-p","-m644",$page,
-			"$destdir$instname.$section$gz";
-		
+		if ($gz) {
+			complex_doit "zcat \Q$page\E > \Q$instpage\E";
+		}
+		else {
+			doit "install","-p","-m644",$page,$instpage;
+		}
+		complex_doit "man --recode UTF-8 \Q$instpage\E > \Q$instpage.new\E";
+		doit "chmod",644,"$instpage.new";
+		doit "mv","$instpage.new",$instpage;
 	}
 
 	# Now the .so conversion.

Reply via email to