diff options
author | Morten Linderud <morten@linderud.pw> | 2023-10-20 22:03:58 +0200 |
---|---|---|
committer | Morten Linderud <morten@linderud.pw> | 2023-10-20 22:03:58 +0200 |
commit | 16bfb5cc479b624e6c048a66e18bed519e46bab0 (patch) | |
tree | 0acf1c7c0278127144ee61754a19463629ecfe2a | |
parent | 9cc2565ad32aeef9eb70096bd80cb45b4cd96e52 (diff) | |
parent | 1760deea68f4a915a502c5602c82c7f9f8404a51 (diff) |
Merge remote-tracking branch 'origin/merge-requests/269'
* origin/merge-requests/269:
add_checked_modules_from_symbol: avoid double-lookup
add_module_from_symbol: rework the API
-rw-r--r-- | functions | 26 | ||||
-rw-r--r-- | install/kms | 2 | ||||
-rw-r--r-- | man/mkinitcpio.8.adoc | 10 |
3 files changed, 24 insertions, 14 deletions
@@ -1077,21 +1077,27 @@ find_module_from_symbol() { done } -add_module_from_symbol() { - local mods - local -i use_add_checked_modules=0 +add_all_modules_from_symbol() { + local -a mods - if [[ "$1" == '-c' ]]; then - use_add_checked_modules=1 - shift - fi mapfile -t mods < <(find_module_from_symbol "$@") (( ${#mods[@]} )) || return 1 - if (( use_add_checked_modules )); then - map add_checked_modules "${mods[@]}" || : + map add_module "${mods[@]}" +} + +add_checked_modules_from_symbol() { + local -a mods + + # _autodetect_cache is declared in mkinitcpio and assigned in install/autodetect + # shellcheck disable=SC2154 + if (( ${#_autodetect_cache[*]} )); then + mapfile -t mods < <(find_module_from_symbol "$@" | grep -xFf <(printf '%s\n' "${!_autodetect_cache[@]}")) else - map add_module "${mods[@]}" + mapfile -t mods < <(find_module_from_symbol "$@") fi + + (( ${#mods[*]} )) || return 1 + map add_module "${mods[@]}" } # vim: set ft=sh ts=4 sw=4 et: diff --git a/install/kms b/install/kms index 9fa6487..f1e10b0 100644 --- a/install/kms +++ b/install/kms @@ -6,7 +6,7 @@ build() { map add_checked_modules '/drivers/char/agp/' '/drivers/gpu/drm/' # modules that implement the privacy screen interface - add_module_from_symbol -c 'drm_privacy_screen_register' '=drivers/platform' + add_checked_modules_from_symbol 'drm_privacy_screen_register' '=drivers/platform' } help() { diff --git a/man/mkinitcpio.8.adoc b/man/mkinitcpio.8.adoc index d3f3c50..3571ca0 100644 --- a/man/mkinitcpio.8.adoc +++ b/man/mkinitcpio.8.adoc @@ -272,11 +272,15 @@ functions exist to facilitate this. and added. The argument can be a rule file name (discovered from well known udev paths) or an absolute path. -*add_module_from_symbol* [ *-c* ] _symbol_ _paths..._:: +*add_all_modules_from_symbol* _symbol_ _paths_:: Adds modules from the _paths_ directories containing the _symbol_ to the image. - Uses *add_module* by default, but by specifying the *-c* flag, - *add_checked_modules* will be used instead. + +*add_checked_modules_from_symbol* _symbol_ _paths_:: + Similar to *add_all_modules_from_symbol* with the constraint that only + modules matching the whitelist generated by the autodetect hook will be + added to the image. If the autodetect hook is not present in the image, this + function is identical to *add_all_modules_from_symbol*. == About runtime hooks |