summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functions49
-rw-r--r--install/autodetect50
-rw-r--r--install/filesystems2
-rw-r--r--install/ide2
-rw-r--r--install/sata2
-rw-r--r--install/scsi6
-rw-r--r--install/usb2
-rw-r--r--mkinitcpio3
-rw-r--r--mkinitcpio.conf4
9 files changed, 66 insertions, 54 deletions
diff --git a/functions b/functions
index ac3d5a7..8396999 100644
--- a/functions
+++ b/functions
@@ -2,19 +2,42 @@
auto_modules ()
{
aliases=$(find /sys/devices/ -name modalias -exec cat {} \;)
- modprobe --set-version ${KERNELVERSION} --show-depends -a \
- $aliases 2>/dev/null | sed "s|insmod \(.*\)|\1|" |\
- grep ${@} | sort -u
+ mods=$(modprobe --set-version ${KERNELVERSION} --show-depends -a \
+ $aliases 2>/dev/null | sed 's|insmod \(.*\)|\1|' | grep ${@} | sort -u)
+
+ echo "${mods}"
+ [ "x${mods}" = "x" ] && return 1
+ return 0
}
all_modules ()
{
- find ${MODULEDIR} -name *.ko 2>/dev/null |\
- grep ${@} | sort -u
+ mods=$(find ${MODULEDIR} -name *.ko 2>/dev/null | grep ${@} | sort -u)
+
+ echo "${mods}"
+ [ "x${mods}" = "x" ] && return 1
+ return 0
+}
+
+checked_modules ()
+{
+ ret=1
+ if [ -e "${MODULE_FILE}" ]; then
+ for mod in $(all_modules ${@}); do
+ if grep "$(basename ${mod%%\.ko})" "${MODULE_FILE}" >/dev/null 2>&1; then
+ ret=0
+ echo ${mod}
+ fi
+ done
+ return $ret
+ else
+ all_modules ${@}
+ fi
}
msg () { [ "${QUIET}" = "n" ] && echo "${@}"; }
err () { echo "ERROR: ${@}" >&2; }
+die () { echo "FATAL: ${@}" >&2; exit 1; }
add_dir ()
{
@@ -35,7 +58,7 @@ add_device ()
local perms
perms="${5:-644}"
if ! grep "nod ${1}" "${FILELIST}" 2>&1 > /dev/null; then
- add_dir $(dirname "${1}")
+ add_dir $(dirname "${1}")
msg " adding node ${1}"
echo "nod ${1} ${perms} 0 0 ${2} ${3} ${4}" >> "${FILELIST}"
fi
@@ -53,11 +76,11 @@ add_symlink ()
dest="${2##$BASEDIR}"
add_dir $(dirname "${dest}")
if ! grep "slink ${dest} " "${FILELIST}" 2>&1 > /dev/null; then
- msg " adding link ${fil} -> ${dest}"
+ msg " adding link ${fil} -> ${dest}"
echo "slink ${dest} ${fil} $(stat -c '%a %u %g' ${fil})" >> "${FILELIST}"
fi
fi
- #fail quietly
+ #fail quietly
}
add_file ()
@@ -109,7 +132,7 @@ add_module ()
_finish_modules ()
{
- echo "wtf!"
+ echo "wtf!"
}
@@ -175,8 +198,8 @@ parse_hook ()
fi
done
- if [ "x${SCRIPT}" != "x" ]; then
- add_file "${HOOKDIR}/${SCRIPT}" "/hooks/${SCRIPT}"
- fi
+ if [ "x${SCRIPT}" != "x" ]; then
+ add_file "${HOOKDIR}/${SCRIPT}" "/hooks/${SCRIPT}"
+ fi
}
-# vim: set ft=sh ts=4 sw=4 noet:
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/autodetect b/install/autodetect
index 70dc779..6371d35 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -3,10 +3,9 @@
install ()
{
msg ":: Autodetecting modules"
+ MODULE_FILE="$(mktemp /tmp/initcpio_modules.XXXXXX)"
#blegh, we'll let /tmp clean itself up
- modtmp=$( mktemp /tmp/initcpio_modules.XXXXXX )
- modall=$( mktemp /tmp/initcpio_modulesall.XXXXXX )
- AUTODETECT=" $(auto_modules "/scsi/" | grep -v "imm"| grep -v "pcmcia" | grep -v "ide" && echo "sd_mod sr_mod")
+ AUTODETECT=" $((auto_modules "/scsi/" | grep -ve "imm" -e "pcmcia" -e "ide") && echo "sd_mod sr_mod")
$(auto_modules "/block/" && echo "sd_mod sr_mod")
$(auto_modules "/fusion/" && echo "sd_mod sr_mod")
$(auto_modules "/usb/" && echo "usb_storage usbhid sd_mod sr_mod")
@@ -14,33 +13,21 @@ install ()
$(auto_modules "/ieee1394/" && echo "sbp2 sd_mod sr_mod")
$(auto_modules "/cdrom/")
$(cat /proc/filesystems | grep -v nodev) "
-
+
for m in $AUTODETECT; do
- echo $(basename ${m//\.ko/}) >> $modtmp
+ modname="$(basename ${m%%\.ko})"
+ grep "${modname}" "${MODULE_FILE}" >/dev/null 2>&1 && continue
+ echo "${modname}" >> "${MODULE_FILE}"
# fixing missing depends for filesystems
- [ "$m" == "ext3" ] && echo "jbd" >> $modtmp
- [ "$m" == "afs" ] && echo "rxrpc" >> $modtmp
- [ "$m" == "cramfs" ] && echo "zlib_inflate" >> $modtmp
- [ "$m" == "isofs" ] && echo "zlib_inflate" >> $modtmp
- [ "$m" == "msdos" ] && echo "fat" >> $modtmp
- [ "$m" == "vfat" ] && echo "fat" >> $modtmp
- [ "$m" == "ocfs2" ] && echo "ocfs2_dlm" >> $modtmp
- [ "$m" == "ocfs2" ] && echo "jbd" >> $modtmp
- [ "$m" == "ocfs2" ] && echo "ocfs2_nodemanager" >> $modtmp
- [ "$m" == "ocfs2" ] && echo "configfs" >> $modtmp
+ [ "$m" = "ext3" ] && echo "jbd" >> "${MODULE_FILE}"
+ [ "$m" = "afs" ] && echo "rxrpc" >> "${MODULE_FILE}"
+ [ "$m" = "cramfs" ] && echo "zlib_inflate" >> "${MODULE_FILE}"
+ [ "$m" = "isofs" ] && echo "zlib_inflate" >> "${MODULE_FILE}"
+ [ "$m" = "msdos" ] && echo "fat" >> "${MODULE_FILE}"
+ [ "$m" = "vfat" ] && echo "fat" >> "${MODULE_FILE}"
+ [ "$m" = "ocfs2" ] && echo -e "ocfs2_dlm\njbd\nocfs2_nodemanager\nconfigfs" >> "${MODULE_FILE}"
done
- grep "file /lib/modules" ${FILELIST} >>$modall
- for i in `cat $modtmp`; do
- sed -i -e "\=/$i=d" $modall
- done
- for i in `grep "file /lib/modules" $modall | awk '{print $2}'`; do
- sed -i -e "\=$i=d" ${FILELIST}
- done
- msg "Included MODULES:"
- msg "-----------------"
- msg "$(grep "file /lib/modules/" ${FILELIST} | awk '{print $2}')"
- msg "-----------------"
BINARIES=""
FILES=""
SCRIPT=""
@@ -50,11 +37,10 @@ help ()
{
cat <<HELPEOF
This hook shrinks your initramdisk to a smaller size
- by autodetecting your needed modules.
- Please take a look at the included modules for completeness,
- else your system might be unbootable.
- Valid Hooks are: base,udev,ide,scsi,sata,usb,fw,filesystems
- Put this hook at the end of your valid hooks.
- Put other hooks behind autodetect hook.
+ 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
}
diff --git a/install/filesystems b/install/filesystems
index bebef3e..c9528a7 100644
--- a/install/filesystems
+++ b/install/filesystems
@@ -2,7 +2,7 @@
install ()
{
- MODULES=" $(all_modules '/kernel/fs' | grep -v "nls") "
+ MODULES=" $(checked_modules '/kernel/fs' | grep -v "nls") "
BINARIES=""
FILES=""
SCRIPT="filesystems"
diff --git a/install/ide b/install/ide
index ac0ea62..67b5be1 100644
--- a/install/ide
+++ b/install/ide
@@ -2,7 +2,7 @@
install ()
{
- MODULES=" $(all_modules "/ide/" | grep -v "legacy") ";
+ MODULES=" $(checked_modules "/ide/" | grep -v "legacy") ";
BINARIES=""
FILES=""
SCRIPT=""
diff --git a/install/sata b/install/sata
index a31b55a..51a61a7 100644
--- a/install/sata
+++ b/install/sata
@@ -2,7 +2,7 @@
install ()
{
- MODULES=" $(all_modules "scsi/.*ata") sx8 ahci pdc_adma sd_mod sr_mod piix"
+ MODULES=" $(checked_modules "scsi/.*ata" && echo "sx8 ahci pdc_adma sd_mod sr_mod piix")"
BINARIES=""
FILES=""
SCRIPT=""
diff --git a/install/scsi b/install/scsi
index fc6f940..2f107bc 100644
--- a/install/scsi
+++ b/install/scsi
@@ -2,9 +2,9 @@
install ()
{
- MODULES=" $(all_modules "/scsi/" | grep -ve "imm" -e "pdc_adma" -e "ahci" -e "ata" -e "pcmcia" -e "ide")
- $(all_modules "/block/" | grep -v "sx8")
- $(all_modules "/fusion/")"
+ MODULES=" $(checked_modules "/scsi/" | grep -ve "imm" -e "pdc_adma" -e "ahci" -e "ata" -e "pcmcia" -e "ide")
+ $(checked_modules "/block/" | grep -v "sx8")
+ $(checked_modules "/fusion/")"
BINARIES=""
FILES=""
SCRIPT=""
diff --git a/install/usb b/install/usb
index 0e655bd..03ed024 100644
--- a/install/usb
+++ b/install/usb
@@ -2,7 +2,7 @@
install ()
{
- MODULES=" $(all_modules "/usb/host" | grep -ve "_cs" -e "sl1811-hcd" -e "isp116x-hcd")
+ MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl1811-hcd" -e "isp116x-hcd")
usb_storage usbhid sd_mod sr_mod "
BINARIES=""
FILES=""
diff --git a/mkinitcpio b/mkinitcpio
index 061301f..77eda81 100644
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -20,6 +20,7 @@ FUNCTIONS="functions" #/lib/initramfs/functions
CONFIG="mkinitcpio.conf"
HOOKDIR="hooks"
INSTDIR="install"
+MODULE_FILE=""
SAVELIST=""
GENIMG=""
APPEND=""
@@ -122,6 +123,7 @@ if [ "${HAS_MODULES}" == "y" ]; then
add_file /tmp${MODULEDIR}/modules.dep ${MODULEDIR}/modules.dep
add_file /tmp${MODULEDIR}/modules.alias ${MODULEDIR}/modules.alias
add_file /tmp${MODULEDIR}/modules.symbols ${MODULEDIR}/modules.symbols
+ add_file "${MODULE_FILE}" "/modules"
fi
if [ "x$GENIMG" != "x" ]; then
@@ -133,4 +135,5 @@ if [ "x$GENIMG" != "x" ]; then
rm ${FILELIST}
fi
fi
+[ -e "${MODULE_FILE}" ] && rm "${MODULE_FILE}"
#vim:set ft=sh ts=4 sw=4 noet:
diff --git a/mkinitcpio.conf b/mkinitcpio.conf
index 9e0576d..e4c301d 100644
--- a/mkinitcpio.conf
+++ b/mkinitcpio.conf
@@ -39,7 +39,7 @@ FILES=""
#
# This setup will autodetect all modules for your system and should
# work as a sane default
-# HOOKS="base udev ide scsi sata filesystems autodetect"
+# HOOKS="base udev autodetect ide scsi sata filesystems"
#
# This setup will generate a 'full' image which supports most systems.
# No autodetection is done.
@@ -51,4 +51,4 @@ FILES=""
#
# This setup loads an LVM volume group on a usb device.
# HOOKS="base udev usb filesystems lvm"
-HOOKS="base udev ide scsi sata filesystems autodetect"
+HOOKS="base udev autodetect ide scsi sata filesystems"