Jan Čermák 0354f47ecf
Make console keymaps configurable through localectl (#4424)
For users having non-English, and especially non-qwerty layouts, using the host
shell can be very awkward. There was no option to change the keymaps as they
haven't been installed in the OS, and the persistence couldn't have been
achieved because of read-only /etc.

With upstream patch merged in #4224, we have an option to put
/etc/vconsole.conf to a writable location and use the same approach as in the
timezone PR. This is needed because even if we only bind-mounted the file from
the overlay directory, the Systemd services which start early will still refer
to the inode on the read-only FS. Also, gzip is required as current version of
kbd in Buildroot (v2.6.4) always compresses the keymaps using gzip. We can get
rid of this after we bump to kbd v2.9.0 [1] or newer. The overall bloat in
local build of the OS is slightly over 1 MiB, so it is acceptable.

With these changes, the `localectl set-keymap` command can be used to use any
available keymap from the installed `kbd` package (refer to `localectl
list-keymaps` for complete lists) and persist it between reboots.

[1] https://github.com/legionus/kbd/releases/tag/v2.9.0

Fixes #1775
2025-12-02 17:20:28 +01:00

58 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
function fix_rootfs() {
# Cleanup etc
rm -rf "${TARGET_DIR:?}/etc/init.d"
rm -rf "${TARGET_DIR:?}/etc/network"
rm -rf "${TARGET_DIR:?}/etc/X11"
rm -rf "${TARGET_DIR:?}/etc/xdg"
# Cleanup root
rm -rf "${TARGET_DIR:?}/media"
rm -rf "${TARGET_DIR:?}/srv"
rm -rf "${TARGET_DIR:?}/opt"
# Remove info pages
rm -rf "${TARGET_DIR:?}/share/info"
rm -rf "${TARGET_DIR:?}/usr/share/info"
# Cleanup miscs
rm -rf "${TARGET_DIR}/usr/lib/modules-load.d"
# systemd-update-done.service relies on writeable /var and /etc
rm -f "${TARGET_DIR}/usr/lib/systemd/system/sysinit.target.wants/systemd-update-done.service"
# Fix: tempfs with /srv
sed -i "/srv/d" "${TARGET_DIR}/usr/lib/tmpfiles.d/home.conf"
# Fix: Could not generate persistent MAC address
sed -i "s/MACAddressPolicy=persistent/MACAddressPolicy=none/g" "${TARGET_DIR}/usr/lib/systemd/network/99-default.link"
# Use systemd-resolved for Host OS resolve
sed -i '/^hosts:/ {/resolve/! s/files/resolve [!UNAVAIL=return] files/}' "${TARGET_DIR}/etc/nsswitch.conf"
# Remove unnecessary grub userspace tools, config, modules and translations
find "${TARGET_DIR}"/usr/{,s}bin -name "grub-*" -not -name "grub-editenv" -delete
rm -rf "${TARGET_DIR}/etc/grub.d"
rm -rf "${TARGET_DIR}/usr/lib/grub"
if [ -d "${TARGET_DIR}/share/locale" ]; then
find "${TARGET_DIR}/share/locale" -name "grub.mo" -delete
find "${TARGET_DIR}/share/locale" -type d -empty -delete
fi
}
function install_tini_docker() {
ln -fs /usr/bin/tini "${TARGET_DIR}/usr/bin/docker-init"
}
function setup_localtime() {
# localtime is writable through SYSTEMD_ETC_LOCALTIME
ln -fs /mnt/overlay/etc/localtime "${TARGET_DIR}/etc/localtime"
}
function setup_vconsole() {
# vconsole.conf is writable through SYSTEMD_ETC_VCONSOLE_CONF
ln -fs /mnt/overlay/etc/vconsole.conf "${TARGET_DIR}/etc/vconsole.conf"
}