de581b99ca
Pull request #38470 added support for running/building kernels without
modules. This got merged in 38e04bbf29
but
unfortunately while this works perfectly on kernels without modules it
also makes sure that *every* kernel gets no modules.
So all of our VM tests fail since that merge with something like this:
machine# loading module loop...
machine# modprobe: FATAL: Module loop not found in directory /lib/modules/4.14.33
machine# loading module vfat...
machine# modprobe: FATAL: Module vfat not found in directory /lib/modules/4.14.33
machine# loading module nls_cp437...
machine# modprobe: FATAL: Module nls_cp437 not found in directory /lib/modules/4.14.33
machine# loading module nls_iso8859-1...
machine# modprobe: FATAL: Module nls_iso8859-1 not found in directory /lib/modules/4.14.33
machine# loading module fuse...
machine# modprobe: FATAL: Module fuse not found in directory /lib/modules/4.14.33
machine# loading module dm_mod...
machine# modprobe: FATAL: Module dm_mod not found in directory /lib/modules/4.14.33
I shortly tested this against the "misc" VM test and the test is working
again.
In the long term (and I currently don't have time for this) it would be
better to also have a VM test which tests a kernel without modules.
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @roberth, @7c6f434c
60 lines
2.0 KiB
Bash
60 lines
2.0 KiB
Bash
source $stdenv/setup
|
|
|
|
# When no modules are built, the $out/lib/modules directory will not
|
|
# exist. Because the rest of the script assumes it does exist, we
|
|
# handle this special case first.
|
|
if ! test -d "$kernel/lib/modules"; then
|
|
if test -z "$rootModules" || test -n "$allowMissing"; then
|
|
mkdir -p "$out"
|
|
exit 0
|
|
else
|
|
echo "Required modules: $rootModules"
|
|
echo "Can not derive a closure of kernel modules because no modules were provided."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
version=$(cd $kernel/lib/modules && ls -d *)
|
|
|
|
echo "kernel version is $version"
|
|
|
|
# Determine the dependencies of each root module.
|
|
closure=
|
|
for module in $rootModules; do
|
|
echo "root module: $module"
|
|
deps=$(modprobe --config no-config -d $kernel --set-version "$version" --show-depends "$module" \
|
|
| sed 's/^insmod //') \
|
|
|| if test -z "$allowMissing"; then exit 1; fi
|
|
if [[ "$deps" != builtin* ]]; then
|
|
closure="$closure $deps"
|
|
fi
|
|
done
|
|
|
|
echo "closure:"
|
|
mkdir -p $out/lib/modules/"$version"
|
|
for module in $closure; do
|
|
target=$(echo $module | sed "s^$NIX_STORE.*/lib/modules/^$out/lib/modules/^")
|
|
if test -e "$target"; then continue; fi
|
|
if test \! -e "$module"; then continue; fi # XXX: to avoid error with "cp builtin builtin"
|
|
mkdir -p $(dirname $target)
|
|
echo $module
|
|
cp $module $target
|
|
# If the kernel is compiled with coverage instrumentation, it
|
|
# contains the paths of the *.gcda coverage data output files
|
|
# (which it doesn't actually use...). Get rid of them to prevent
|
|
# the whole kernel from being included in the initrd.
|
|
nuke-refs $target
|
|
echo $target >> $out/insmod-list
|
|
done
|
|
|
|
mkdir -p $out/lib/firmware
|
|
for module in $closure; do
|
|
for i in $(modinfo -F firmware $module); do
|
|
mkdir -p "$out/lib/firmware/$(dirname "$i")"
|
|
echo "firmware for $module: $i"
|
|
cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null || if test -z "$allowMissing"; then exit 1; fi
|
|
done
|
|
done
|
|
|
|
depmod -b $out -a $version
|