summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-11 04:20:28 +0200
committerDave Reisner <dreisner@archlinux.org>2011-09-27 12:18:04 +0200
commit5a0f7ebc8d2cede7532539268e0ffc0bd6816572 (patch)
tree1709a7c58504db390f0161977af581e32da394fc
parentff557b25937b3511dd04e009a4735b73d1279d4c (diff)
downloadmkinitcpio-5a0f7ebc8d2cede7532539268e0ffc0bd6816572.tar.gz
mkinitcpio-5a0f7ebc8d2cede7532539268e0ffc0bd6816572.tar.xz
functions: allow ignoring errors on module addition
We conditionally, but naively, add modules in some of our install hooks, but the kernel may not have these. Note that these modules can fail silently by detecting a '?' suffix on the module name. In conjunction with this, the add_module function now takes a flag, -t or --try, which will ignore module not found errors from modinfo. The config file will also support this syntax. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions20
-rw-r--r--install/base2
-rw-r--r--install/fw2
-rw-r--r--install/ide2
-rw-r--r--install/pata2
-rw-r--r--install/pcmcia5
-rw-r--r--install/sata2
-rw-r--r--install/scsi2
-rw-r--r--install/usb4
-rw-r--r--install/usbinput4
10 files changed, 28 insertions, 17 deletions
diff --git a/functions b/functions
index 3c0cd89..c7e167e 100644
--- a/functions
+++ b/functions
@@ -137,6 +137,13 @@ add_module() {
# $1: module name
local module path dep deps field value
+ local -i ign_errors=0
+
+ if [[ $1 = -@(t|-try) ]]; then
+ ign_errors=1
+ shift
+ fi
+
module=${1%.ko*}
# skip expensive stuff if this module has already been added
@@ -162,6 +169,7 @@ add_module() {
done < <(modinfo -b "$BASEDIR" -k "$KERNELVERSION" -0 "$module" 2>/dev/null)
if [[ -z $path ]]; then
+ (( ign_errors )) && return 0
error "module not found: \`%s'" "$module"
return 1
fi
@@ -173,9 +181,9 @@ add_module() {
# explicit module depends
case "$module" in
- fat) add_module "nls_cp437" ;;
- ocfs2) add_module "configfs" ;;
- libcrc32c) add_module "crc32c"; add_module "crc32c_intel" ;;
+ fat) add_module --try "nls_cp437" ;;
+ ocfs2) add_module --try "configfs" ;;
+ libcrc32c) add_module --try "crc32c"; add_module --try "crc32c_intel" ;;
esac
}
@@ -291,7 +299,11 @@ parse_hook() {
local item
for item in $MODULES; do
- add_module "$item"
+ if [[ ${item:(-1)} = '?' ]]; then
+ try=--try
+ item=${item%\?}
+ fi
+ add_module $try "$item"
done
for item in $BINARIES; do
diff --git a/install/base b/install/base
index b4f23d5..e85551c 100644
--- a/install/base
+++ b/install/base
@@ -24,7 +24,7 @@ build() {
read -r -a hooks <<< "$HOOKS"
{
- (( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]}"
+ (( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]%\?}"
(( ${#hooks[*]} )) && printf 'HOOKS="%s"\n' "${hooks[*]}"
} >"$BUILDROOT/config"
)
diff --git a/install/fw b/install/fw
index 94e70d1..f624de0 100644
--- a/install/fw
+++ b/install/fw
@@ -3,7 +3,7 @@
build() {
MODULES=$(checked_modules "/drivers/firewire/")
- [[ $MODULES ]] && MODULES+=" firewire-sbp2 sd_mod sr_mod"
+ [[ $MODULES ]] && MODULES+=" firewire-sbp2? sd_mod? sr_mod?"
}
help() {
diff --git a/install/ide b/install/ide
index 9443dd3..a8d9e97 100644
--- a/install/ide
+++ b/install/ide
@@ -3,7 +3,7 @@
build() {
MODULES="$(checked_modules "/ide/" | grep -v "legacy")"
- [[ $MODULES ]] && MODULES+=" ide-gd_mod"
+ [[ $MODULES ]] && MODULES+=" ide-gd_mod?"
}
help() {
diff --git a/install/pata b/install/pata
index c51356e..76f268c 100644
--- a/install/pata
+++ b/install/pata
@@ -5,7 +5,7 @@ build() {
MODULES+=" $(checked_modules "$filter")"
done
- [[ $MODULES ]] && MODULES+=" sd_mod"
+ [[ $MODULES ]] && MODULES+=" sd_mod?"
}
help() {
diff --git a/install/pcmcia b/install/pcmcia
index b390497..2e9ac9a 100644
--- a/install/pcmcia
+++ b/install/pcmcia
@@ -4,9 +4,8 @@ build() {
FILES="/etc/pcmcia/config.opts"
MODULES=" $(checked_modules '/drivers/pcmcia/' | grep -ve 'sound' -e 'net') $(checked_modules '/ide/legacy')"
- if [[ $MODULES ]]; then
- MODULES+=" sd_mod"
- fi
+ [[ $MODULES ]] MODULES+=" sd_mod?"
+
add_binary "/lib/udev/pcmcia-socket-startup"
add_binary "/lib/udev/pcmcia-check-broken-cis"
add_file "/lib/udev/rules.d/60-pcmcia.rules"
diff --git a/install/sata b/install/sata
index 39fe805..c9b67c3 100644
--- a/install/sata
+++ b/install/sata
@@ -6,7 +6,7 @@ build() {
MODULES+=" $(checked_modules "$filter")"
done
- [[ $MODULES ]] && MODULES+=" sd_mod"
+ [[ $MODULES ]] && MODULES+=" sd_mod?"
}
help() {
diff --git a/install/scsi b/install/scsi
index fa9e5d9..4c2abc5 100644
--- a/install/scsi
+++ b/install/scsi
@@ -6,7 +6,7 @@ build(){
$(checked_modules "/block/" | grep -E '(cciss|cpqarray|DAC960)')
$(checked_modules "/fusion/")"
- [[ $MODULES ]] && MODULES+=" sd_mod"
+ [[ $MODULES ]] && MODULES+=" sd_mod?"
}
help() {
diff --git a/install/usb b/install/usb
index 61020ab..fcb2a47 100644
--- a/install/usb
+++ b/install/usb
@@ -1,10 +1,12 @@
#!/bin/bash
build() {
+ local module=
+
MODULES="$(checked_modules "/usb/host" | grep -ve "_cs" -e "sl811_hcd" -e "isp116x_hcd")"
if [[ $MODULES ]]; then
- MODULES+=" usb_storage sd_mod sr_mod"
+ MODULES+=" usb_storage? sd_mod? sr_mod?"
MODULES+=" $(checked_modules "drivers/usb/storage/ums-*")"
fi
}
diff --git a/install/usbinput b/install/usbinput
index aa4e1a6..f89d0bd 100644
--- a/install/usbinput
+++ b/install/usbinput
@@ -2,9 +2,7 @@
build() {
MODULES=" $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl811_hcd" -e "isp116x_hcd")"
- MODULES+=" $(all_modules "/hid/hid-")"
-
- [[ $MODULES ]] && MODULES+=" usbhid"
+ MODULES+=" $(all_modules "/hid/hid-") usbhid?"
}
help() {