Back to home page

LXR

 
 

    


0001 #!/bin/sh
0002 #
0003 # A depmod wrapper used by the toplevel Makefile
0004 
0005 if test $# -ne 3; then
0006         echo "Usage: $0 /sbin/depmod <kernelrelease> <symbolprefix>" >&2
0007         exit 1
0008 fi
0009 DEPMOD=$1
0010 KERNELRELEASE=$2
0011 SYMBOL_PREFIX=$3
0012 
0013 if ! test -r System.map -a -x "$DEPMOD"; then
0014         exit 0
0015 fi
0016 
0017 # older versions of depmod don't support -P <symbol-prefix>
0018 # support was added in module-init-tools 3.13
0019 if test -n "$SYMBOL_PREFIX"; then
0020         release=$("$DEPMOD" --version)
0021         package=$(echo "$release" | cut -d' ' -f 1)
0022         if test "$package" = "module-init-tools"; then
0023                 version=$(echo "$release" | cut -d' ' -f 2)
0024                 later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1)
0025                 if test "$later" != "$version"; then
0026                         # module-init-tools < 3.13, drop the symbol prefix
0027                         SYMBOL_PREFIX=""
0028                 fi
0029         fi
0030         if test -n "$SYMBOL_PREFIX"; then
0031                 SYMBOL_PREFIX="-P $SYMBOL_PREFIX"
0032         fi
0033 fi
0034 
0035 # older versions of depmod require the version string to start with three
0036 # numbers, so we cheat with a symlink here
0037 depmod_hack_needed=true
0038 tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
0039 mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
0040 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
0041         if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
0042                 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
0043                 depmod_hack_needed=false
0044         fi
0045 fi
0046 rm -rf "$tmp_dir"
0047 if $depmod_hack_needed; then
0048         symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
0049         ln -s "$KERNELRELEASE" "$symlink"
0050         KERNELRELEASE=99.98.$KERNELRELEASE
0051 fi
0052 
0053 set -- -ae -F System.map
0054 if test -n "$INSTALL_MOD_PATH"; then
0055         set -- "$@" -b "$INSTALL_MOD_PATH"
0056 fi
0057 "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX
0058 ret=$?
0059 
0060 if $depmod_hack_needed; then
0061         rm -f "$symlink"
0062 fi
0063 
0064 exit $ret