2012-08-10 21:50:14

by Arokux X

[permalink] [raw]
Subject: Failure while make modules_install if kmod was compiled with --with-rootprefix set

Dear Mr. Marek, dear all,

I have detected a hidden failure while building the kernel. If
--with-rootprefix is set for kmod, then depmod will look for modules
installed at the location $ROOTPREFIX/lib/modules/<version>. The
kernel build system does not know anything about $ROOTPREFIX, and so
the wrong directory is created for the test if the hack is needed for
an older versin of depmod at scripts/depmod.sh:19 mkdir -p
"$tmp_dir/lib/modules/$KERNELRELEASE". That is why "$DEPMOD" -b
"$tmp_dir" $KERNELRELEASE will always fail and kernel build system
will think that the hack is always needed and depmod_hack_needed will
always be true. After that the created symlink is wrong since it also
does not contain $ROOTPREFIX, which depmod will preprend. That is why
depmod will fail.

To cure the problem an additional variable $MOD_ROOT_PREFIX can be
introduced. With the help of this variable the paths in the
scripts/depmod.sh are parametrized. This variable should be set to the
same value which was passed to --with-rootprefix while compilation of
kmod. Example: if --with-rootprefix is set to /usr and the modules
should be installed at the location /home/john, then the the following
make call should be issued: make INSTALL_MOD_PATH=/home/john
$MOD_ROOT_PREFIX=/usr. After that the modules will be installed at
/home/john/usr. However should be also added to other places where the
actuall installing takes place, and so I do not this this solution is
optimal, nevertheless, please find the patch for depmod.sh at the end
of this e-mail.

A more superior solution could be probably a new option for depmod
which would allow an overwriting of the $ROOTPREFIX. This option can
be used in depmod.sh then to overwrite $ROOTPREFIX with an empty
string.

I was unsure as of which solution is better if any at all and so such
a lengthy e-mail...

With kind regards,

Arokux


diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 2ae4817..87a6e42 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -16,16 +16,18 @@ fi
# numbers, so we cheat with a symlink here
depmod_hack_needed=true
tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
-mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
+mkdir -p "$tmp_dir/$MOD_ROOT_PREFIX/lib/modules/$KERNELRELEASE"
+"$DEPMOD" -b "$tmp_dir" $KERNELRELEASE
+echo hello
if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
- if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
- -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
+ if test -e
"$tmp_dir/$MOD_ROOT_PREFIX/lib/modules/$KERNELRELEASE/modules.dep" -o
\
+ -e
"$tmp_dir/$MOD_ROOT_PREFIX/lib/modules/$KERNELRELEASE/modules.dep.bin";
then
depmod_hack_needed=false
fi
fi
rm -rf "$tmp_dir"
if $depmod_hack_needed; then
- symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
+ symlink="$INSTALL_MOD_PATH/$MOD_ROOT_PREFIX/lib/modules/99.98.$KERNELRELEASE"
ln -s "$KERNELRELEASE" "$symlink"
KERNELRELEASE=99.98.$KERNELRELEASE
fi


2012-08-30 14:37:09

by Michal Marek

[permalink] [raw]
Subject: Re: Failure while make modules_install if kmod was compiled with --with-rootprefix set

On 10.8.2012 23:50, Arokux B. wrote:
> Dear Mr. Marek, dear all,
>
> I have detected a hidden failure while building the kernel. If
> --with-rootprefix is set for kmod, then depmod will look for modules
> installed at the location $ROOTPREFIX/lib/modules/<version>. The
> kernel build system does not know anything about $ROOTPREFIX, and so
> the wrong directory is created for the test if the hack is needed for
> an older versin of depmod at scripts/depmod.sh:19 mkdir -p
> "$tmp_dir/lib/modules/$KERNELRELEASE". That is why "$DEPMOD" -b
> "$tmp_dir" $KERNELRELEASE will always fail

I think we can revert the hack, because the three-digit version number
will stay for foreseeable future and depmod is not the only tool that
used to rely on this. However, what you describe looks like a bug in
kmod's depmod. -b sets the basedir, depmod should not prepend it with
any compiled-in string.

Michal