Re: please revert commit ce8556cca6 "kbuild: verify that $DEPMOD is installed" introduced in v4.18.4.

Alexander Kapshuk
2018-08-23T15:55:46Z

On Thu, Aug 23, 2018 at 05:38:27PM +0900, Masahiro Yamada wrote:
> Hi Randy,
>
>
> 2018-08-23 8:33 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:
> > On 08/22/2018 11:53 AM, H. Nikolaus Schaller wrote:
> >> This patch requires that /sbin/depmod is installed and installable on
> >> the build host.
> >>
> >> But not all build hosts for cross compiling Linux are Linux systems
> >> and are able to provide a working port of depmod, especially at the
> >> file patch /sbin/depmod.
> >>
> >> I use, for example, a Darwin system to cross compile Linux and I run
> >> depmod -a on the embedded system once, after installing a new Linux
> >> kernel there.
> >>
> >> I have no problem with seeing a warning, but aborting the build process
> >> is IMHO a bad idea since the previous behaviour didn't harm many people
> >> as far as I see. Probably 99% of people compiling Linux kernels do that
> >> on Linux and 99% of those have depmod installed for optimal operation of
> >> their build host. So IMHO printing the warning is good enough.
> >
> > Thanks for the report and sorry about the problem.
> >
> > I'm OK with changing the error to a warning.
> > Does the patch below work for you?
> >
> > thanks.
> > ---
> > From: Randy Dunlap <rdunlap@infradead.org>
> >
> > When $DEPMOD is not found, only print a warning instead of exiting
> > with an error message and error status.
> >
> > E.g.:
> > Warning: 'make modules_install' requires /sbin/depmod. Please install it.
> > This is probably in the kmod package.
> > ../scripts/depmod.sh: line 44: /sbin/depmod: No such file or directory
> > make[1]: *** [/home/rdunlap/lnx/lnx-418/Makefile:1244: _modinst_post] Error 127
> > make: *** [Makefile:146: sub-make] Error 2
> >
> > Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> > Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
> > ---
> > scripts/depmod.sh | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > --- lnx-418.orig/scripts/depmod.sh
> > +++ lnx-418/scripts/depmod.sh
> > @@ -15,9 +15,8 @@ if ! test -r System.map ; then
> > fi
> >
> > if [ -z $(command -v $DEPMOD) ]; then
> > - echo "'make modules_install' requires $DEPMOD. Please install it." >&2
> > + echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2
> > echo "This is probably in the kmod package." >&2
> > - exit 1
>
>
> 'exit 0' is missing here.
>
> This shell script would fail, then abort the build process.
>
>
> > ../scripts/depmod.sh: line 44: /sbin/depmod: No such file or directory
> > make[1]: *** [/home/rdunlap/lnx/lnx-418/Makefile:1244: _modinst_post] Error 127
> > make: *** [Makefile:146: sub-make] Error 2
>
>
>
>
>
>
> --
> Best Regards
> Masahiro Yamada

May I suggest the following implementation:

diff -U0 scripts/depmod.sh ~/tmp/depmod.sh
--- scripts/depmod.sh 2018-08-10 17:14:19.036349222 +0300
+++ /home/sasha/tmp/depmod.sh 2018-08-23 18:07:23.486048827 +0300

# 'if' block may be omitted here. If System.map isn't there and isn't
readable, 'exit 0'.
@@ -13,3 +13 @@
-if ! test -r System.map ; then
- exit 0
-fi
+test -r System.map || exit 0

# Have the 'if' test statement syntax conform with the remainder of the
script, which uses 'if test' rather then the 2nd form of the test utility,
i.e. '[ expr ]'.
# In my view, the use of the negation operator, '!', makes the intent
clearer, and reads, 'if $DEPMOD not found', rather then 'if the length
of $DEPMOD is zero'.
@@ -17 +15 @@
-if [ -z $(command -v $DEPMOD) ]; then
+if test ! $(command -v $DEPMOD); then
@@ -20 +18 @@
- exit 1
+ exit 0

[Sample run]
# Testing for a non-existant utility:
% if test ! $(command -v cmd); then echo cmd not found; fi
% cmd not found

# Testing for a existing utility:
% if test ! $(command -v ed); then echo ed not found; fi

% if test $(command -v ed); then echo ed found; fi
% ed found