summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-31 02:15:54 +0100
committerThomas Bächler <thomas@archlinux.org>2011-01-31 21:44:38 +0100
commit49c9c9fc1b37610a87fe3cf9f5e7b5785672264d (patch)
tree340b30a2d0c60dea519d7d6f86357f904b6af610
parent643e98eeb42677a9ce8c32fa44d4ee61d02f7fcf (diff)
downloadmkinitcpio-49c9c9fc1b37610a87fe3cf9f5e7b5785672264d.tar.gz
mkinitcpio-49c9c9fc1b37610a87fe3cf9f5e7b5785672264d.tar.xz
Short circuit add module if it already exists in image
Rather than go through all the hoops, check if the module has already been added by looking for its file path and skip the addition early if we can. This helps especially in modules with many recursive dependencies, and is most noticable when generating a full image with many modules. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--functions7
1 files changed, 6 insertions, 1 deletions
diff --git a/functions b/functions
index 96d5fe2..334938b 100644
--- a/functions
+++ b/functions
@@ -171,9 +171,13 @@ add_module ()
#find pattern - replace _ with [-_] to match either
fil="${m//_/[-_]}"
- msg " adding module ${fil}"
found=0
for path in $(find "${MODULEDIR}" -type f -name "${fil}.ko" -or -name "${fil}.ko.gz"); do
+ #skip expensive stuff if this module has already been added
+ if grep -q "file ${path} " "${FILELIST}"; then
+ found=1
+ continue
+ fi
#get needed firmware files
for fw in $(/sbin/modinfo -F firmware "${path}"); do
[ -f "/lib/firmware/$fw" ] && add_file "/lib/firmware/$fw"
@@ -186,6 +190,7 @@ add_module ()
fi
done
HAS_MODULES="y"
+ msg " adding module ${fil}"
add_file "${path}" && found=1
done
if [ ${found} -eq 1 ]; then