summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-10-06 16:25:18 +0200
committerDave Reisner <dreisner@archlinux.org>2012-10-21 21:25:46 +0200
commit7b3890b0ec079b57a610147b18404444ff4c0190 (patch)
tree1759ac0fda1471e8b2f9ceb77b6289ab2845496f /install
parent2d8c7e66ae8db2eb8b7549d441669e3b26695198 (diff)
downloadmkinitcpio-7b3890b0ec079b57a610147b18404444ff4c0190.tar.gz
mkinitcpio-7b3890b0ec079b57a610147b18404444ff4c0190.tar.xz
convert autodetect cache to hash
If mkinitcpio -s is run, we still flush this cache to disk before exiting. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'install')
-rw-r--r--install/autodetect38
1 files changed, 21 insertions, 17 deletions
diff --git a/install/autodetect b/install/autodetect
index 4f1e4bb..907a85a 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -1,20 +1,19 @@
#!/bin/bash
build() {
- local -a md_devs
-
- _f_autodetect_cache=$_d_workdir/autodetect_modules
+ local m=
+ local -a md_devs mods
add_if_avail() {
- local resolved
+ local r= resolved=
# treat this as an alias, since ext3 might be aliased to ext4.
IFS=$'\n' read -rd '' -a resolved < \
<(modprobe -d "$_optmoduleroot" -S "$KERNELVERSION" -R "$1" 2>/dev/null)
- if (( ${#resolved[*]} )); then
- printf '%s\n' "${resolved[@]}" >>"$_f_autodetect_cache"
- fi
+ for r in "${resolved[@]}"; do
+ _autodetect_cache["$r"]=1
+ done
}
if [[ ! -d /sys/devices ]]; then
@@ -22,7 +21,10 @@ build() {
return 1
fi
- auto_modules >"$_f_autodetect_cache"
+ mapfile -t mods < <(auto_modules)
+ for m in "${mods[@]}"; do
+ _autodetect_cache["$m"]=1
+ done
# detect filesystem for root
if rootfstype=$(findmnt -uno fstype '/'); then
@@ -41,22 +43,24 @@ build() {
md_devs=(/sys/class/block/md*/md/level)
if [[ -e $md_devs ]]; then
quiet "found %d mdadm arrays to scan" "${#md_devs[*]}"
- awk '{ gsub(/raid[456]/, "raid456"); print; }' "${md_devs[@]}" |
- sort -u >>"$_f_autodetect_cache"
+ mapfile -t mods < <(awk '{ gsub(/raid[456]/, "raid456"); print; }' "${md_devs[@]}")
+ for m in "${mods[@]}"; do
+ _autodetect_cache["$m"]=1
+ done
fi
- if [[ -s $_f_autodetect_cache ]]; then
- quiet "caching %d modules" $(wc -l < "$_f_autodetect_cache")
+ if (( ${#_autodetect_cache[*]} )); then
+ quiet "caching %d modules" "${#_autodetect_cache[*]}"
fi
}
help() {
cat <<HELPEOF
-This hook shrinks your initramdisk to a smaller size by autodetecting your
-needed modules. Be sure to verify included modules are correct and none are
-missing. This hook must be run before other subsystem hooks in order to take
-advantage of auto-detection. Any hooks placed before 'autodetect' will be
-installed in full.
+This hook shrinks your initramfs to a smaller size by autodetecting the needed
+modules. Be sure to verify included modules are correct and none are missing.
+This hook must be run before other subsystem hooks in order to take advantage
+of auto-detection. Any hooks placed before 'autodetect' will be installed in
+full.
HELPEOF
}