simplify kernel detection

This commit is contained in:
Tobias Powalowski 2023-08-26 20:11:16 +02:00
parent 2c06a6c6d0
commit 32eaaac721
2 changed files with 15 additions and 14 deletions

View file

@ -119,7 +119,7 @@ preload_builtin_modules() {
local modname field value local modname field value
local -a path local -a path
# Prime the _addedmodules list with the builtins for this kernel. # Prime the _addedmodules list with the builtins for this kernel.
if [[ -r $_d_kmoduledir/modules.builtin.modinfo ]]; then # kmod>=27 and kernel >=5.2 required!
while IFS=.= read -rd '' modname field value; do while IFS=.= read -rd '' modname field value; do
_addedmodules[${modname//-/_}]=2 _addedmodules[${modname//-/_}]=2
case "$field" in case "$field" in
@ -128,7 +128,6 @@ preload_builtin_modules() {
;; ;;
esac esac
done <"$_d_kmoduledir/modules.builtin.modinfo" done <"$_d_kmoduledir/modules.builtin.modinfo"
fi
} }
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
@ -187,10 +186,11 @@ fi
[[ -e /dev/fd ]] || die "/dev must be mounted!" [[ -e /dev/fd ]] || die "/dev must be mounted!"
if [[ -z "${_KERNEL}" ]]; then if [[ -z "${_KERNEL}" ]]; then
msg "Autodetecting kernel from: /etc/archboot/presets/${_RUNNING_ARCH}" msg "Autodetecting kernel from: /etc/archboot/presets/${_RUNNING_ARCH}"
if [[ ! -f "$(grep 'kver' "/etc/archboot/presets/${_RUNNING_ARCH}" | cut -d '=' -f2 | sed -e 's#"##g')" ]]; then . /etc/archboot/presets/${_RUNNING_ARCH}
if [[ ! -f "${ALL_kver}" ]]; then
die "specified kernel image does not exist!" die "specified kernel image does not exist!"
fi fi
_KERNELVERSION="$(_kver "$(grep 'kver' "/etc/archboot/presets/${_RUNNING_ARCH}" | cut -d '=' -f2 | sed -e 's#"##g')")" _KERNELVERSION="$(_kver ${ALL_kver})"
else else
msg "Using specified kernel: ${_KERNEL}" msg "Using specified kernel: ${_KERNEL}"
if [[ ! -f "${_KERNEL}" ]]; then if [[ ! -f "${_KERNEL}" ]]; then

View file

@ -389,6 +389,7 @@ install_modules() {
msg "Generating module dependencies" msg "Generating module dependencies"
map add_file "$_d_kmoduledir"/modules.{builtin,builtin.modinfo,order} map add_file "$_d_kmoduledir"/modules.{builtin,builtin.modinfo,order}
depmod -b "$BUILDROOT" "${_KERNELVERSION}" depmod -b "$BUILDROOT" "${_KERNELVERSION}"
# remove all non-binary module.* files (except devname for on-demand module loading) # remove all non-binary module.* files (except devname for on-demand module loading
rm "${BUILDROOT}${_d_kmoduledir}"/modules.!(*.bin|devname|softdep) # and builtin.modinfo for checking on builtin modules)
rm "${BUILDROOT}${_d_kmoduledir}"/modules.!(*.bin|*.modinfo|devname|softdep)
} }