source: grass/trunk/binaryInstall.src

Last change on this file was 74182, checked in by neteler, 5 years ago

binaryInstall.src: nad2bin no longer used (completes r74179)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id
  • Property svn:mime-type set to text/plain
File size: 9.8 KB
Line 
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
19TEST_STR=
20
21# Use a text string for sed to recognize to insert the proper version
22NAME_VER=BIN_DIST_VERSION
23TAR_FILE_SIZE=SIZE_TAR_FILE
24ARCH=ARCHITECTURE
25
26GRASSPRG=GRASSPRG_NAME
27
28# Set the default BINDIR and DESTDIR directories
29BINDIR=/usr/local/bin
30DESTDIR=/usr/local/grass$NAME_VER
31UNINSTALL=grass${NAME_VER}uninstall.sh
32
33# Check if this is a source file or not
34if [ -z "$TEST_STR" ] ; then
35 echo "This is a source script, not an executable script which can be run."
36 exit
37fi
38
39# Check for first parameter:
40if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ] ; then
41 echo "
42
43GRASS GIS $NAME_VER binary package installation tool
44
45Usage: 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
57You may need login as root for installation.
58"
59 exit
60fi
61
62# Check for second parameter:
63if [ "$2" ] ; then
64 DESTDIR=$2
65fi
66
67# Check for third parameter:
68if [ "$3" ] ; then
69 BINDIR=$3
70fi
71
72# Print out script identification message
73echo ""
74echo "GRASS GIS $NAME_VER binary package installation tool"
75echo ""
76
77# Check for correct package name:
78if [ ! -f $1 ] ; then
79 echo "ERROR: Wrong package name $1. File does not exists."
80 echo ""
81 exit
82fi
83
84# Obtain the package name and path
85CURR_DIR=`pwd`
86PACKAGE_NAME=`basename $1`
87PACKAGE_DIR=`dirname $1`
88
89# the dirname command uses . and .. if found so we need the absolute path
90cd $PACKAGE_DIR
91PACKAGE_DIR=`pwd`
92
93# Check if package is first parameter and in gz or bz2 compression:
94# is package in .tar.gz format?
95echo $PACKAGE_NAME | grep "\.tar\.gz" > /dev/null
96if [ $? -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
115else
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
144fi
145
146# Check if the size of the tar gzip file is the same as what was on the server
147SIZE=`ls -l $PACKAGE_NAME | tr -s " " | cut -d" " -f5`
148if [ $? -ne 0 ] ; then
149 echo "ERROR while installing binaries!"
150 echo "Exiting."
151 exit
152fi
153
154if [ $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
160fi
161
162echo "Using $UNPACK decompressor..."
163
164echo "The package $PACKAGE_NAME seems to be OK"
165echo "Proceeding..."
166echo ""
167
168# Check if the paths for the binary and the destination are the same
169BIN_PATH1=$BINDIR/grass-$NAME_VER
170BIN_PATH2=$BIN_PATH1/
171
172if [ $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
180fi
181
182# Check if BINDIR is a directory
183if [ ! -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
199fi
200
201# Check if DESTDIR is appropriate
202echo "Checking and creating installation directory..."
203
204if [ ! -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
233else
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
265fi
266
267
268# Start the installation job...
269echo "Installing GRASS binaries into $DESTDIR"
270echo ""
271
272echo "Uncompressing the package and extracting to target directory..."
273PACK_FILE=`echo $PACKAGE_DIR/$PACKAGE_NAME | sed 's+^//+/+g'`
274cd $DESTDIR; $UNPACK -c $PACK_FILE | tar -xf -
275if [ $? -eq 1 ] ; then
276 echo "An error occurred or user break while installing binaries! Exiting."
277 exit
278fi
279
280# Get rid of any CVS directories
281find . -name CVS -exec rm -rf {} \; 2>/dev/null ; true
282cd $CURR_DIR
283
284# Creating start script
285echo "Creating start script:"
286echo "$BINDIR/$GRASSPRG -> $BINDIR/grass-$NAME_VER"
287
288sed -e "s#@GISBASE@#$DESTDIR#g" \
289 $DESTDIR/$GRASSPRG.tmp > $BINDIR/grass-$NAME_VER
290if [ $? -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
295fi
296
297ln -sf $BINDIR/grass-$NAME_VER $BINDIR/$GRASSPRG
298chmod ugo+x $BINDIR/grass-$NAME_VER
299
300if [ $? -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
305fi
306
307echo "Creating the locks directory for monitors..."
308SERVERNAME=`uname -n | sed -e "s/\..*//"`
309
310if [ ! -d $DESTDIR/locks ] ; then
311 mkdir $DESTDIR/locks
312fi
313
314rm -rf $DESTDIR/locks/*
315mkdir $DESTDIR/locks/$SERVERNAME
316chmod -R 1777 $DESTDIR/locks
317
318echo""
319
320echo "Generating display font configuration file..."
321
322GISBASE="$DESTDIR" GISRC=junk LD_LIBRARY_PATH_VAR="${DESTDIR}/lib:$LD_LIBRARY_PATH_VAR" "${DESTDIR}/bin/g.mkfontcap" -o
323
324echo""
325
326# fix include/Make/Platform.make file for g.extension
327mv ${DESTDIR}/include/Make/Platform.make ${DESTDIR}/include/Make/Platform.make.orig
328cat ${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
338echo "Installation finished. Start GRASS $NAME_VER with"
339echo " $BINDIR/grass-$NAME_VER"
340echo ""
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"
346echo ""
347echo "Welcome to GRASS GIS. Enjoy this open source GRASS GIS!"
348echo ""
Note: See TracBrowser for help on using the repository browser.