-
-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix locale setting with openhabian.conf not working #1723
Conversation
Fixes openhab#1721. Removed `dpkg-reconfigure --frontend=noninteractive locales` because it's only generating the locales, which is already done with `locale-gen`. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
I don't know.
with that 'reconfigure' line removed ? |
Seems like reconfigure with the noniteractive frontend only generates the locales, see the command output compared to openhabian@smarthomevm ~> sudo dpkg-reconfigure --frontend=noninteractive locales
[sudo] password for openhabian:
Generating locales (this might take a while)...
de_DE.UTF-8... done
en_US.UTF-8... done
Generation complete.
openhabian@smarthomevm ~> sudo locale-gen
Generating locales (this might take a while)...
de_DE.UTF-8... done
en_US.UTF-8... done
Generation complete. Moreover, the reconfigure line with noniteractive frontend does not change anything in |
functions/system.bash
Outdated
@@ -161,10 +162,10 @@ locale_setting() { | |||
done | |||
if ! cond_redirect locale-gen; then echo "FAILED (locale-gen)"; return 1; fi | |||
fi | |||
if ! cond_redirect dpkg-reconfigure --frontend=noninteractive locales; then echo "FAILED (reconfigure locales)"; return 1; fi | |||
# shellcheck disable=SC2154 | |||
syslocale=$system_default_locale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if system_default_locale is unset ?
And will /etc/default/locale be adapted to match system_default_locale (if set) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if system_default_locale is unset ?
Then en_US.UTF-8 will be used as defined in line 171:
if cond_redirect update-locale LANG="${syslocale:-en_US.UTF-8}" LC_ALL="${syslocale:-en_US.UTF-8}" LC_CTYPE="${syslocale:-en_US.UTF-8}" LANGUAGE="${syslocale:-en_US.UTF-8}"; then echo "OK (reboot required)"; else echo "FAILED"; return 1; fi
Use the following code snippet to verify that:
#!/bin/bash
# system_default_locale=de_DE.UTF-8
syslocale=$system_default_locale
echo ${syslocale:-en_US.UTF-8}
And will /etc/default/locale be adapted to match system_default_locale (if set) ?
update-locale
automatically updates /etc/default/locale
on every call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but update-locale is only called before your new line syslocale=$system_default_locale so does not have the value by then
Use defaults on assignments i.e. X=${Y:-z}, can even be X=${Y:-${Z:-z}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but update-locale is only called before your new line syslocale=$system_default_locale so does not have the value by then
No, see:
…
# shellcheck disable=SC2154
syslocale=$system_default_locale
fi
if cond_redirect update-locale LANG="${syslocale:-en_US.UTF-8}" LC_ALL="${syslocale:-en_US.UTF-8}" LC_CTYPE="${syslocale:-en_US.UTF-8}" LANGUAGE="${syslocale:-en_US.UTF-8}"; then echo "OK (reboot required)"; else echo "FAILED"; return 1; fi
…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use defaults on assignments i.e. X=${Y:-z}, can even be X=${Y:-${Z:-z}}
In the line syslocale=$system_default_locale
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes and everywhere where appropriate never mind it should do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the update-locale statement, for the syslocale
var it is not required. (If interactive, an error is thrown if syslocale cant be assigned, and if unattened, syslocale gets a default from the assignment to system_default_locale.
Can I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if unattened, syslocale gets a default from the assignment to system_default_locale.
which is not guaranteed to be set as it's user-defined.
Can I remove it?
At some place you have to provide a default to apply to all use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my latest commit, I assign a default if system_default_locale is not set and we are in unattended mode.
If we are in interactive mode, syslocal can not be empty, because the function exits with an error if the assignment fails.
I used the |
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright then, thanks!
Fixes #1721.
@mstormi Am I right with the following assumption?
Removed
dpkg-reconfigure --frontend=noninteractive locales
because it's only generating the locales, which is already done withlocale-gen
.I tested the locale setup using
openhabian.conf
and theopenhabian-config
tool a few times, seems to work this time.Maybe you could also test.
Signed-off-by: Florian Hotze florianh_dev@icloud.com