Install.sh 3.9 KB

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