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