Blame SOURCES/0001-skip-kernel-buildin-modules.patch

b9f7b3
From df5e18b8d7c8359b48bc133bfa29734934d18160 Mon Sep 17 00:00:00 2001
b9f7b3
From: Johannes Meixner <jsmeix@suse.com>
b9f7b3
Date: Mon, 10 Aug 2020 16:20:38 +0200
b9f7b3
Subject: [PATCH] Merge pull request #2469 from
b9f7b3
 rear/skip-kernel-builtin-modules-issue2414
b9f7b3
b9f7b3
In 400_copy_modules.sh skip copying kernel modules that are builtin modules.
b9f7b3
The new behaviour is that when modules are listed in modules.builtin
b9f7b3
and are also shown by modinfo then those modules are now skipped.
b9f7b3
Before for such modules the modules file(s) would have been included
b9f7b3
in the recovery system.
b9f7b3
See https://github.com/rear/rear/issues/2414
b9f7b3
---
b9f7b3
 usr/share/rear/build/GNU/Linux/400_copy_modules.sh | 12 ++++++++++--
b9f7b3
 1 file changed, 10 insertions(+), 2 deletions(-)
b9f7b3
b9f7b3
diff --git a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
b9f7b3
index d8d733d2..641b7f83 100644
b9f7b3
--- a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
b9f7b3
+++ b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
b9f7b3
@@ -133,8 +133,13 @@ for dummy in "once" ; do
b9f7b3
         module=${module#.o}
b9f7b3
         # Strip trailing ".ko" if there:
b9f7b3
         module=${module#.ko}
b9f7b3
-        # Continue with the next module if the current one does not exist:
b9f7b3
+        # Continue with the next module if the current one does not exist as a module file:
b9f7b3
         modinfo $module 1>/dev/null || continue
b9f7b3
+        # Continue with the next module if the current one is a kernel builtin module
b9f7b3
+        # cf. https://github.com/rear/rear/issues/2414#issuecomment-668632798
b9f7b3
+        # Quoting the grep search value is mandatory here ($module might be empty or blank),
b9f7b3
+        # cf. "Beware of the emptiness" in https://github.com/rear/rear/wiki/Coding-Style
b9f7b3
+        grep -q "$( echo $module | tr '_-' '..' )" /lib/modules/$KERNEL_VERSION/modules.builtin && continue
b9f7b3
         # Resolve module dependencies:
b9f7b3
         # Get the module file plus the module files of other needed modules.
b9f7b3
         # This is currently only a "best effort" attempt because
b9f7b3
@@ -166,7 +171,10 @@ done
b9f7b3
 
b9f7b3
 # Remove those modules that are specified in the EXCLUDE_MODULES array:
b9f7b3
 for exclude_module in "${EXCLUDE_MODULES[@]}" ; do
b9f7b3
-    # Continue with the next module if the current one does not exist:
b9f7b3
+    # Continue with the next module only if the current one does not exist as a module file
b9f7b3
+    # but do not continue with the next module if the current one is a kernel builtin module
b9f7b3
+    # so when a module file exists that gets removed regardless if it is also a builtin module
b9f7b3
+    # cf. https://github.com/rear/rear/issues/2414#issuecomment-669115481
b9f7b3
     modinfo $exclude_module 1>/dev/null || continue
b9f7b3
     # In this case it is ignored when a module exists but 'modinfo -F filename' cannot show its filename
b9f7b3
     # because then it is assumed that also no module file had been copied above: