-
Notifications
You must be signed in to change notification settings - Fork 66
build_library: Fix depmod issues with sysext kmods #2976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
SCRIPT_NAME=$(basename "$(realpath "${BASH_SOURCE[0]}")") | ||
SYSEXT_NAME=${SCRIPT_NAME#sysext_mangle_} | ||
SYSEXT_NAME=${SYSEXT_NAME%.sh} | ||
DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")") | ||
. "$DIR/sysext_mangle_kmod" | ||
|
||
rootfs="${1}" | ||
|
||
cd "${rootfs}" | ||
configure_modprobe "$SYSEXT_NAME" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysext_mangle_flatcar-nvidia-drivers-535 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysext_mangle_flatcar-nvidia-drivers-535 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysext_mangle_flatcar-nvidia-drivers-535 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysext_mangle_flatcar-nvidia-drivers-535 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysext_mangle_flatcar-nvidia-drivers-535 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
configure_modprobe() { | ||
local sysext_name="${1}" | ||
shift | ||
|
||
local module_directories=(./usr/lib/modules/*-flatcar/) | ||
|
||
mkdir -p ./usr/lib/modprobe.d/ | ||
for module_name in $(find "${module_directories[@]}" -type f \( -name "*.ko" -o -name "*.ko.*" \) -printf "%f\n" | sed -E 's/\.ko(\.\w+)?$//'); do | ||
cat <<EOF >> "./usr/lib/modprobe.d/10-${sysext_name}-kmod-sysext.conf" | ||
install $module_name /usr/local/bin/_${sysext_name}_modprobe_helper $module_name | ||
remove $module_name /usr/local/bin/_${sysext_name}_modprobe_helper -r $module_name | ||
EOF | ||
done | ||
|
||
mkdir -p ./usr/local/bin/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized /use/libexec would be a better location for these internal helpers. There are scenarios where /ust/local needs to be writeable and that is accomplished by using a sysext that redirects /usr/local to a different path using a symlink. Using the same path would conflict with those scenarios. |
||
install -m0755 -D /dev/stdin "./usr/local/bin/_${sysext_name}_modprobe_helper" <<'EOF' | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
action="Loading" | ||
for arg in "$@"; do | ||
if [[ $arg == "-r" ]]; then | ||
action="Unloading" | ||
fi | ||
done | ||
echo "$action kernel module from a sysext..." | ||
chewi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
KMOD_PATH=/usr/lib/modules/$(uname -r) | ||
TMP_DIR=$(mktemp -d) | ||
trap "rm -rf -- '${TMP_DIR}'" EXIT | ||
mkdir "${TMP_DIR}"/{upper,work} | ||
|
||
unshare -m bash -s -- "${@}" <<FOE | ||
set -euo pipefail | ||
if ! mountpoint -q "${KMOD_PATH}"; then | ||
mount -t overlay overlay -o lowerdir="${KMOD_PATH}",upperdir="${TMP_DIR}"/upper,workdir="${TMP_DIR}"/work "${KMOD_PATH}" | ||
depmod | ||
fi | ||
modprobe --ignore-install "\${@}" | ||
FOE | ||
EOF | ||
|
||
# prevent the sysext from masking /usr/lib/modules/*-flatcar/modules.XXX | ||
find "${module_directories[@]}" -maxdepth 1 -mindepth 1 -type f -delete | ||
} |
Uh oh!
There was an error while loading. Please reload this page.