summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-04-21 22:58:55 +0200
committerDave Reisner <dreisner@archlinux.org>2013-04-24 16:24:36 +0200
commit45d340c154b7c956822e0c1a5ff4b956851e2cd6 (patch)
tree23810073b4c63a0208c62b6c11be846aa360b4e6 /functions
parent28dcc378781b22ee44363484583812515a4859e3 (diff)
downloadmkinitcpio-45d340c154b7c956822e0c1a5ff4b956851e2cd6.tar.gz
mkinitcpio-45d340c154b7c956822e0c1a5ff4b956851e2cd6.tar.xz
functions: implement add_firmware
Add this as an abstraction for the various places firmware might exist. Additionally, don't complain about missing firmware unless *none* of it can be found -- and even then, only throw a warning. NB: this means that users building images without the autodetect hook and a rudimentary hook like "block" will see warnings which are going to cause panic, chaos, and upheaval. I fully expect that this will result in extra non-work for me in the form of closing invalid bug reports. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions32
1 files changed, 25 insertions, 7 deletions
diff --git a/functions b/functions
index fac153c..bb28f34 100644
--- a/functions
+++ b/functions
@@ -318,12 +318,30 @@ add_checked_modules() {
return $(( !${#mods[*]} ))
}
+add_firmware() {
+ # add a firmware file to the image.
+ # $1: firmware path fragment
+
+ local fw fwpath r=1
+
+ for fw; do
+ for fwpath in "${_d_firmware[@]}"; do
+ if [[ -f $fwpath/$fw ]]; then
+ add_file "$fwpath/$fw" "$fwpath/$fw" 644 && r=0
+ break
+ fi
+ done
+ done
+
+ return $r
+}
+
add_module() {
# Add a kernel module to the initcpio image. Dependencies will be
# discovered and added.
# $1: module name
- local module= path= deps= field= value=
+ local module= path= deps= field= value= firmware=()
local ign_errors=0
if [[ $1 = *\? ]]; then
@@ -346,12 +364,7 @@ add_module() {
map add_module "${deps[@]}"
;;
firmware)
- # ensure that we favor updated firmware files
- if [[ -f $_d_firmware/updates/$value ]]; then
- add_file "$_d_firmware/updates/$value" "$_d_firmware/updates/$value" 644
- else
- add_file "$_d_firmware/$value" "$_d_firmware/$value" 644
- fi
+ firmware+=("$value")
;;
esac
done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$module" 2>/dev/null)
@@ -362,6 +375,11 @@ add_module() {
return 1
fi
+ if (( ${#firmware[*]} )); then
+ add_firmware "${firmware[@]}" ||
+ warning 'Possibly missing firmware for module: %s' "$module"
+ fi
+
# aggregate modules and add them all at once to save some forks
quiet "adding module: %s" "$1"
_modpaths["$path"]=1