install_raptor.sh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #!/bin/bash
  2. # raptor script
  3. # install sbsv2
  4. # parse command line options
  5. # -s indicates silent (non-interactive operation); the dialog utility is not used in this mode and
  6. # the -i option is required; if the -i is missing, the script exits
  7. # -i specifies the installation directory; this is ignored in non-silent mode
  8. # SILENT is the empty string
  9. export SILENT=""
  10. export SYMBIANHOME=/opt/symbian
  11. while getopts si: VARNAME; do
  12. case $VARNAME in
  13. s)
  14. export SILENT=1
  15. echo "install_raptor.sh: operating in silent mode"
  16. ;;
  17. i)
  18. export INSTALL_DIR=$OPTARG
  19. echo "install_raptor.sh: given installation directory is $INSTALL_DIR"
  20. ;;
  21. esac
  22. done
  23. # exit if no installation directory is given in silent mode
  24. if [[ $SILENT ]]; then
  25. if [[ -z $INSTALL_DIR ]]; then
  26. echo "install_raptor.sh: error: no installation directory specified. Unable to continue. Exiting."
  27. exit 1
  28. else
  29. echo "install_raptor.sh: using installation directory $INSTALL_DIR"
  30. fi
  31. else
  32. if [[ ! -z $INSTALL_DIR ]]; then
  33. echo "install_raptor.sh: remark: installation directory, $INSTALL_DIR, specified in interactive mode. Ignoring."
  34. fi
  35. fi
  36. chmod a+x "${PWD}/bin/gethost.sh"
  37. export HOSTPLATFORM=$("$PWD/bin/gethost.sh")
  38. export HOSTPLATFORM_DIR=$("$PWD/bin/gethost.sh" -d)
  39. export build_utils=no
  40. if [[ ! -d "$PWD/$HOSTPLATFORM_DIR" ]]; then
  41. cat << MSG
  42. The Raptor installer has determined that this computer is running:
  43. $HOSTPLATFORM_DIR
  44. This platform is not directly supported by the installer.
  45. If you proceed then the installation will attempt to build the Raptor tools for your platform.
  46. Your system must have some tools installed:
  47. MSG
  48. if [ "$(which gcc)" ]; then
  49. echo "You appear to have gcc"
  50. else
  51. echo "You DON'T appear to have gcc - please install it"
  52. fi
  53. if [ "$(which g++)" ]; then
  54. echo "You appear to have gcc-c++"
  55. else
  56. echo "You DON'T appear to have gcc-c++ (also called g++) - please install it"
  57. fi
  58. if [ "$(which make)" ]; then
  59. echo "You appear to have GNU make"
  60. else
  61. echo "You DON'T appear to have GNU make - please install it (version 3.81)"
  62. fi
  63. if [ "$(which bison)" ]; then
  64. echo "You appear to have GNU bison"
  65. else
  66. echo "You DON'T appear to have GNU bison - please install it "
  67. fi
  68. if [ -f "/usr/include/ncurses.h" ]; then
  69. echo "You appear to have the ncurses dev libraries"
  70. else
  71. echo "You DON'T appear to have the ncurses dev libraries - please install them (ncurses-dev or ncurses-devel)"
  72. fi
  73. if [ -f "/usr/include/bzlib.h" ]; then
  74. echo "You appear to have the bzip2 dev libraries"
  75. else
  76. echo "You DON'T appear to have the bzip2 dev libraries - please install them (bzip2-dev or bzip2-devel)"
  77. fi
  78. echo "Do you wish to continue (Y or y for 'yes' anything else for no)?"
  79. read X
  80. if [[ "$X" != "y" && "$X" != "Y" ]]; then
  81. exit 1
  82. else
  83. build_utils=yes
  84. fi
  85. # Build the dialog utility so that we can get started
  86. if [[ ! $SILENT ]]; then
  87. (export SBS_HOME=$PWD;cd "$SBS_HOME/util" && echo "Building dialog utility..." && (make -k -j2 dialog> dialog_util_build.log 2>&1 && echo -e "\nBuild Complete") || (echo "Dialog utility build failed, see $PWD/dialog_util_build.log for more details"; read X; exit 1)) || exit 1
  88. fi
  89. fi
  90. export DIALOG="$PWD/$HOSTPLATFORM_DIR/bin/dialog"
  91. chmod a+x "$DIALOG"
  92. test -w "$SYMBIANHOME"
  93. if [[ $? -ne 0 ]]; then
  94. SYMBIANHOME=$(echo ~)
  95. fi
  96. export TMPSBSDIR="$PWD"
  97. errorexit() {
  98. echo -e "\nRaptor installation aborted: $1" 1>&2
  99. echo -e "\nInstall tmp dir is $TMPSBSDIR" 1>&2
  100. exit 1
  101. }
  102. # get FULLVERSION and VERSION from .version file
  103. export FULLVERSION=""
  104. export VERSION=""
  105. eval $(cat .version)
  106. if [[ "$FULLVERSION" == "" || "$VERSION" == "" ]]; then
  107. errorexit "Bad install package - no version found."
  108. fi
  109. export RESPONSEFILE=$PWD/.installdir
  110. export MANIFEST=$PWD/.manifest
  111. export SBS_HOME=$SYMBIANHOME/raptor-$(echo "$VERSION" | sed 's#\.##g')
  112. if [[ ! $SILENT ]]; then
  113. DIALOGVER=$($DIALOG --version)
  114. if ! expr match "$DIALOGVER" "Version:" 2>&1 >/dev/null; then
  115. errorexit "Could not run the installation user interface on this version of Linux.\nPlease install the compat-glibc and compat-ncurses packages (RedHat) or the equivalent for your distribution and then try again.\n\nYou may also simply 'untar' raptor using the ' --target NewDirectory --noexec' options to this installer.\n"
  116. fi
  117. export DIALOGSBS=$DIALOG "--backtitle 'Installing $FULLVERSION'"
  118. $DIALOGSBS --msgbox "Symbian Build System Installer\n\n$FULLVERSION" 0 0
  119. # check what SBS_HOME
  120. $DIALOGSBS --title "Select Symbian Home Directory" --fselect "$SBS_HOME" 10 50 2> "$RESPONSEFILE"
  121. SBS_HOME=$(cat "$RESPONSEFILE")
  122. else
  123. SBS_HOME=$INSTALL_DIR
  124. fi
  125. if [[ ! -d "$SBS_HOME" ]]; then
  126. if [[ ! $SILENT ]]; then
  127. $DIALOGSBS --yesno "$SBS_HOME does not exist - should it be created?" 0 0; YESNO=$?
  128. else
  129. # always make the directory in silent mode
  130. YESNO=0
  131. fi
  132. if [[ "$YESNO" -eq 0 ]]; then
  133. mkdir -p "$SBS_HOME" ||
  134. (
  135. errorexit "Could not create directory $SBS_HOME"
  136. )
  137. else
  138. errorexit "SBSv2 Installation aborted: User chose not to create installation directory $SBS_HOME"
  139. fi
  140. else
  141. # check if there's a previous install and give an option to stop in interactive mode
  142. if [[ ! $SILENT ]]; then
  143. $DIALOGSBS --defaultno --yesno "$SBS_HOME already exists - should the installation be overwritten?" 0 0; YESNO=$?
  144. else
  145. # always abort in silent mode
  146. YESNO=1
  147. fi
  148. if [[ "$YESNO" -eq 1 ]]; then
  149. errorexit "Not replacing existing installation."
  150. fi
  151. fi
  152. # Install the software
  153. if [[ ! $SILENT ]]; then
  154. echo "" >"$MANIFEST"
  155. (tar -cf - *) | (cd $SBS_HOME && tar -xvf - > "$MANIFEST" && echo -e "\nCopying complete - press RETURN" >> "$MANIFEST") &
  156. (
  157. $DIALOGSBS --title "Copying SBS files" --tailbox "$MANIFEST" 20 60
  158. )
  159. else
  160. (tar -cf - *) | (cd $SBS_HOME && tar -xvf - && echo -e "\nCopying complete")
  161. fi
  162. dobuildutils() {
  163. cd "$SBS_HOME/util" && echo "Building utilities ..." && make -k -j2
  164. if [[ $? -eq 0 ]]; then
  165. echo -e "\nBuild Complete"
  166. else
  167. echo -e "\nUtility build failed, see $BUILDLOG for more details"
  168. exit 1
  169. fi
  170. }
  171. # Build the utilities if needed
  172. if [[ "$build_utils" == "yes" ]]; then
  173. BUILDLOG=$SBS_HOME/util/util_build.log
  174. if [[ ! $SILENT ]]; then
  175. ( dobuildutils ) > "$BUILDLOG" 2>&1 & (
  176. $DIALOGSBS --title "Building utilities for $HOSTPLATFORM_DIR" --tailbox "$BUILDLOG" 20 60
  177. )
  178. else
  179. ( dobuildutils 2&>1 ) | tee "$BUILDLOG"
  180. fi
  181. fi
  182. # Force sbs to be executable:
  183. chmod a+x "${SBS_HOME}/bin/sbs"
  184. chmod a+x "${SBS_HOME}/bin/gethost.sh"
  185. chmod a+x "${SBS_HOME}/bin/setup_user.sh"
  186. chmod -R a+r "${SBS_HOME}"
  187. chmod a+x "${SBS_HOME}/$HOSTPLATFORM_DIR/bin/"*
  188. chmod a+x "${SBS_HOME}/$HOSTPLATFORM_DIR/bv/bin/"*
  189. chmod a+x "${SBS_HOME}/$HOSTPLATFORM_DIR/bv/libexec/"*/*/*
  190. # Prepare user scripts for bashrc and bash_profile
  191. INSTALLER="${SBS_HOME}/util/install-linux"
  192. sed "s#__SBS_HOME__#${SBS_HOME}#" < "${INSTALLER}/linux_bash_profile" > "${SBS_HOME}/bin/user.bash_profile"
  193. sed "s#__SBS_HOME__#${SBS_HOME}#" < "${INSTALLER}/linux_bashrc" > "${SBS_HOME}/bin/user.bashrc"
  194. # Set symbolic link
  195. if [[ -L "$SYMBIANHOME/raptor" ]]; then
  196. rm "$SYMBIANHOME/raptor"
  197. fi
  198. if [[ ! -e "$SYMBIANHOME/raptor" ]]; then
  199. ln -s "$SBS_HOME" "$SYMBIANHOME/raptor"
  200. fi
  201. if [[ ! $SILENT ]]; then
  202. $DIALOGSBS --msgbox "Raptor $VERSION\ninstallation complete" 0 0
  203. else
  204. echo "Raptor $VERSION installation complete"
  205. fi