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

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