From c02b9b90d896a580ed54c83cf13087e38e1cb8ee Mon Sep 17 00:00:00 2001 From: ColorfulRhino <131405023+ColorfulRhino@users.noreply.github.com> Date: Sun, 10 Mar 2024 13:29:14 +0100 Subject: [PATCH] build script: configuration: Check if ROOTFS_TYPE is supported by build host --- lib/functions/configuration/main-config.sh | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index acc68fbae5..d8b6a61edb 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -138,6 +138,45 @@ function do_main_configuration() { ;; esac + # Check if the filesystem type is supported by the build host + if [[ $CONFIG_DEFS_ONLY != yes ]]; then # don't waste time if only gathering config defs + if [[ -f "/proc/filesystems" ]]; then + # Check if the filesystem is listed in /proc/filesystems + if ! grep -q "\<$ROOTFS_TYPE\>" /proc/filesystems; then # ensure exact match with \<...\> + # Try modprobing the fs module since it doesn't show up in /proc/filesystems if it's an unloaded module versus built-in + if ! modprobe "$ROOTFS_TYPE"; then + exit_with_error "Filesystem type unsupported by build host:" "$ROOTFS_TYPE" + else + display_alert "Sucessfully loaded kernel mopdule for filesystem" "$ROOTFS_TYPE" "" + fi + fi + + # For f2fs, check if support for extended attributes is enabled in kernel config (otherwise will fail later when using rsync) + if [ "$ROOTFS_TYPE" = "f2fs" ]; then + local build_host_kernel_config="" + # Try to find kernel config in different places + if [ -f "/boot/config-$(uname -r)" ]; then + build_host_kernel_config="/boot/config-$(uname -r)" + elif [ -f "/proc/config.gz" ]; then + pigz -dc /proc/config.gz > /tmp/build_host_kernel_config # use pigz since it's a host dependency listed in prepare-host.sh + build_host_kernel_config="/tmp/build_host_kernel_config" + else + display_alert "Could not find kernel config of build host." "Build might fail in case of missing kernel configs for '${ROOTFS_TYPE}'." "wrn" + fi + + # Check if required configurations are set + if [ -n "$build_host_kernel_config" ]; then + if ! grep -q '^CONFIG_F2FS_FS_XATTR=y$' "$build_host_kernel_config" || \ + ! grep -q '^CONFIG_F2FS_FS_SECURITY=y$' "$build_host_kernel_config"; then + exit_with_error "Required kernel configurations for f2fs filesystem not enabled." "Please enable CONFIG_F2FS_FS_XATTR and CONFIG_F2FS_FS_SECURITY in your kernel configuration." "err" + fi + fi + fi + else + display_alert "Could not check filesystem support via /proc/filesystems on build host." "Build might fail in case of unsupported rootfs type." "wrn" + fi + fi + # Support for LUKS / cryptroot if [[ $CRYPTROOT_ENABLE == yes ]]; then enable_extension "fs-cryptroot-support" # add the tooling needed, cryptsetup