Debian – preseeding locales in debian

debiandebian-squeezelocalizationpreseed

I am trying to use debconf to preseed the values for the locales package in Debian squeeze, so that I can reconfigure it non-interactively to, e.g., generate all locales. I extract the right selection from a working system using debconf-get-selections, and then feed them to debconf-set-selections on the new system.

It is working for other packages, e.g. sun-java6-bin, not quite for locales. I am able to set the values with debconf-set-selections, but if I reconfigure locales with dpkg-reconfigure (or reinstall it with, e.g., apt-get install --reinstall locales, for that matter), the values are reset and the new locales are not generated.

Symptoms are exactly the same as in debian bug #592216, but that bug is officially resolved in version 2.9-13 of the package. Squeeze has 2.11.3-4, so either the bug is still there, or I am doing something wrong.

Has anyone experienced the same thing?

Thanks in advance

— M

Best Answer

Yes, I have experienced the same problem, and after fighting it for a while, I found a workaround that uses /etc/locale.gen.

I published a puppet module to configure the locales we usually use on our servers, that is, only en_US.UTF-8:

https://github.com/cosimo/puppet-modules/blob/master/locales/manifests/init.pp

Here it is, inlined:

class locales {

  package { "locales": 
    ensure => "latest",
  }

  file { "/etc/locale.gen":
    source => [
      "puppet:///locales/locale.gen.$fqdn",
      "puppet:///locales/locale.gen"
    ],
    owner => "root",
    group => "root",
    mode => 644,
    require => Package["locales"],
  }

  exec { "/usr/sbin/locale-gen":
    subscribe => File["/etc/locale.gen"],
    refreshonly => true,
    require => [ Package["locales"], File["/etc/locale.gen"] ]
  }

}

Even if you don't use puppet ;-), you can easily understand what's happening. You just create the /etc/locale.gen file with the list of locales you want to generate, and then run the /usr/sbin/locale-gen.

Here's the list file I use as /etc/locale.gen:

# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED, and you can add
# user defined locales to /usr/local/share/i18n/SUPPORTED. If you change
# this file, you need to rerun locale-gen.

en_US.UTF-8 UTF-8