[arch-projects] [mkinitcpio][PATCH 1/3] Handle softdeps in modules
modinfo outputs softdeps which we can add if they exist (failing quietly on not-found). this obviates the need for some of our own module quirks. The output of modinfo can take many forms, as it's nearly freeform text in the .modinfo section of the kernel module. The basic form is: softdep: pre: foo But it might also be: softdep: pre: foo bar post: baz Or: softdep: pre: foo softdep: post: bar So just parse the entire line, discarding anything that ends with a ':'. --- functions | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/functions b/functions index 362d07b..500dcc0 100644 --- a/functions +++ b/functions @@ -348,7 +348,7 @@ add_module() { # discovered and added. # $1: module name - local module= path= deps= field= value= firmware=() + local module= path= softdeps= deps= field= value= firmware=() local ign_errors=0 [[ $KERNELVERSION == none ]] && return 0 @@ -375,6 +375,14 @@ add_module() { firmware) firmware+=("$value") ;; + softdep) + read -ra softdeps <<<"$value" + for module in "${softdeps[@]}"; do + [[ $module == *: ]] && continue + add_module "$module" + done + add_module "$softdep?" + ;; esac done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$module" 2>/dev/null) @@ -403,9 +411,8 @@ add_module() { ocfs2) add_module "configfs?" ;; - btrfs|libcrc32c) - add_module "crc32c_intel?" - add_module "crc32c?" + btrfs) + add_module "libcrc32c?" ;; esac } @@ -780,7 +787,7 @@ install_modules() { depmod -b "$BUILDROOT" "$KERNELVERSION" # remove all non-binary module.* files (except devname for on-demand module loading) - rm "$moduledest"/modules.!(*.bin|devname) + rm "$moduledest"/modules.!(*.bin|devname|softdep) } # vim: set ft=sh ts=4 sw=4 et: -- 2.8.3
This is true of more and more modules with the advent of aliases, e.g. $ modinfo -F filename crc32c /lib/modules/4.6.2-rampage/kernel/arch/x86/crypto/crc32c-intel.ko.gz /lib/modules/4.6.2-rampage/kernel/crypto/crc32c_generic.ko.gz --- functions | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/functions b/functions index 500dcc0..bdba988 100644 --- a/functions +++ b/functions @@ -348,8 +348,8 @@ add_module() { # discovered and added. # $1: module name - local module= path= softdeps= deps= field= value= firmware=() - local ign_errors=0 + local target= module= softdeps= deps= field= value= firmware=() + local ign_errors=0 found=0 [[ $KERNELVERSION == none ]] && return 0 @@ -358,15 +358,19 @@ add_module() { set -- "${1%?}" fi - module=${1%.ko*} + target=${1%.ko*} target=${target//-/_} # skip expensive stuff if this module has already been added - (( _addedmodules["${module//-/_}"] )) && return + (( _addedmodules["$target"] )) && return while IFS=':= ' read -r -d '' field value; do case "$field" in filename) - path=$value + found=1 + module=${value##*/} module=${module%.ko*} + quiet "adding module: %s" "$module" + _modpaths["$value"]=1 + _addedmodules["${module//-/_}"]=1 ;; depends) IFS=',' read -r -a deps <<< "$value" @@ -384,26 +388,21 @@ add_module() { add_module "$softdep?" ;; esac - done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$module" 2>/dev/null) + done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$target" 2>/dev/null) - if [[ -z $path ]]; then + if (( !found )); then (( ign_errors )) && return 0 - error "module not found: \`%s'" "$module" + error "module not found: \`%s'" "$target" return 1 fi if (( ${#firmware[*]} )); then add_firmware "${firmware[@]}" || - warning 'Possibly missing firmware for module: %s' "$module" + warning 'Possibly missing firmware for module: %s' "$target" fi - # aggregate modules and add them all at once to save some forks - quiet "adding module: %s" "$1" - _modpaths["$path"]=1 - _addedmodules["${module//-/_}"]=1 - # handle module quirks - case $module in + case $target in fat) add_module "nls_cp437?" add_module "nls_iso8859-1?" -- 2.8.3
ref: https://bugs.archlinux.org/task/49380 --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index bdba988..9260920 100644 --- a/functions +++ b/functions @@ -410,7 +410,7 @@ add_module() { ocfs2) add_module "configfs?" ;; - btrfs) + btrfs|f2fs) add_module "libcrc32c?" ;; esac -- 2.8.3
On Mon, Jun 27, 2016 at 08:19:35AM -0400, Dave Reisner wrote:
modinfo outputs softdeps which we can add if they exist (failing quietly on not-found). this obviates the need for some of our own module quirks.
The output of modinfo can take many forms, as it's nearly freeform text in the .modinfo section of the kernel module. The basic form is:
softdep: pre: foo
But it might also be:
softdep: pre: foo bar post: baz
Or:
softdep: pre: foo softdep: post: bar
So just parse the entire line, discarding anything that ends with a ':'. ---
Replying to myself, because apparently I'm bad at rebasing my own work.
functions | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/functions b/functions index 362d07b..500dcc0 100644 --- a/functions +++ b/functions @@ -348,7 +348,7 @@ add_module() { # discovered and added. # $1: module name
- local module= path= deps= field= value= firmware=() + local module= path= softdeps= deps= field= value= firmware=() local ign_errors=0
[[ $KERNELVERSION == none ]] && return 0 @@ -375,6 +375,14 @@ add_module() { firmware) firmware+=("$value") ;; + softdep) + read -ra softdeps <<<"$value" + for module in "${softdeps[@]}"; do + [[ $module == *: ]] && continue + add_module "$module"
The arg to add_module needs to be suffixed with '?'
+ done + add_module "$softdep?"
This add_module call doesn't belong here...
+ ;; esac done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$module" 2>/dev/null)
@@ -403,9 +411,8 @@ add_module() { ocfs2) add_module "configfs?" ;; - btrfs|libcrc32c) - add_module "crc32c_intel?" - add_module "crc32c?" + btrfs) + add_module "libcrc32c?" ;; esac } @@ -780,7 +787,7 @@ install_modules() { depmod -b "$BUILDROOT" "$KERNELVERSION"
# remove all non-binary module.* files (except devname for on-demand module loading) - rm "$moduledest"/modules.!(*.bin|devname) + rm "$moduledest"/modules.!(*.bin|devname|softdep) }
# vim: set ft=sh ts=4 sw=4 et: -- 2.8.3
participants (2)
-
Dave Reisner
-
Dave Reisner