summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Linderud <morten@linderud.pw>2023-10-20 22:03:38 +0200
committerMorten Linderud <morten@linderud.pw>2023-10-20 22:03:38 +0200
commit9cc2565ad32aeef9eb70096bd80cb45b4cd96e52 (patch)
treedd3ceae76805497f7979451c412dad554b50ddc9
parentb8f91b24e32d0dbf4de9a3d3e12ca38040a79908 (diff)
parent1ed3dc01c1b7e12e6ae824c589f76c32e767ba5d (diff)
Merge remote-tracking branch 'origin/merge-requests/267'
* origin/merge-requests/267: install/autodetect: match non-empty tokens install/autodetect: match on both MODALIAS and DRIVER install/autodetect: deduplicate the detected modules list install/autodetect: use sed for MODALIAS processing install/autodetect: move auto_modules() where it's used install/autodetect: pass the kernel version to modprobe
-rw-r--r--functions12
-rw-r--r--install/autodetect16
2 files changed, 14 insertions, 14 deletions
diff --git a/functions b/functions
index a8c9103..1e5ead1 100644
--- a/functions
+++ b/functions
@@ -374,18 +374,6 @@ modprobe() {
command modprobe -d "$_optmoduleroot" -S "$KERNELVERSION" "$@"
}
-auto_modules() {
- # Perform auto detection of modules via sysfs.
-
- local mods=()
-
- mapfile -t mods < <(find /sys/devices -name uevent \
- -exec sort -u {} + | awk -F= '$1 == "MODALIAS" && !_[$0]++')
- mapfile -t mods < <(modprobe -S "$1" -qaR "${mods[@]#MODALIAS=}")
-
- (( ${#mods[*]} )) && printf "%s\n" "${mods[@]//-/_}"
-}
-
all_modules() {
# Add modules to the initcpio, filtered by grep.
# $@: filter arguments to grep
diff --git a/install/autodetect b/install/autodetect
index 61422b0..918cdd8 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -7,13 +7,25 @@ build() {
[[ "$KERNELVERSION" == 'none' ]] && return 0
+ auto_modules() {
+ # Perform auto detection of modules via sysfs.
+
+ local mods=()
+
+ mapfile -t mods < <(find /sys/devices -name uevent \
+ -exec sort -u {} + | sed -n 's/\(DRIVER\|MODALIAS\)=\(.\+\)/\2/p')
+ mapfile -t mods < <(modprobe -S "$KERNELVERSION" -qaR "${mods[@]}" | sort -u)
+
+ (( ${#mods[*]} )) && printf "%s\n" "${mods[@]//-/_}"
+ }
+
add_if_avail() {
local r='' resolved=()
# treat this as an alias, since ext3 might be aliased to ext4. also, as
# of linux 3.9, we can find any filesystem by the alias "fs-$name"
# rather than having to guess at the corresponding module name.
- mapfile -t resolved < <(modprobe -Ra {fs-,}"$1" 2>/dev/null)
+ mapfile -t resolved < <(modprobe -S "$KERNELVERSION" -qaR {fs-,}"$1")
for r in "${resolved[@]}"; do
_autodetect_cache["$r"]=1
@@ -25,7 +37,7 @@ build() {
return 1
fi
- mapfile -t mods < <(auto_modules "$KERNELVERSION")
+ mapfile -t mods < <(auto_modules)
for m in "${mods[@]}"; do
_autodetect_cache["$m"]=1
done