proc: test /proc/thread-self symlink
[linux/fpc-iii.git] / scripts / depmod.sh
blob999d585eaa7358dd813b8b0d5a204fc1ea48ca3c
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # A depmod wrapper used by the toplevel Makefile
6 if test $# -ne 2; then
7 echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
8 exit 1
9 fi
10 DEPMOD=$1
11 KERNELRELEASE=$2
13 if ! test -r System.map ; then
14 exit 0
17 if [ -z $(command -v $DEPMOD) ]; then
18 echo "'make modules_install' requires $DEPMOD. Please install it." >&2
19 echo "This is probably in the kmod package." >&2
20 exit 1
23 # older versions of depmod require the version string to start with three
24 # numbers, so we cheat with a symlink here
25 depmod_hack_needed=true
26 tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
27 mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
28 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
29 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
30 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
31 depmod_hack_needed=false
34 rm -rf "$tmp_dir"
35 if $depmod_hack_needed; then
36 symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
37 ln -s "$KERNELRELEASE" "$symlink"
38 KERNELRELEASE=99.98.$KERNELRELEASE
41 set -- -ae -F System.map
42 if test -n "$INSTALL_MOD_PATH"; then
43 set -- "$@" -b "$INSTALL_MOD_PATH"
45 "$DEPMOD" "$@" "$KERNELRELEASE"
46 ret=$?
48 if $depmod_hack_needed; then
49 rm -f "$symlink"
52 exit $ret