FS#10428 - [initscripts] locale settings are reset at every reboot
Attached to Project:
Arch Linux
Opened by Heiko Baums (cyberpatrol) - Friday, 16 May 2008, 13:33 GMT
Last edited by Roman Kyrylych (Romashka) - Friday, 12 June 2009, 22:53 GMT
Opened by Heiko Baums (cyberpatrol) - Friday, 16 May 2008, 13:33 GMT
Last edited by Roman Kyrylych (Romashka) - Friday, 12 June 2009, 22:53 GMT
|
Details
Description:
I had a problem with the sorting of the ls output. It was sorted ASCII like and case sensitive, but I need an alphabetically and case insensitive sorting as it is defined in my chosen locale. I also have set my locale settings to "de_DE.UTF-8" but I need LC_MESSAGES="en_US.UTF-8". So I set my LANG and LC_* environment variables in /etc/profile.d/locale.sh, because I need these settings system wide. But unfortunately I must notice, that the sort order still isn't changed and my settings in /etc/profile.d/locale.sh are gone after every reboot. The sort order isn't changed, because in /etc/profile the variable LC_COLLATE is set to "C" independently of the variable LOCALE in /etc/rc.conf. LC_COLLATE is, btw., not necessary to get and keep the system working. If a script needs LC_COLLATE="C" for whatever reason, the command, which needs it, should be prefixed with 'LC_COLLATE="C"' in the script, so that this setting is changed only for this command. The locale settings are removed at every reboot, because /etc/profile.d/locale.sh is always overwritten by rc.sysinit at every boot time. To fix this, the files /etc/profile (belongs to package filesystem) and /etc/rc.sysinit (belongs to package initscripts) should be changed, so that the locale settings are not overwritten anymore. User specific settings in ~/.bashrc are not an option, because I need these settings system wide. The line `LC_COLLATE="C"` should be removed from /etc/profile. If someone needs another LC_COLLATE than this one set by the chosen locale, this can and should be set manually by the admin himself in /etc/profile.d/locale.sh. From the file /etc/rc.sysinit the whole "# Flush old locale settings" and "# Set user defined locale" parts should be removed without replacement. See the attached patch. Additional info: * package version(s) filesystem 2008.03-2 initscripts 2008.03-4 * config and/or log files etc. /etc/profile /etc/rc.sysinit Steps to reproduce: Edit the file /etc/profile.d/locale.sh and set "export LANG=..." and "export LC_...=..." in this file. Reboot the system. cat /etc/profile.d/locale.sh |
This task depends upon
Archlinux uses /etc/rc.conf to configure the locale. Your patch completely removes that ability. locale.sh is always autogenerated. Perhaps we need a comment that says "THIS FILE IS AUTOGENERATED, DO NOT EDIT"
What is wrong with setting LOCALE="de_DE.UTF-8" in rc.conf and then doing your *custom* steps in rc.local. That is exactly what rc.local is for. Add "export LC_MESSGES=en_US.UTF-8" to that file and you're gold.
Removing LC_COLLATE is totally unrelated. Please file a different bug report for this - one bug per report please.
Setting LOCALE="de_DE.UTF-8" in rc.conf, and setting the custom locales in rc.local doesn't work. This only works by setting the custom locales in /etc/profile instead of rc.local. But then you have locale settings at two, actually three different places (/etc/rc.conf, /etc/profile.d/locale.sh and /etc/profile) and /etc/profile is getting not much, but a bit more complex. I think it's better to have the locale settings at only one place. This file could be autogenerated once during the installation - could be edited within the installer, like it is already done with rc.conf - and then be kept untouched like the other scripts in /etc/profile.d. And the file /etc/profile.d/locale.sh is autogenerated and used, anyway. And for the usability I think it doesn't matter, if the user sets the locale in /etc/rc.conf or in /etc/profile.d/locale.sh. I would say, editing /etc/profile.d/locale.sh directly, is a bit more KISS like. This should of course be explained in http://wiki.archlinux.org/index.php/Configuring_locales.
If you like it more to have the locale settings in rc.conf and keep /etc/profile.d/locale.sh being autogenerated, then you probably should add every possible LC_* variable to rc.conf. I'm not quite sure, if this or setting the locales in /etc/profile.d/locale.sh directly is easier.
If I am on a multi user machine, like the one this bug tracker runs on, which is used by people of at least 4 different locales, what do I do? I set a sensible global locale (in this case, English) and let each user change their own settings in their home dir. If you have custom settings that don't fit into the way we do this, do it on a per-user basis.
That said, I think we can meet somewhere in the middle here. If you were to give me a locale.sh file that would both
a) read LOCALE from rc.conf and use that if defined
b) allow custom overrides in that file
then I would think about implementing it, as it seems feasible. This way we could kill of the autogeneration (which is messy anyway)
The locale is stricktly a per-user setting, so I ussually suggest people to have it setup in their own ~/.xprofile or ~/.profile
Locale settings can, of course, also be set on a per-user basis like nearly every other system configuration, but this doesn't mean, that these settings are not system settings.
When somebody's living in Germany or France or whereever, why should he run an English locale system wide?
If it is set system wide, it usually belongs in /etc/profile or for my part also in /etc/rc.conf. If it is set by a user, it belongs to ~/.bashrc or whatever file is sourced at login.
1) As for LC_COLLATE=C -
FS#10435was closed as "Won't fix" andputting your config lines at the end of profile.sh or, as Thomas suggested, in profile.d/zz.sh will override anything in locale.sh
2) The are a couple of reasons for generating /etc/profile.d/locale.sh instead of doing same settings in rc.sysinit,
for example to make sure that terminal looks okay even after it was reset/broken by user or some crappy program,
This solution existed for ages, and was greatly stabilized during past years while solving different locale-related issues
(actually, my first contribution to Arch was a patch I sent to Judd to fix some locale problems, that was in year 2005).
For the record our current console localization scheme is quite flexible, it even supports things like non-UTF console with different charsets for keyboard and display.
If there are some proposals to extend the configurability of the current scheme in a clean and backwards compatible way - great,
but please open a separate feature request for this, preferably with a patch.
The idea of generating locale.sh during installation and putting info on wiki about editing it may seem good,
but actually this doesn't bring much benefits - most people are fine with current scheme and manual setup of correct localization of console is very tricky (see rc.sysinit for that),
and that's a turnover from our 'keep stuff in rc.conf' idea.
To summarize all - let's not try to "fix" things in this area because there's really nothing broken.
Again, for proposals of more customization without breaking the current scheme - please create a separate feature request.