1source $stdenv/setup
2
3set -o pipefail
4
5PATH=$kmod/sbin:$PATH
6
7version=$(cd $kernel/lib/modules && ls -d *)
8
9echo "kernel version is $version"
10
11# Determine the dependencies of each root module.
12closure=
13for module in $rootModules; do
14 echo "root module: $module"
15 deps=$(modprobe --config no-config -d $kernel --set-version "$version" --show-depends "$module" \
16 | sed 's/^insmod //') \
17 || if test -z "$allowMissing"; then exit 1; fi
18 if [[ "$deps" != builtin* ]]; then
19 closure="$closure $deps"
20 fi
21done
22
23echo "closure:"
24mkdir -p $out/lib/modules/"$version"
25for module in $closure; do
26 target=$(echo $module | sed "s^$NIX_STORE.*/lib/modules/^$out/lib/modules/^")
27 if test -e "$target"; then continue; fi
28 if test \! -e "$module"; then continue; fi # XXX: to avoid error with "cp builtin builtin"
29 mkdir -p $(dirname $target)
30 echo $module
31 cp $module $target
32 # If the kernel is compiled with coverage instrumentation, it
33 # contains the paths of the *.gcda coverage data output files
34 # (which it doesn't actually use...). Get rid of them to prevent
35 # the whole kernel from being included in the initrd.
36 nuke-refs $target
37 echo $target >> $out/insmod-list
38done
39
40depmod -b $out -a $version