depmod.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. #
  3. # A depmod wrapper used by the toplevel Makefile
  4. if test $# -ne 2; then
  5. echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
  6. exit 1
  7. fi
  8. DEPMOD=$1
  9. KERNELRELEASE=$2
  10. if ! test -r System.map -a -x "$DEPMOD"; then
  11. exit 0
  12. fi
  13. # older versions of depmod require the version string to start with three
  14. # numbers, so we cheat with a symlink here
  15. depmod_hack_needed=true
  16. tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
  17. mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
  18. if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
  19. if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
  20. -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
  21. depmod_hack_needed=false
  22. fi
  23. fi
  24. rm -rf "$tmp_dir"
  25. if $depmod_hack_needed; then
  26. symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
  27. ln -s "$KERNELRELEASE" "$symlink"
  28. KERNELRELEASE=99.98.$KERNELRELEASE
  29. fi
  30. set -- -ae -F System.map
  31. if test -n "$INSTALL_MOD_PATH"; then
  32. set -- "$@" -b "$INSTALL_MOD_PATH"
  33. fi
  34. "$DEPMOD" "$@" "$KERNELRELEASE"
  35. ret=$?
  36. if $depmod_hack_needed; then
  37. rm -f "$symlink"
  38. fi
  39. exit $ret