[v2,11/13] package/openrc: add support to setterminal encoding
diff mbox series

Message ID 20190512195550.24457-11-michal.lyszczek@bofc.pl
State Changes Requested
Headers show
Series
  • [v2,01/13] package/openrc: new package (v0.41.2)
Related show

Commit Message

Michał Łyszczek May 12, 2019, 7:55 p.m. UTC
When openrc init is enabled, user can chose to set terminal
encoding to ascii, utf-8 or to keep default settings.

* system/Config.in
  New kconfig choice BR2_TARGET_GENERIC_TERMENCODING_* to
  choose terminal encoding. Depends on openrc init.

* package/openrc/openrc.mk
  monitors BR2_TARGET_GENERIC_TERMENCODING_* choice and
  make proper changes on TARGET_DIR to enable/disable
  terminal encoding set.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>

---
Changes v1 -> v2
  None
---
 package/openrc/openrc.mk | 19 +++++++++++++++++++
 system/Config.in         | 17 +++++++++++++++++
 2 files changed, 36 insertions(+)

Patch
diff mbox series

diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk
index 0feea22818..8d5e6ec381 100644
--- a/package/openrc/openrc.mk
+++ b/package/openrc/openrc.mk
@@ -55,4 +55,23 @@  endef
 OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_SET_GETTY
 endif # BR2_TARGET_GENERIC_GETTY
 
+ifeq ($(BR2_TARGET_GENERIC_TERMENCODING_KEEP),y)
+# openrc by default installs service to set terminal encoding, if we want to
+# keep default encoding we need to remove service from boot.
+define OPENRC_TERMENCODING
+	$(RM) $(TARGET_DIR)/etc/runlevels/boot/{termencoding,save-termencoding}
+	$(RM) $(TARGET_DIR)/etc/conf.d/termencoding
+endef
+OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_TERMENCODING
+else
+ifeq ($(BR2_TARGET_GENERIC_TERMENCODING_UTF8),y)
+# By default openrc will set terminal encoding to ASCII, if we want encoding
+# to be utf8, we need to set it.
+define OPENRC_TERMENCODING
+	echo "unicode=\"yes\"" > $(TARGET_DIR)/etc/conf.d/termencoding
+endef
+OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_TERMENCODING
+endif # BR2_TARGET_GENERIC_TERMENCODING_UTF8
+endif # BR2_TARGET_GENERIC_TERMENCODING_KEEP
+
 $(eval $(generic-package))
diff --git a/system/Config.in b/system/Config.in
index 32c502e310..08bcb517e4 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -390,6 +390,23 @@  comment "automatic network configuration via DHCP needs ifupdown or busybox or n
 		BR2_PACKAGE_SYSTEMD_NETWORKD) && !BR2_PACKAGE_OPENRC) || \
 		BR2_PACKAGE_OPENRC_NETIFRC)
 
+choice
+	prompt "Terminal encoding"
+	default BR2_TARGET_GENERIC_TERMENCODING_KEEP
+	depends on BR2_INIT_OPENRC
+	help
+	  Set terminal encoding. This makes sense only when you are going to
+	  use virtual terminals with external monitor (or qemu) that uses
+	  /dev/tty[1-12].
+
+config BR2_TARGET_GENERIC_TERMENCODING_KEEP
+	bool "keep default"
+config BR2_TARGET_GENERIC_TERMENCODING_ASCII
+	bool "ascii"
+config BR2_TARGET_GENERIC_TERMENCODING_UTF8
+	bool "utf-8"
+endchoice
+
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_SYSTEM_DEFAULT_PATH