From 664ae4ebfc9fc8e358f5577bd80794d0bc0cc934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Thu, 20 Feb 2025 17:50:21 +0100 Subject: [PATCH] Remove unnecessary GRUB userspace tools and other files (#3887) Because the OTA hooks interact with GRUB environment using grub-editenv, we have BR2_TARGET_GRUB2_INSTALL_TOOLS enabled. However, that brings massive bloat of files that are never used in HAOS, as it also installs many other binaries, GRUB modules and translations. As it's not possible to configure what gets installed in grub2 package, remove the undesired files in the post-build function. This brings savings of ~8.5MB of space in the root partition. --- buildroot-external/scripts/rootfs-layer.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/buildroot-external/scripts/rootfs-layer.sh b/buildroot-external/scripts/rootfs-layer.sh index d88065ab2..014dfafc7 100755 --- a/buildroot-external/scripts/rootfs-layer.sh +++ b/buildroot-external/scripts/rootfs-layer.sh @@ -26,6 +26,15 @@ function fix_rootfs() { # 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 }