mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
build script: config: Move fs-compatibility-check into a function
for better readability
This commit is contained in:
@@ -140,46 +140,7 @@ function do_main_configuration() {
|
||||
|
||||
# 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 module 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
|
||||
# Try to extract kernel config from /proc/config.gz
|
||||
if command -v gzip &> /dev/null; then
|
||||
gzip -dc /proc/config.gz > /tmp/build_host_kernel_config
|
||||
build_host_kernel_config="/tmp/build_host_kernel_config"
|
||||
else
|
||||
display_alert "Could extract kernel config from build host, please install 'gzip'." "Build might fail in case of missing kernel configs for '${ROOTFS_TYPE}'" "wrn"
|
||||
fi
|
||||
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
|
||||
check_filesystem_compatibility_on_host
|
||||
fi
|
||||
|
||||
# Support for LUKS / cryptroot
|
||||
@@ -563,3 +524,48 @@ function set_git_build_repo_url_and_commit_vars() {
|
||||
display_alert "BUILD_REPOSITORY_COMMIT set during ${1}" "${BUILD_REPOSITORY_COMMIT}" "debug"
|
||||
return 0
|
||||
}
|
||||
|
||||
function check_filesystem_compatibility_on_host() {
|
||||
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 module 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
|
||||
# Try to extract kernel config from /proc/config.gz
|
||||
if command -v gzip &> /dev/null; then
|
||||
gzip -dc /proc/config.gz > /tmp/build_host_kernel_config
|
||||
build_host_kernel_config="/tmp/build_host_kernel_config"
|
||||
else
|
||||
display_alert "Could extract kernel config from build host, please install 'gzip'." "Build might fail in case of missing kernel configs for '${ROOTFS_TYPE}'" "wrn"
|
||||
fi
|
||||
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
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user