From 8effa5a686037ba3c2f8c97753f398b73cc54881 Mon Sep 17 00:00:00 2001 From: George Prekas Date: Wed, 6 Apr 2022 16:15:15 -0500 Subject: [PATCH 01/12] Fix for missing /lib/modules. Even when supplied with $SUPERMIN_MODULES, supermin tries to access /lib/modules. This directory does not exist by default in all the environments. --- src/format_ext2.ml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/format_ext2.ml b/src/format_ext2.ml index e311ea6..484b469 100644 --- a/src/format_ext2.ml +++ b/src/format_ext2.ml @@ -95,8 +95,22 @@ let build_ext2 debug basedir files modpath kernel_version appliance size printf "supermin: ext2: copying kernel modules\n%!"; (* Import the kernel modules. *) - ext2fs_copy_file_from_host fs "/lib" "/lib"; - ext2fs_copy_file_from_host fs "/lib/modules" "/lib/modules"; + (try + ext2fs_copy_file_from_host fs "/lib" "/lib" + with Unix_error _ -> + (* If /lib doesn't exist on the host, create /lib directory + * in the image, populating it with mode etc from host / + *) + ext2fs_copy_file_from_host fs "/" "/lib" + ); + + (try + ext2fs_copy_file_from_host fs "/lib/modules" "/lib/modules" + with Unix_error _ -> + (* As above, if /lib/modules does not exist on the host. *) + ext2fs_copy_file_from_host fs "/" "/lib/modules" + ); + ext2fs_copy_dir_recursively_from_host fs modpath ("/lib/modules/" ^ kernel_version); -- 2.37.3