#!/bin/sh # # A depmod wrapper used by the toplevel Makefile if test $Argc -ne 3 { echo "Usage: $0 /sbin/depmod " > !2 exit 1 } global DEPMOD := $1 global KERNELRELEASE := $2 global SYMBOL_PREFIX := $3 if ! test -r System.map -a -x $DEPMOD { exit 0 } # older versions of depmod don't support -P # support was added in module-init-tools 3.13 if test -n $SYMBOL_PREFIX { global release := $[$DEPMOD --version] global package := $[echo $release | cut -d' ' -f 1] if test $package = "module-init-tools" { global version := $[echo $release | cut -d' ' -f 2] global later := $[printf '%s\n' $version "3.13" | sort -V | tail -n 1] if test $later != $version { # module-init-tools < 3.13, drop the symbol prefix global SYMBOL_PREFIX := ''"" } } if test -n $SYMBOL_PREFIX { global SYMBOL_PREFIX := ""-P $SYMBOL_PREFIX"" } } # older versions of depmod require the version string to start with three # numbers, so we cheat with a symlink here global depmod_hack_needed := 'true' global tmp_dir := $[mktemp -d $(TMPDIR:-/tmp)/depmod.XXXXXX] mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE" if $DEPMOD -b $tmp_dir $KERNELRELEASE !2 >/dev/null { if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \ -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin" { global depmod_hack_needed := 'false' } } rm -rf $tmp_dir if $depmod_hack_needed { global symlink := ""$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"" ln -s $KERNELRELEASE $symlink global KERNELRELEASE := "99.98.$KERNELRELEASE" } set -- -ae -F System.map if test -n $INSTALL_MOD_PATH { set -- @Argv -b $INSTALL_MOD_PATH } $DEPMOD @Argv $KERNELRELEASE $SYMBOL_PREFIX global ret := $Status if $depmod_hack_needed { rm -f $symlink } exit $ret (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {($ VSub_Pound "$#")} {(-ne)} {(3)}) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Usage: ") ($ VSub_Number "$0") (" /sbin/depmod ")) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[32])] ) (C {(exit)} {(1)}) ] spids: [-1 21] ) ] spids: [-1 40] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DEPMOD) op:Equal rhs:{($ VSub_Number "$1")} spids:[42])] spids: [42] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KERNELRELEASE) op: Equal rhs: {($ VSub_Number "$2")} spids: [45] ) ] spids: [45] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SYMBOL_PREFIX) op: Equal rhs: {($ VSub_Number "$3")} spids: [48] ) ] spids: [48] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (C {(test)} {(-r)} {(System.map)} {(-a)} {(-x)} {(DQ ($ VSub_Name "$DEPMOD"))}) ] negated: True ) terminator: ) ] action: [(C {(exit)} {(0)})] spids: [-1 71] ) ] spids: [-1 78] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-n)} {(DQ ($ VSub_Name "$SYMBOL_PREFIX"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:release) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(DQ ($ VSub_Name "$DEPMOD"))} {(--version)})] ) left_token: spids: [102 108] ) } spids: [101] ) ] spids: [101] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:package) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$release"))}) (C {(cut)} {(-d) (SQ <" ">)} {(-f)} {(1)}) ] negated: False ) ] ) left_token: spids: [112 131] ) } spids: [111] ) ] spids: [111] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$package"))} {(Lit_Other "=")} {(DQ (module-init-tools))} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:version) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$release"))}) (C {(cut)} {(-d) (SQ <" ">)} {(-f)} {(2)}) ] negated: False ) ] ) left_token: spids: [153 172] ) } spids: [152] ) ] spids: [152] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:later) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(printf)} {(SQ <"%s\\n">)} {(DQ ($ VSub_Name "$version"))} {(DQ (3.13))} ) (C {(sort)} {(-V)}) (C {(tail)} {(-n)} {(1)}) ] negated: False ) ] ) left_token: spids: [176 204] ) } spids: [175] ) ] spids: [175] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$later"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ ($ VSub_Name "$version"))} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SYMBOL_PREFIX) op: Equal rhs: {(DQ )} spids: [230] ) ] spids: [230] ) ] spids: [-1 223] ) ] spids: [-1 235] ) ] spids: [-1 149] ) ] spids: [-1 238] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-n)} {(DQ ($ VSub_Name "$SYMBOL_PREFIX"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SYMBOL_PREFIX) op: Equal rhs: {(DQ ("-P ") ($ VSub_Name "$SYMBOL_PREFIX"))} spids: [255] ) ] spids: [255] ) ] spids: [-1 252] ) ] spids: [-1 262] ) ] spids: [-1 98] ) ] spids: [-1 264] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:depmod_hack_needed) op:Equal rhs:{(true)} spids:[273])] spids: [273] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:tmp_dir) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(mktemp)} {(-d)} { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (tmp)} ) spids: [282 287] ) (/depmod.XXXXXX) } ) ] ) left_token: spids: [277 289] ) } spids: [276] ) ] spids: [276] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name "$tmp_dir") (/lib/modules/) ($ VSub_Name "$KERNELRELEASE"))}) (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [ {(DQ ($ VSub_Name "$DEPMOD"))} {(-b)} {(DQ ($ VSub_Name "$tmp_dir"))} {($ VSub_Name "$KERNELRELEASE")} ] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[315])] ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-e)} { (DQ ($ VSub_Name "$tmp_dir") (/lib/modules/) ($ VSub_Name "$KERNELRELEASE") (/modules.dep) ) } {(-o)} {(-e)} { (DQ ($ VSub_Name "$tmp_dir") (/lib/modules/) ($ VSub_Name "$KERNELRELEASE") (/modules.dep.bin) ) } ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:depmod_hack_needed) op: Equal rhs: {(false)} spids: [352] ) ] spids: [352] ) ] spids: [-1 349] ) ] spids: [-1 356] ) ] spids: [-1 319] ) ] spids: [-1 358] ) (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$tmp_dir"))}) (If arms: [ (if_arm cond: [(Sentence child:(C {($ VSub_Name "$depmod_hack_needed")}) terminator:)] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:symlink) op: Equal rhs: { (DQ ($ VSub_Name "$INSTALL_MOD_PATH") (/lib/modules/99.98.) ($ VSub_Name "$KERNELRELEASE") ) } spids: [376] ) ] spids: [376] ) (C {(ln)} {(-s)} {(DQ ($ VSub_Name "$KERNELRELEASE"))} {(DQ ($ VSub_Name "$symlink"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KERNELRELEASE) op: Equal rhs: {(99.98.) ($ VSub_Name "$KERNELRELEASE")} spids: [397] ) ] spids: [397] ) ] spids: [-1 373] ) ] spids: [-1 401] ) (C {(set)} {(--)} {(-ae)} {(-F)} {(System.map)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-n)} {(DQ ($ VSub_Name "$INSTALL_MOD_PATH"))}) terminator: ) ] action: [ (C {(set)} {(--)} {(DQ ($ VSub_At "$@"))} {(-b)} {(DQ ($ VSub_Name "$INSTALL_MOD_PATH"))}) ] spids: [-1 425] ) ] spids: [-1 442] ) (C {(DQ ($ VSub_Name "$DEPMOD"))} {(DQ ($ VSub_At "$@"))} {(DQ ($ VSub_Name "$KERNELRELEASE"))} {($ VSub_Name "$SYMBOL_PREFIX")} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{($ VSub_QMark "$?")} spids:[458])] spids: [458] ) (If arms: [ (if_arm cond: [(Sentence child:(C {($ VSub_Name "$depmod_hack_needed")}) terminator:)] action: [(C {(rm)} {(-f)} {(DQ ($ VSub_Name "$symlink"))})] spids: [-1 467] ) ] spids: [-1 478] ) (C {(exit)} {($ VSub_Name "$ret")}) ] )