depmod.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 ! "$DEPMOD" -V 2>/dev/null | grep -q module-init-tools; then
  11. echo "Warning: you may need to install module-init-tools" >&2
  12. echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt" >&2
  13. sleep 1
  14. fi
  15. if ! test -r System.map -a -x "$DEPMOD"; then
  16. exit 0
  17. fi
  18. # older versions of depmod require the version string to start with three
  19. # numbers, so we cheat with a symlink here
  20. depmod_hack_needed=true
  21. tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
  22. mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
  23. if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
  24. if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
  25. -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
  26. depmod_hack_needed=false
  27. fi
  28. fi
  29. rm -rf "$tmp_dir"
  30. if $depmod_hack_needed; then
  31. symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
  32. ln -s "$KERNELRELEASE" "$symlink"
  33. KERNELRELEASE=99.98.$KERNELRELEASE
  34. fi
  35. set -- -ae -F System.map
  36. if test -n "$INSTALL_MOD_PATH"; then
  37. set -- "$@" -b "$INSTALL_MOD_PATH"
  38. fi
  39. "$DEPMOD" "$@" "$KERNELRELEASE"
  40. ret=$?
  41. if $depmod_hack_needed; then
  42. rm -f "$symlink"
  43. fi
  44. exit $ret