blob: d34e280368036fe5c37059ee626f33a4ed925295 [file] [log] [blame]
# This is still a bit of an experiment.
if ! [ -f modules.order ]; then
echo 'virtme-prep-kdir-mods must be run from a kernel build directory' >&2
exit 1
# Some distro don't have /sbin or /usr/sbin in user's default path. Make sure
# to setup the right path to find all the commands needed to setup the modules
# (depmod, etc.).
if ! [ -f "modules.order" ]; then
echo "modules.order is missing. Your kernel may be too old or you didn't make modules." >&2
exit 1
# Set up .virtme_mods/lib/modules/0.0.0 as a module directory for this kernel,
# but fill it with symlinks instead of actual modules.
mkdir -p "$MODDIR/kernel"
ln -srfT . "$MODDIR/build"
# Remove all preexisting symlinks and add symlinks to all modules that belong
# to the build kenrnel.
find "$MODDIR/kernel" -type l -print0 |xargs -0 rm -f --
while read -r i; do
[ ! -e "$i" ] && i=$(echo "$i" | sed s:^kernel/::)
mkdir -p "$MODDIR/kernel/$(dirname "$i")"
ln -sr "$i" "$MODDIR/kernel/$i"
done < modules.order
# Link in the files that make modules_install would copy
ln -srf modules.builtin modules.builtin.modinfo modules.order "$MODDIR/"
# Now run depmod to collect dependencies
depmod -ae -F -b .virtme_mods "$FAKEVER"