Message ID | 20231009151729.2223963-9-arbab@linux.ibm.com |
---|---|
State | Changes Requested |
Headers | show |
Series | package/petitboot: misc fixes/enhancement | expand |
On 09/10/2023 17:17, Reza Arbab wrote: > The petitboot UI looks much nicer in a Unicode locale: > > * Items in the language selection submenu use multibyte Unicode > characters. In other locales, they say "Unable to display text in this > locale". > > * The combination of TERM=linux with a UTF-8 locale is required to > trigger a special-case workaround in ncurses code[1]. Without > this, line-drawing characters in the menu look like q's. > > Add a reminder that a UTF-8 locale should be generated for things to > look right. Assume C.UTF-8 by default, allowing $LANG to be overridden > (by /etc/default/petitboot or otherwise) if something else is desired. So, this improves things, but they're not really necessary. I think it's better then to just put in the help text that it looks better with UTF-8 locale enabled. > > [1] https://invisible-island.net/ncurses/ncurses.faq.html#no_line_drawing > > Signed-off-by: Reza Arbab <arbab@linux.ibm.com> > --- > package/petitboot/Config.in | 8 ++++++-- > package/petitboot/S15pb-discover | 1 + > package/petitboot/pb-console | 1 + > package/petitboot/shell_profile | 3 +++ > 4 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/package/petitboot/Config.in b/package/petitboot/Config.in > index 0f965e71e628..a449ed87872c 100644 > --- a/package/petitboot/Config.in > +++ b/package/petitboot/Config.in > @@ -4,6 +4,7 @@ config BR2_PACKAGE_PETITBOOT > depends on BR2_PACKAGE_KEXEC_ARCH_SUPPORTS > depends on BR2_USE_MMU # lvm2 > depends on BR2_USE_WCHAR # elfutils > + depends on BR2_ENABLE_LOCALE > depends on !BR2_STATIC_LIBS # elfutils, lvm2 > depends on BR2_TOOLCHAIN_HAS_THREADS # elfutils, lvm2 > depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils > @@ -11,6 +12,7 @@ config BR2_PACKAGE_PETITBOOT > select BR2_PACKAGE_ELFUTILS > select BR2_PACKAGE_LVM2 # devmapper > select BR2_PACKAGE_NCURSES > + select BR2_PACKAGE_NCURSES_WCHAR > # run-time dependencies > select BR2_PACKAGE_KEXEC if !BR2_PACKAGE_KEXEC_LITE > select BR2_PACKAGE_KEXEC_LITE if ( BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le ) > @@ -20,12 +22,14 @@ config BR2_PACKAGE_PETITBOOT > help > Petitboot is a small kexec-based bootloader > > + NOTE: petitboot needs a working UTF-8 locale (BR2_GENERATE_LOCALE) > + > http://www.kernel.org/pub/linux/kernel/people/geoff/petitboot/petitboot.html > > -comment "petitboot needs a uClibc or glibc toolchain w/ wchar, dynamic library, threads, udev /dev management" > +comment "petitboot needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library, threads, udev /dev management" > depends on BR2_PACKAGE_KEXEC_ARCH_SUPPORTS > depends on BR2_USE_MMU > - depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS || \ > + depends on !BR2_USE_WCHAR || !BR2_ENABLE_LOCALE || BR2_STATIC_LIBS || \ > !BR2_TOOLCHAIN_HAS_THREADS || \ > !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC) || \ > !BR2_PACKAGE_HAS_UDEV > diff --git a/package/petitboot/S15pb-discover b/package/petitboot/S15pb-discover > index a37e33521f1a..15b428ce0e42 100644 > --- a/package/petitboot/S15pb-discover > +++ b/package/petitboot/S15pb-discover > @@ -15,6 +15,7 @@ start() { > # shellcheck disable=SC2174 # only apply -m to deepest dir > mkdir -p -m 0775 /var/log/petitboot > chown root:petitgroup /var/log/petitboot > + export LANG="${LANG:-C.UTF-8}" I think it's better to rely on the default locale being set to C.UTF-8. Hm, it seems we don't actually set a default locale though... Perhaps we should add a system menu entry to do exactly that. Though I'm not sure if it's even possible with uClibc (glibc has /etc/locale.conf). Regards, Arnout > > # shellcheck disable=SC2086 # we need the word splitting > start-stop-daemon -S -q -b -m -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ > diff --git a/package/petitboot/pb-console b/package/petitboot/pb-console > index eea40163d02f..55e5462f0457 100644 > --- a/package/petitboot/pb-console > +++ b/package/petitboot/pb-console > @@ -13,6 +13,7 @@ start() { > # shellcheck disable=SC2174 # only apply -m to deepest dir > mkdir -p -m 0775 /var/log/petitboot > chown root:petitgroup /var/log/petitboot > + export LANG="${LANG:-C.UTF-8}" > > # shellcheck disable=SC2086 # we need the word splitting > start-stop-daemon -S -q -x "/usr/libexec/petitboot/$DAEMON" \ > diff --git a/package/petitboot/shell_profile b/package/petitboot/shell_profile > index 1ca5e6364dba..6bbe49e6d113 100644 > --- a/package/petitboot/shell_profile > +++ b/package/petitboot/shell_profile > @@ -1,2 +1,5 @@ > +[ -r "/etc/default/petitboot" ] && . "/etc/default/petitboot" > export ENV="/home/petituser/.shrc" > +export LANG="${LANG:-C.UTF-8}" > + > exec /usr/libexec/petitboot/pb-console
On Sun, Nov 05, 2023 at 07:30:28PM +0100, Arnout Vandecappelle wrote: >On 09/10/2023 17:17, Reza Arbab wrote: >>Add a reminder that a UTF-8 locale should be generated for things to >>look right. Assume C.UTF-8 by default, allowing $LANG to be overridden >>(by /etc/default/petitboot or otherwise) if something else is desired. > > So, this improves things, but they're not really necessary. I think >it's better then to just put in the help text that it looks better >with UTF-8 locale enabled. Will change. >>--- a/package/petitboot/S15pb-discover >>+++ b/package/petitboot/S15pb-discover >>@@ -15,6 +15,7 @@ start() { >> # shellcheck disable=SC2174 # only apply -m to deepest dir >> mkdir -p -m 0775 /var/log/petitboot >> chown root:petitgroup /var/log/petitboot >>+ export LANG="${LANG:-C.UTF-8}" > > I think it's better to rely on the default locale being set to >C.UTF-8. Hm, it seems we don't actually set a default locale though... >Perhaps we should add a system menu entry to do exactly that. Though >I'm not sure if it's even possible with uClibc (glibc has >/etc/locale.conf). No problem, I'll take this out. I think we can defer to the user to set a UTF-8 system locale. A config option for default locale would be nice indeed.
diff --git a/package/petitboot/Config.in b/package/petitboot/Config.in index 0f965e71e628..a449ed87872c 100644 --- a/package/petitboot/Config.in +++ b/package/petitboot/Config.in @@ -4,6 +4,7 @@ config BR2_PACKAGE_PETITBOOT depends on BR2_PACKAGE_KEXEC_ARCH_SUPPORTS depends on BR2_USE_MMU # lvm2 depends on BR2_USE_WCHAR # elfutils + depends on BR2_ENABLE_LOCALE depends on !BR2_STATIC_LIBS # elfutils, lvm2 depends on BR2_TOOLCHAIN_HAS_THREADS # elfutils, lvm2 depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils @@ -11,6 +12,7 @@ config BR2_PACKAGE_PETITBOOT select BR2_PACKAGE_ELFUTILS select BR2_PACKAGE_LVM2 # devmapper select BR2_PACKAGE_NCURSES + select BR2_PACKAGE_NCURSES_WCHAR # run-time dependencies select BR2_PACKAGE_KEXEC if !BR2_PACKAGE_KEXEC_LITE select BR2_PACKAGE_KEXEC_LITE if ( BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le ) @@ -20,12 +22,14 @@ config BR2_PACKAGE_PETITBOOT help Petitboot is a small kexec-based bootloader + NOTE: petitboot needs a working UTF-8 locale (BR2_GENERATE_LOCALE) + http://www.kernel.org/pub/linux/kernel/people/geoff/petitboot/petitboot.html -comment "petitboot needs a uClibc or glibc toolchain w/ wchar, dynamic library, threads, udev /dev management" +comment "petitboot needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library, threads, udev /dev management" depends on BR2_PACKAGE_KEXEC_ARCH_SUPPORTS depends on BR2_USE_MMU - depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS || \ + depends on !BR2_USE_WCHAR || !BR2_ENABLE_LOCALE || BR2_STATIC_LIBS || \ !BR2_TOOLCHAIN_HAS_THREADS || \ !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC) || \ !BR2_PACKAGE_HAS_UDEV diff --git a/package/petitboot/S15pb-discover b/package/petitboot/S15pb-discover index a37e33521f1a..15b428ce0e42 100644 --- a/package/petitboot/S15pb-discover +++ b/package/petitboot/S15pb-discover @@ -15,6 +15,7 @@ start() { # shellcheck disable=SC2174 # only apply -m to deepest dir mkdir -p -m 0775 /var/log/petitboot chown root:petitgroup /var/log/petitboot + export LANG="${LANG:-C.UTF-8}" # shellcheck disable=SC2086 # we need the word splitting start-stop-daemon -S -q -b -m -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ diff --git a/package/petitboot/pb-console b/package/petitboot/pb-console index eea40163d02f..55e5462f0457 100644 --- a/package/petitboot/pb-console +++ b/package/petitboot/pb-console @@ -13,6 +13,7 @@ start() { # shellcheck disable=SC2174 # only apply -m to deepest dir mkdir -p -m 0775 /var/log/petitboot chown root:petitgroup /var/log/petitboot + export LANG="${LANG:-C.UTF-8}" # shellcheck disable=SC2086 # we need the word splitting start-stop-daemon -S -q -x "/usr/libexec/petitboot/$DAEMON" \ diff --git a/package/petitboot/shell_profile b/package/petitboot/shell_profile index 1ca5e6364dba..6bbe49e6d113 100644 --- a/package/petitboot/shell_profile +++ b/package/petitboot/shell_profile @@ -1,2 +1,5 @@ +[ -r "/etc/default/petitboot" ] && . "/etc/default/petitboot" export ENV="/home/petituser/.shrc" +export LANG="${LANG:-C.UTF-8}" + exec /usr/libexec/petitboot/pb-console
The petitboot UI looks much nicer in a Unicode locale: * Items in the language selection submenu use multibyte Unicode characters. In other locales, they say "Unable to display text in this locale". * The combination of TERM=linux with a UTF-8 locale is required to trigger a special-case workaround in ncurses code[1]. Without this, line-drawing characters in the menu look like q's. Add a reminder that a UTF-8 locale should be generated for things to look right. Assume C.UTF-8 by default, allowing $LANG to be overridden (by /etc/default/petitboot or otherwise) if something else is desired. [1] https://invisible-island.net/ncurses/ncurses.faq.html#no_line_drawing Signed-off-by: Reza Arbab <arbab@linux.ibm.com> --- package/petitboot/Config.in | 8 ++++++-- package/petitboot/S15pb-discover | 1 + package/petitboot/pb-console | 1 + package/petitboot/shell_profile | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-)