build : Added support to build using sudo
[wilink8-wlan/build-utilites.git] / sudo_build_wl18xx.sh
1 ORG_FILENAME="build_wl18xx.sh"
2 SUDO_FILENAME="_build_with_sudo.sh"
3 cp $ORG_FILENAME $SUDO_FILENAME
5 MAKE_PREFIX="sudo PATH=\$PATH -E "
6 SUDO_PREFIX="sudo "
8 makeregex[1]="modules_install"
9 makeregex[2]="make install"
11 for i in {1..2}
12 do
13     #echo "Add 'sudo' for $i) ${makeregex[$i]}"
14     sed -i "/${makeregex[$i]}/s/^/${MAKE_PREFIX} /" ./$SUDO_FILENAME
15 done
17 sudoregex[1]="mkdir"
18 sudoregex[2]="tar "
19 sudoregex[3]="cp "
20 sudoregex[4]="chmod "
21 sudoregex[5]="rm "
23 for i in {1..5}
24 do
25     #echo "Add 'sudo' for $i) ${sudoregex[$i]}"
26     #sed -i "s/${sudoregex[$i]}/${SUDO_PREFIX} /" ./$SUDO_FILENAME
27         sed -i "s/\(${sudoregex[$i]}\)/${SUDO_PREFIX} \1/g" ./$SUDO_FILENAME
28 done
30 echo "Finished adding sudo to build script, Running..."
32 ./$SUDO_FILENAME $@