Advertisement
rockdrilla

chroot: force use specific GCC version

Jun 17th, 2015
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. divert_path() { echo $1.real; } ### customizable
  2.  
  3. divert() { dpkg-divert --divert $(divert_path $1) --rename $1; }
  4.  
  5. GNUHOST=$(dpkg-architecture -qDEB_HOST_GNU_TYPE)
  6.  
  7. VERSIONS=(4.6 4.7 4.8 4.9 5)
  8. USE_VERSION=5
  9.  
  10. BINPATH=/usr/bin
  11. BIN=(g++ gcc gcc-ar gcc-nm gcc-ranlib gcov gcov-tool)
  12. BIN_HACK=(g++ gcc)
  13.  
  14. for b in ${BIN[@]}; do
  15.     TARGETS=()
  16.  
  17.     TARGETS=(${TARGETS[@]} ${b})
  18.     for v in ${VERSIONS[@]}; do
  19.         TARGETS=(${TARGETS[@]} ${b}-${v})
  20.     done; unset v
  21.  
  22.     TARGETS=(${TARGETS[@]} ${GNUHOST}-${b})
  23.     for v in ${VERSIONS[@]}; do
  24.         TARGETS=(${TARGETS[@]} ${GNUHOST}-${b}-${v})
  25.     done; unset v
  26.  
  27.     for t in ${TARGETS[@]}; do
  28.         divert ${BINPATH}/${t}
  29.         test "$t" = "$b" && continue
  30.         ln -s ${b} ${BINPATH}/${t}
  31.     done; unset t
  32. done; unset b
  33.  
  34. for b in ${BIN[@]}; do
  35.     cat > ${BINPATH}/${b} <<EOF
  36. #!/bin/sh
  37. exec $(divert_path ${b}-${USE_VERSION}) "\$@"
  38. EOF
  39.     chmod 755 ${BINPATH}/${b}
  40. done; unset b
  41.  
  42. for bh in ${BIN_HACK[@]}; do
  43.     cat > ${BINPATH}/${bh} <<EOF
  44. #!/bin/sh
  45. exec $(divert_path ${bh}-${USE_VERSION}) "\$@" -march=native -mtune=native -Ofast
  46. EOF
  47.     chmod 755 ${BINPATH}/${bh}
  48. done; unset bh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement