| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | ##########################################################################
|
|---|
| 4 | #
|
|---|
| 5 | # IMPORTANT: The binaryInstall.src file is a source file, NOT an
|
|---|
| 6 | # executable shell script!! Used to generate grass-MAJ.MIN.VER-ARCH-DD_MM_YYYY-install.sh by
|
|---|
| 7 | # make bindist
|
|---|
| 8 | #
|
|---|
| 9 | # GRASS binary package installation tool
|
|---|
| 10 | # platform independent
|
|---|
| 11 | #
|
|---|
| 12 | # 1999-2000, 2010 by Markus Neteler, and the GRASS development team
|
|---|
| 13 | #
|
|---|
| 14 | ##########################################################################
|
|---|
| 15 |
|
|---|
| 16 | # Set a zero size variable for testing if this file is a source file. Note
|
|---|
| 17 | # that the make bindist command will change this line to TEST_STR = executable
|
|---|
| 18 | # without the spaces surrounding the equal sign
|
|---|
| 19 | TEST_STR=
|
|---|
| 20 |
|
|---|
| 21 | # Use a text string for sed to recognize to insert the proper version
|
|---|
| 22 | NAME_VER=BIN_DIST_VERSION
|
|---|
| 23 | TAR_FILE_SIZE=SIZE_TAR_FILE
|
|---|
| 24 | ARCH=ARCHITECTURE
|
|---|
| 25 |
|
|---|
| 26 | GRASSPRG=GRASSPRG_NAME
|
|---|
| 27 |
|
|---|
| 28 | # Set the default BINDIR and DESTDIR directories
|
|---|
| 29 | BINDIR=/usr/local/bin
|
|---|
| 30 | DESTDIR=/usr/local/grass$NAME_VER
|
|---|
| 31 | UNINSTALL=grass${NAME_VER}uninstall.sh
|
|---|
| 32 |
|
|---|
| 33 | # Check if this is a source file or not
|
|---|
| 34 | if [ -z "$TEST_STR" ] ; then
|
|---|
| 35 | echo "This is a source script, not an executable script which can be run."
|
|---|
| 36 | exit
|
|---|
| 37 | fi
|
|---|
| 38 |
|
|---|
| 39 | # Check for first parameter:
|
|---|
| 40 | if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ] ; then
|
|---|
| 41 | echo "
|
|---|
| 42 |
|
|---|
| 43 | GRASS GIS $NAME_VER binary package installation tool
|
|---|
| 44 |
|
|---|
| 45 | Usage: grass-$NAME_VER-install.sh grass-$NAME_VER.tar.gz [dest_dir] [bin_dir]
|
|---|
| 46 |
|
|---|
| 47 | with:
|
|---|
| 48 | [dest_dir] - optional: FULL path name to the installation directory
|
|---|
| 49 | (default: /usr/local/grass$NAME_VER/)
|
|---|
| 50 | [bin_dir] - optional: FULL path name to the grass binary directory
|
|---|
| 51 | (default: /usr/local/bin/)
|
|---|
| 52 | Notes: 1) Only the grass executable file is stored here
|
|---|
| 53 | 2) If you want to change the binary directory only
|
|---|
| 54 | then you need to specify the destination
|
|---|
| 55 | directory as well
|
|---|
| 56 |
|
|---|
| 57 | You may need login as root for installation.
|
|---|
| 58 | "
|
|---|
| 59 | exit
|
|---|
| 60 | fi
|
|---|
| 61 |
|
|---|
| 62 | # Check for second parameter:
|
|---|
| 63 | if [ "$2" ] ; then
|
|---|
| 64 | DESTDIR=$2
|
|---|
| 65 | fi
|
|---|
| 66 |
|
|---|
| 67 | # Check for third parameter:
|
|---|
| 68 | if [ "$3" ] ; then
|
|---|
| 69 | BINDIR=$3
|
|---|
| 70 | fi
|
|---|
| 71 |
|
|---|
| 72 | # Print out script identification message
|
|---|
| 73 | echo ""
|
|---|
| 74 | echo "GRASS GIS $NAME_VER binary package installation tool"
|
|---|
| 75 | echo ""
|
|---|
| 76 |
|
|---|
| 77 | # Check for correct package name:
|
|---|
| 78 | if [ ! -f $1 ] ; then
|
|---|
| 79 | echo "ERROR: Wrong package name $1. File does not exists."
|
|---|
| 80 | echo ""
|
|---|
| 81 | exit
|
|---|
| 82 | fi
|
|---|
| 83 |
|
|---|
| 84 | # Obtain the package name and path
|
|---|
| 85 | CURR_DIR=`pwd`
|
|---|
| 86 | PACKAGE_NAME=`basename $1`
|
|---|
| 87 | PACKAGE_DIR=`dirname $1`
|
|---|
| 88 |
|
|---|
| 89 | # the dirname command uses . and .. if found so we need the absolute path
|
|---|
| 90 | cd $PACKAGE_DIR
|
|---|
| 91 | PACKAGE_DIR=`pwd`
|
|---|
| 92 |
|
|---|
| 93 | # Check if package is first parameter and in gz or bz2 compression:
|
|---|
| 94 | # is package in .tar.gz format?
|
|---|
| 95 | echo $PACKAGE_NAME | grep "\.tar\.gz" > /dev/null
|
|---|
| 96 | if [ $? -eq 0 ] ; then
|
|---|
| 97 | UNPACK=gunzip
|
|---|
| 98 |
|
|---|
| 99 | # Is gunzip there?
|
|---|
| 100 | IFSSAVE="$IFS"
|
|---|
| 101 | IFS=":"
|
|---|
| 102 | GUNZIP=""
|
|---|
| 103 | for TEST in $PATH ; do
|
|---|
| 104 | if [ -x $TEST/gunzip ] ; then
|
|---|
| 105 | GUNZIP="$TEST/gunzip"
|
|---|
| 106 | fi
|
|---|
| 107 | done
|
|---|
| 108 | # which gunzip | grep -v no > /dev/null
|
|---|
| 109 | IFS="$IFSSAVE"
|
|---|
| 110 | if [ ! "$GUNZIP" ] ; then
|
|---|
| 111 | echo "No gunzip installed. Please get from:"
|
|---|
| 112 | echo " http://www.gnu.org/software/gzip/gzip.html"
|
|---|
| 113 | exit
|
|---|
| 114 | fi
|
|---|
| 115 | else
|
|---|
| 116 | # not in .tar.gz format, perhaps in .tar.bz2 format?
|
|---|
| 117 | echo $PACKAGE_NAME | grep "\.tar\.bz2" > /dev/null
|
|---|
| 118 | if [ $? -eq 0 ] ; then
|
|---|
| 119 | UNPACK=bunzip2
|
|---|
| 120 |
|
|---|
| 121 | # Is bunzip2 there?
|
|---|
| 122 | IFSSAVE="$IFS"
|
|---|
| 123 | IFS=":"
|
|---|
| 124 | BUNZIP2=""
|
|---|
| 125 | for TEST in $PATH ; do
|
|---|
| 126 | if [ -x $TEST/bunzip2 ] ; then
|
|---|
| 127 | BUNZIP2="$TEST/bunzip2"
|
|---|
| 128 | fi
|
|---|
| 129 | done
|
|---|
| 130 | IFS="$IFSSAVE"
|
|---|
| 131 | # which bunzip2 | grep -v no > /dev/null
|
|---|
| 132 | if [ ! "$BUNZIP2" ] ; then
|
|---|
| 133 | echo "No bunzip2 installed. Please get from:"
|
|---|
| 134 | echo " http://sources.redhat.com/bzip2/index.html"
|
|---|
| 135 | exit
|
|---|
| 136 | fi
|
|---|
| 137 | else
|
|---|
| 138 | # not in .tar.gz or .tar.bz2 format, completely wrong!
|
|---|
| 139 | echo "ERROR: You need the GRASS binary package in .tar.gz compression "
|
|---|
| 140 | echo "or .tar.bz2."
|
|---|
| 141 | echo ""
|
|---|
| 142 | exit
|
|---|
| 143 | fi
|
|---|
| 144 | fi
|
|---|
| 145 |
|
|---|
| 146 | # Check if the size of the tar gzip file is the same as what was on the server
|
|---|
| 147 | SIZE=`ls -l $PACKAGE_NAME | tr -s " " | cut -d" " -f5`
|
|---|
| 148 | if [ $? -ne 0 ] ; then
|
|---|
| 149 | echo "ERROR while installing binaries!"
|
|---|
| 150 | echo "Exiting."
|
|---|
| 151 | exit
|
|---|
| 152 | fi
|
|---|
| 153 |
|
|---|
| 154 | if [ $SIZE -ne $TAR_FILE_SIZE ] ; then
|
|---|
| 155 | echo "ERROR: The size of the binary package is not correct."
|
|---|
| 156 | echo " Perhaps there was a transmission error. Please download"
|
|---|
| 157 | echo " the package again"
|
|---|
| 158 | echo ""
|
|---|
| 159 | exit
|
|---|
| 160 | fi
|
|---|
| 161 |
|
|---|
| 162 | echo "Using $UNPACK decompressor..."
|
|---|
| 163 |
|
|---|
| 164 | echo "The package $PACKAGE_NAME seems to be OK"
|
|---|
| 165 | echo "Proceeding..."
|
|---|
| 166 | echo ""
|
|---|
| 167 |
|
|---|
| 168 | # Check if the paths for the binary and the destination are the same
|
|---|
| 169 | BIN_PATH1=$BINDIR/grass-$NAME_VER
|
|---|
| 170 | BIN_PATH2=$BIN_PATH1/
|
|---|
| 171 |
|
|---|
| 172 | if [ $BIN_PATH1 = $DESTDIR -o $BIN_PATH2 = $DESTDIR ] ; then
|
|---|
| 173 | echo "ERROR:"
|
|---|
| 174 | echo "It appears that the destination directory path is the same as the"
|
|---|
| 175 | echo "path for the grass binary executable. This results in a name"
|
|---|
| 176 | echo "conflict between the destination directory and the executable."
|
|---|
| 177 | echo "Please run this script again with a different path name for the"
|
|---|
| 178 | echo "destination directory."
|
|---|
| 179 | exit
|
|---|
| 180 | fi
|
|---|
| 181 |
|
|---|
| 182 | # Check if BINDIR is a directory
|
|---|
| 183 | if [ ! -d "$BINDIR" ] ; then
|
|---|
| 184 |
|
|---|
| 185 | # Check if BINDIR is a file
|
|---|
| 186 | if [ -f "$BINDIR" ] ; then
|
|---|
| 187 | echo ""
|
|---|
| 188 | echo "ERROR: $BINDIR is a file not a directory."
|
|---|
| 189 | echo "Please specify a directory for the binary executable directory."
|
|---|
| 190 | exit
|
|---|
| 191 | fi
|
|---|
| 192 |
|
|---|
| 193 | mkdir -p $BINDIR
|
|---|
| 194 |
|
|---|
| 195 | if [ $? -ne 0 ] ; then
|
|---|
| 196 | echo "An error occurred trying to create $BINDIR ! Exiting."
|
|---|
| 197 | exit
|
|---|
| 198 | fi
|
|---|
| 199 | fi
|
|---|
| 200 |
|
|---|
| 201 | # Check if DESTDIR is appropriate
|
|---|
| 202 | echo "Checking and creating installation directory..."
|
|---|
| 203 |
|
|---|
| 204 | if [ ! -d "$DESTDIR" ] ; then
|
|---|
| 205 |
|
|---|
| 206 | # Check if a word "grass" is in string $DESTDIR
|
|---|
| 207 | echo $DESTDIR | grep "grass" > /dev/null
|
|---|
| 208 |
|
|---|
| 209 | if [ $? -eq 1 ] ; then
|
|---|
| 210 | echo "WARNING: Your destination path $DESTDIR does not contain the word 'grass'"
|
|---|
| 211 | echo "Continue (y/n)?"
|
|---|
| 212 | read ans
|
|---|
| 213 |
|
|---|
| 214 | if [ "$ans" = "n" -o "$ans" = "N" ] ; then
|
|---|
| 215 | exit
|
|---|
| 216 | fi
|
|---|
| 217 | fi
|
|---|
| 218 |
|
|---|
| 219 | # Check if DESTDIR is a file
|
|---|
| 220 | if [ -f "$DESTDIR" ] ; then
|
|---|
| 221 | echo ""
|
|---|
| 222 | echo "ERROR: $DESTDIR is a file not a directory."
|
|---|
| 223 | echo "Please specify a directory for the destination directory"
|
|---|
| 224 | exit
|
|---|
| 225 | fi
|
|---|
| 226 |
|
|---|
| 227 | mkdir -p $DESTDIR
|
|---|
| 228 |
|
|---|
| 229 | if [ $? -ne 0 ] ; then
|
|---|
| 230 | echo "An error occurred trying to create $DESTDIR! Exiting."
|
|---|
| 231 | exit
|
|---|
| 232 | fi
|
|---|
| 233 | else
|
|---|
| 234 | if [ -d $DESTDIR/bin ] ; then
|
|---|
| 235 | echo ""
|
|---|
| 236 | echo "ERROR: Old GRASS distribution existing in $DESTDIR!"
|
|---|
| 237 | echo "Remove first!"
|
|---|
| 238 | exit
|
|---|
| 239 | else
|
|---|
| 240 |
|
|---|
| 241 | # Check if a word "grass" is in string $DESTDIR
|
|---|
| 242 | echo $DESTDIR | grep "grass" > /dev/null
|
|---|
| 243 |
|
|---|
| 244 | if [ $? -eq 1 ] ; then
|
|---|
| 245 | echo "WARNING: Your destination path $DESTDIR does not contain the word 'grass'"
|
|---|
| 246 | echo "Continue (y/n)?"
|
|---|
| 247 | read ans
|
|---|
| 248 |
|
|---|
| 249 | if [ "$ans" = "n" -o "$ans" = "N" ] ; then
|
|---|
| 250 | exit
|
|---|
| 251 | fi
|
|---|
| 252 | fi
|
|---|
| 253 |
|
|---|
| 254 | # Check if DESTDIR is writable
|
|---|
| 255 | touch $DESTDIR/test$$ > /dev/null
|
|---|
| 256 | if [ $? -ne 0 ] ; then
|
|---|
| 257 | echo "ERROR: Destination directory $DESTDIR is not"
|
|---|
| 258 | echo "writable, try installing as root!"
|
|---|
| 259 | echo "Exiting."
|
|---|
| 260 | exit 1
|
|---|
| 261 | fi
|
|---|
| 262 | rm -f $DESTDIR/test$$ > /dev/null
|
|---|
| 263 |
|
|---|
| 264 | fi
|
|---|
| 265 | fi
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 | # Start the installation job...
|
|---|
| 269 | echo "Installing GRASS binaries into $DESTDIR"
|
|---|
| 270 | echo ""
|
|---|
| 271 |
|
|---|
| 272 | echo "Uncompressing the package and extracting to target directory..."
|
|---|
| 273 | PACK_FILE=`echo $PACKAGE_DIR/$PACKAGE_NAME | sed 's+^//+/+g'`
|
|---|
| 274 | cd $DESTDIR; $UNPACK -c $PACK_FILE | tar -xf -
|
|---|
| 275 | if [ $? -eq 1 ] ; then
|
|---|
| 276 | echo "An error occurred or user break while installing binaries! Exiting."
|
|---|
| 277 | exit
|
|---|
| 278 | fi
|
|---|
| 279 |
|
|---|
| 280 | # Get rid of any CVS directories
|
|---|
| 281 | find . -name CVS -exec rm -rf {} \; 2>/dev/null ; true
|
|---|
| 282 | cd $CURR_DIR
|
|---|
| 283 |
|
|---|
| 284 | # Creating start script
|
|---|
| 285 | echo "Creating start script:"
|
|---|
| 286 | echo "$BINDIR/$GRASSPRG -> $BINDIR/grass-$NAME_VER"
|
|---|
| 287 |
|
|---|
| 288 | sed -e "s#@GISBASE@#$DESTDIR#g" \
|
|---|
| 289 | $DESTDIR/$GRASSPRG.tmp > $BINDIR/grass-$NAME_VER
|
|---|
| 290 | if [ $? -eq 1 ] ; then
|
|---|
| 291 | echo "An error occurred trying to create the grass start script! Exiting."
|
|---|
| 292 | echo "You probably do not have permission to install into $BINDIR."
|
|---|
| 293 | echo "You may need to be the root user to install in that directory."
|
|---|
| 294 | exit
|
|---|
| 295 | fi
|
|---|
| 296 |
|
|---|
| 297 | ln -sf $BINDIR/grass-$NAME_VER $BINDIR/$GRASSPRG
|
|---|
| 298 | chmod ugo+x $BINDIR/grass-$NAME_VER
|
|---|
| 299 |
|
|---|
| 300 | if [ $? -eq 1 ] ; then
|
|---|
| 301 | echo "An error occurred trying to create the grass start script! Exiting."
|
|---|
| 302 | echo "You probably do not have permission to install into $BINDIR."
|
|---|
| 303 | echo "You may need to be the root user to install in that directory."
|
|---|
| 304 | exit
|
|---|
| 305 | fi
|
|---|
| 306 |
|
|---|
| 307 | echo "Creating the locks directory for monitors..."
|
|---|
| 308 | SERVERNAME=`uname -n | sed -e "s/\..*//"`
|
|---|
| 309 |
|
|---|
| 310 | if [ ! -d $DESTDIR/locks ] ; then
|
|---|
| 311 | mkdir $DESTDIR/locks
|
|---|
| 312 | fi
|
|---|
| 313 |
|
|---|
| 314 | rm -rf $DESTDIR/locks/*
|
|---|
| 315 | mkdir $DESTDIR/locks/$SERVERNAME
|
|---|
| 316 | chmod -R 1777 $DESTDIR/locks
|
|---|
| 317 |
|
|---|
| 318 | echo""
|
|---|
| 319 |
|
|---|
| 320 | echo "Generating display font configuration file..."
|
|---|
| 321 |
|
|---|
| 322 | GISBASE="$DESTDIR" GISRC=junk LD_LIBRARY_PATH_VAR="${DESTDIR}/lib:$LD_LIBRARY_PATH_VAR" "${DESTDIR}/bin/g.mkfontcap" -o
|
|---|
| 323 |
|
|---|
| 324 | echo""
|
|---|
| 325 |
|
|---|
| 326 | # fix include/Make/Platform.make file for g.extension
|
|---|
| 327 | mv ${DESTDIR}/include/Make/Platform.make ${DESTDIR}/include/Make/Platform.make.orig
|
|---|
| 328 | cat ${DESTDIR}/include/Make/Platform.make.orig | \
|
|---|
| 329 | sed "s+prefix = /usr/local+prefix = $DESTDIR+g" | \
|
|---|
| 330 | sed "s+INST_DIR = $prefix/grass-$NAME_VER+INST_DIR = $prefix+g" | \
|
|---|
| 331 | sed "s+^.*GRASS_HOME.*$+GRASS_HOME = $DESTDIR+" | \
|
|---|
| 332 | sed "s+^.*RUN_GISBASE.*$+RUN_GISBASE = $DESTDIR+" | \
|
|---|
| 333 | sed "s+^.*RUN_GISRC.*$+RUN_GISRC = +" > ${DESTDIR}/include/Make/Platform.make
|
|---|
| 334 |
|
|---|
| 335 | # rm -f ${DESTDIR}/include/Make/Platform.make.orig
|
|---|
| 336 |
|
|---|
| 337 | # Print out some messages
|
|---|
| 338 | echo "Installation finished. Start GRASS $NAME_VER with"
|
|---|
| 339 | echo " $BINDIR/grass-$NAME_VER"
|
|---|
| 340 | echo ""
|
|---|
| 341 | #echo "The graphical user interface can be started within GRASS GIS."
|
|---|
| 342 | #echo ""
|
|---|
| 343 | #echo "You can uninstall grass by typing"
|
|---|
| 344 | #echo " sh $UNINSTALL"
|
|---|
| 345 | #echo "in the directory $BINDIR"
|
|---|
| 346 | echo ""
|
|---|
| 347 | echo "Welcome to GRASS GIS. Enjoy this open source GRASS GIS!"
|
|---|
| 348 | echo ""
|
|---|