summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--functions2
-rw-r--r--install/autodetect91
-rw-r--r--install/filesystems25
4 files changed, 41 insertions, 79 deletions
diff --git a/Makefile b/Makefile
index 4068f23..ff81525 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ install: all
install -m644 bash-completion ${DESTDIR}/etc/bash_completion.d/mkinitcpio
doc: mkinitcpio.5
-mkinitcpio.5: mkinitcpio.5.txt
+mkinitcpio.5: mkinitcpio.5.txt Makefile
a2x -d manpage \
-f manpage \
-a mansource=mkinitcpio \
diff --git a/functions b/functions
index ab0f850..ee6921c 100644
--- a/functions
+++ b/functions
@@ -69,7 +69,7 @@ auto_modules() {
IFS=$'\n' read -rd '' -a mods < \
<(find /sys/devices -name modalias -exec sort -zu {} + |
- xargs -0 modprobe -aRS "$KERNELVERSION" |
+ xargs -0 modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" |
sort -u)
printf "%s\n" "${mods[@]//-/_}"
diff --git a/install/autodetect b/install/autodetect
index b195913..7f22235 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -1,75 +1,40 @@
-# vim: set ft=sh:
+#!/bin/bash
-build()
-{
- MODULE_FILE="${TMPDIR}/autodetect_modules"
- #blegh, we'll let /tmp clean itself up
- AUTODETECT="$(auto_modules | \
- sed -e 's/ata_generic//g' -e 's/ide_generic//g')"
+build() {
+ MODULE_FILE=$TMPDIR/autodetect_modules
+ auto_modules | grep -xEv '(ata|ide)_generic' >"$MODULE_FILE"
- #Filesystem detection, only probe the device for /
- findfs ()
- {
- local rootdev
-
- if [ -f /proc/self/mountinfo -a -x /bin/findmnt ]; then
- /bin/findmnt -n -u -o fstype / 2>/dev/null
- fi
- }
+ if [[ ! -d /sys/devices ]]; then
+ error "/sys does not appear to be mounted. Unable to use autodetection"
+ return 1
+ fi
- if [ ${UID} -eq 0 -o "$(groups | grep disk)" != "" ]; then
- fss=$(findfs | sort | uniq)
- if [ -z "${fss}" ]; then
- error "Root file system type detection failed."
- autodetect_fs_detection_failed=1
- fi
- for fs in ${fss}; do
- allfs="${fs} $(modprobe --set-version ${KERNELVERSION} --resolve-alias ${fs})"
- for mod in ${allfs}; do
- for modfile in $(find "${MODULEDIR}" -type f -name "${mod}.ko" -or -name "${mod}.ko.gz"); do
- if [ -n "${modfile}" ]; then
- AUTODETECT="${AUTODETECT} ${modfile}"
- fi
- done
- done
- done
+ if ! findmnt -uno fstype "${BASEDIR:-/}" >>"$MODULE_FILE"; then
+ error "failed to detect root filesystem"
+ fs_autodetect_failed=1
+ fi
- if [ -e /sbin/mdadm ]; then
- for raidmod in $(/sbin/mdadm -E -s -v /dev/hd* /dev/sd* /dev/rd/* /dev/ida/* /dev/cciss/* /dev/ataraid/* /dev/mapper/* \
- | awk -Flevel= '{print $2}' | awk '{print $1}'); do
- case "${raidmod}" in
- raid4|raid5|raid6)
- AUTODETECT="${AUTODETECT} raid456" ;;
- *)
- AUTODETECT="${AUTODETECT} ${raidmod}" ;;
- esac
- done
+ if (( UID == 0 )) || in_array 'disk' $(groups); then
+ if [[ -x /sbin/mdadm ]]; then
+ /sbin/mdadm -Esv /dev/[hrsv]d* /dev/{ida,cciss,ataraid,mapper}/* |
+ sed -n 's/.*level=\([^ ]\+\) .*/\1/p' |
+ sed 's/\<raid[456]\>/raid456/g' | sort -u >>"$MODULE_FILE"
fi
else
- autodetect_fs_detection_failed=1
- autodetect_raid_detection_failed=1
- error "User does not have proper permissions to read superblocks, raid and filesystem modules are not detected"
+ error "Insufficient permission to perform autodetection for mdadm devices"
+ raid_autodetect_failed=1
fi
-
- for m in ${AUTODETECT}; do
- modname="$(get_module_name "${m}")"
- echo "${modname}" >> "${MODULE_FILE}"
- done
-
- BINARIES=""
- FILES=""
- SCRIPT=""
}
-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.
+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.
HELPEOF
}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/filesystems b/install/filesystems
index 337a6a5..64227bc 100644
--- a/install/filesystems
+++ b/install/filesystems
@@ -1,21 +1,18 @@
-# vim: set ft=sh:
+#!/bin/bash
-build()
-{
- if [ "${autodetect_fs_detection_failed}" = "1" ]; then
- MODULES=" $(all_modules '/kernel/fs' | grep -v "nls")"
+build() {
+ if (( fs_autodetect_failed )); then
+ MODULES=$(all_modules '/kernel/fs' | grep -v "nls")
else
- MODULES=" $(checked_modules '/kernel/fs' | grep -v "nls")"
+ MODULES=$(checked_modules '/kernel/fs' | grep -v "nls")
fi
- BINARIES=""
- FILES=""
- SCRIPT=""
}
-help ()
-{
-cat<<HELPEOF
- This hook adds filesystems modules to the image. If you would like to
- minimize the modules installed in the image, add the autodetect hook too.
+help() {
+ cat<<HELPEOF
+This hook adds filesystems modules to the image. If you would like to minimize
+the modules installed in the image, add the autodetect hook too.
HELPEOF
}
+
+# vim: set ft=sh ts=4 sw=4 et: