Install.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. # Install.sh - GCC4TI binary installation wizard
  3. #
  4. # Copyright (C) 2004-2005 Kevin Kofler
  5. # Copyright (C) 2009 Lionel Debroux
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2, or (at your option)
  10. # any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software Foundation,
  19. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. # Try to find a suitable dialog program
  21. if [ -z "$DIALOG" ]
  22. then xdpyinfo >/dev/null 2>/dev/null && { type kdialog >/dev/null 2>/dev/null && export DIALOG=kdialog || { type xdialog >/dev/null 2>/dev/null && export DIALOG=xdialog || { type gdialog >/dev/null 2>/dev/null && export DIALOG=gdialog || { type cdialog >/dev/null 2>/dev/null && export DIALOG=cdialog || { type dialog >/dev/null 2>/dev/null && export DIALOG=dialog || { export DIALOG=none; }; }; }; }; }; } || { type cdialog >/dev/null 2>/dev/null && export DIALOG=cdialog || { type dialog >/dev/null 2>/dev/null && export DIALOG=dialog || { export DIALOG=none; }; }; }
  23. fi
  24. # If we don't have a dialog program, present a simple bash interface
  25. if [ "$DIALOG" = none ]
  26. then
  27. echo "GCC4TI Installation Wizard"
  28. if [ -z "$TIGCC" ]
  29. then TIGCC="/usr/local/share/gcc4ti"
  30. fi
  31. echo -n "Destination directory ($TIGCC): "
  32. read TIGCCnew
  33. if [ ! -z "$TIGCCnew" ]
  34. then TIGCC="$TIGCCnew"
  35. fi
  36. export TIGCC
  37. # Get current PWD.
  38. PWDSAVE="`pwd`"
  39. # Unpack the binaries to the destination directory
  40. mkdir $TIGCC
  41. cd $TIGCC
  42. tar -x -j --no-same-owner --same-permissions -f "$PWDSAVE/gcc4ti_bin.tar.bz2"
  43. # Now offer to install environment variables
  44. echo -n "Add environment settings (\$TIGCC, \$PATH) to bashrc [Y/n]? "
  45. read -n 1 AddEnvSettings
  46. echo
  47. if [ -z "$AddEnvSettings" -o "$AddEnvSettings" = y -o "$AddEnvSettings" = Y ]
  48. then { $TIGCC/bin/envreg; echo "Done. You must restart bash for the new environment settings to take effect."; exit 0; }
  49. fi
  50. echo "Done. Make sure you set \$TIGCC to \"$TIGCC\" and add \$TIGCC/bin to your \$PATH before using GCC4TI."
  51. exit 0
  52. fi
  53. # cdialog and xdialog output to stderr by default.
  54. if [ "$DIALOG" = dialog -o "$DIALOG" = cdialog -o "$DIALOG" = xdialog ]
  55. then DIALOG="$DIALOG --stdout"
  56. fi
  57. # Now this is stupid. dialog REQUIRES size parameters (which can be "0 0" for
  58. # auto-sizing). kdialog does NOT like them.
  59. if [ "$DIALOG" = kdialog ]
  60. then DLGSIZE=""
  61. else DLGSIZE="0 0"
  62. fi
  63. # Now this is just as stupid. Zenity's gdialog script does NOT allow --,
  64. # everything else REQUIRES it for strings starting with a dash. It is also
  65. # broken with respect to escaping.
  66. if [ -z "`$DIALOG --version | grep zenity`" ]
  67. then DASHDASH="--";BACKSLASH=""
  68. else DASHDASH="";BACKSLASH="\\"
  69. fi
  70. if [ -z "$TIGCC" ]
  71. then TIGCC="/usr/local/share/gcc4ti"
  72. fi
  73. TIGCC="`$DIALOG --title "GCC4TI Installation Wizard" --inputbox "Destination directory:" $DLGSIZE $DASHDASH "$TIGCC"`"
  74. if [ $? != 0 ]
  75. then { echo Install.sh: Canceled by user; exit 1; }
  76. fi
  77. export TIGCC
  78. # Get current PWD.
  79. PWDSAVE="`pwd`"
  80. # Unpack the binaries to the destination directory
  81. mkdir $TIGCC
  82. cd $TIGCC
  83. tar -x -j --no-same-owner --same-permissions -f "$PWDSAVE/tigcc_bin.tar.bz2"
  84. # Now offer to install environment variables
  85. $DIALOG --title "GCC4TI Installation Wizard" --yesno "Add environment settings ($BACKSLASH\$TIGCC, $BACKSLASH\$PATH) to bashrc?" $DLGSIZE && { $TIGCC/bin/envreg; $DIALOG --title "GCC4TI Installation Wizard" --msgbox "Done. You must restart bash for the new environment settings to take effect." $DLGSIZE; exit 0; }
  86. $DIALOG --title "GCC4TI Installation Wizard" --msgbox "Done. Make sure you set $BACKSLASH\$TIGCC to $BACKSLASH\"$TIGCC$BACKSLASH\" and add $BACKSLASH\$TIGCC/bin to your $BACKSLASH\$PATH before using GCC4TI." $DLGSIZE