Commit | Line | Data |
---|---|---|
fc4da9a3 | 1 | #!/bin/sh |
b2441318 | 2 | # SPDX-License-Identifier: GPL-2.0 |
fc4da9a3 MM |
3 | # |
4 | # A depmod wrapper used by the toplevel Makefile | |
5 | ||
5a144a1a MY |
6 | if test $# -ne 2; then |
7 | echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2 | |
fc4da9a3 MM |
8 | exit 1 |
9 | fi | |
10 | DEPMOD=$1 | |
11 | KERNELRELEASE=$2 | |
12 | ||
934193a6 | 13 | if ! test -r System.map ; then |
f0b0d88a | 14 | echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2 |
fc4da9a3 MM |
15 | exit 0 |
16 | fi | |
8937e897 | 17 | |
cedd1862 LT |
18 | # legacy behavior: "depmod" in /sbin, no /sbin in PATH |
19 | PATH="$PATH:/sbin" | |
934193a6 | 20 | if [ -z $(command -v $DEPMOD) ]; then |
914b087f | 21 | echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2 |
934193a6 | 22 | echo "This is probably in the kmod package." >&2 |
914b087f | 23 | exit 0 |
934193a6 RD |
24 | fi |
25 | ||
bfe5424a MM |
26 | # older versions of depmod require the version string to start with three |
27 | # numbers, so we cheat with a symlink here | |
28 | depmod_hack_needed=true | |
8fc62e59 MM |
29 | tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX) |
30 | mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE" | |
31 | if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then | |
32 | if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \ | |
33 | -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then | |
bfe5424a MM |
34 | depmod_hack_needed=false |
35 | fi | |
36 | fi | |
8fc62e59 | 37 | rm -rf "$tmp_dir" |
bfe5424a MM |
38 | if $depmod_hack_needed; then |
39 | symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE" | |
40 | ln -s "$KERNELRELEASE" "$symlink" | |
41 | KERNELRELEASE=99.98.$KERNELRELEASE | |
42 | fi | |
43 | ||
fc4da9a3 MM |
44 | set -- -ae -F System.map |
45 | if test -n "$INSTALL_MOD_PATH"; then | |
46 | set -- "$@" -b "$INSTALL_MOD_PATH" | |
47 | fi | |
5a144a1a | 48 | "$DEPMOD" "$@" "$KERNELRELEASE" |
bfe5424a MM |
49 | ret=$? |
50 | ||
51 | if $depmod_hack_needed; then | |
52 | rm -f "$symlink" | |
53 | fi | |
54 | ||
55 | exit $ret |