File: install-sh

package info (click to toggle)
nosql 3.1-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,448 kB
  • ctags: 267
  • sloc: cpp: 1,028; ansic: 915; awk: 732; perl: 502; tcl: 292; sh: 289; makefile: 44
file content (367 lines) | stat: -rwxr-xr-x 8,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/bin/sh

# *********************************************************************
#  Written by and copyright Carlo Strozzi <carlos@linux.it>.
#
#  install-sh: NoSQL installation script.
#  Copyright (C) 1998-2001 Carlo Strozzi <carlos@linux.it>
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
# 
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# *********************************************************************
# install NoSQL scripts, programs and datafiles
#
# Author: Carlos Strozzi <carlos@linux.it>
#
# To install to a target directory other than the default /usr/local/
# use the following command-line string:
#
#         PREFIX=/some/target/dir ./install-sh
#
# *********************************************************************

# $Id$

####################### User configurable stuff #######################

CFLAGS='-g -O2 -Wall'

#################### End of user configurable stuff ###################

VERSION=3.1
DOCSTUFF='ACKNOWLEDGEMENTS AUTHORS COPYING ChangeLog README* TODO INSTALL'
#LIBSTUFF='nosql.lsm nosqldb.dtd'
LIBSTUFF=nosql.lsm

# Try and work-out this Unix name.
UNAME=`uname -s`

# Default compiler stuff. Pick gcc if possible.

CC=`which gcc`

if [ X$CC = X ]
then
   CC=cc
   CFLAGS='-g -O2 -Wall'
fi

case $UNAME in
   Linux*)
      CC=gcc
      CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-declarations -Wnested-externs"
      CDEFS="$CDEFS -DHAVE_CRYPT_H"
   ;;
esac

# Set the default installation path prefix if not specified in env.

if [ X$PREFIX = X ]
then
   PREFIX=/usr/local
   export PREFIX
fi
PREFIX=$PREFIX/nosql
BINDIR=${BINDIR:-$PREFIX/bin}
DOCDIR=${DOCDIR:-$PREFIX/doc}
LIBDIR=${LIBDIR:-$PREFIX/lib}
HELPDIR=${HELPDIR:-$PREFIX/help}
export BINDIR DOCDIR LIBDIR HELPDIR

# Get a sane test(1). Not all shells provide a standard builtin one.
TEST=`which test`

if [ X$TEST = X ]
then
   echo "$0: unable to find test(1)" >&2
   exit 1
fi

# Look for required printf(1).
PRINTF=`which printf`

if [ X$PRINTF = X ]
then
   echo "$0: unable to find printf(1)" >&2
   exit 1
fi

# Get a pager program.
PAGER=`which less`

[ X$PAGER = X ] && PAGER=more

# Show Licensing Terms and Conditions.

cat <<EOF

	NoSQL DBMS, Copyright (C) 1998-2001 by Carlo Strozzi

To install this software you are requested to accept the Terms and
Conditions under which the software itself is distributed. Please
EOF
$PRINTF 'press ENTER to display the licensing document, or CTRL-C to quit: '

read ANSWER

if $TEST -e t-and-c.txt
then :
else
   echo "$0: unable to find the licensing document" >&2
   exit 1
fi

cat t-and-c.txt | $PAGER

echo ''
$PRINTF 'Do you accept the above Terms and Conditions ? (yes/no): '
read ANSWER OTHER

ANSWER=`echo "$ANSWER" | tr A-Z a-z`

case "$ANSWER" in
     y|yes)	   ;;
     *)	    exit 1 ;;
esac

# Try and be portable with respect to standard i/o streams.
STDIN=/dev/fd/0
STDOUT=/dev/fd/1
STDERR=/dev/fd/2

if $TEST -e /dev/stdin
then
   STDIN=/dev/stdin
fi

if $TEST -e /dev/stdout
then
   STDOUT=/dev/stdout
fi

if $TEST -e /dev/stderr
then
   STDERR=/dev/stderr
fi

# Look for required lockfile(1).
LOCKFILE=`which lockfile`
if [ X$LOCKFILE = X ]
then
   echo "$0: unable to find lockfile(1) in \$PATH" >&2
   echo "$0: please make sure the procmail package is installed" >&2
   exit 1
fi

# Look for required mktemp(1).
MKTEMP=`which mktemp`
if [ X$MKTEMP = X ]
then
   echo "$0: unable to find mktemp(1) in \$PATH" >&2
   exit 1
fi

# Look for required Metamail.
METAMAIL=`which mimencode`
if [ X$METAMAIL = X ]
then
   echo "$0: unable to find mimencode(1) in \$PATH" >&2
   echo "$0: please make sure the Metamail package is installed" >&2
   exit 1
fi

# Look for recommended ash(1)
SH=`which ash`
if [ X$SH = X ]
then
   # No ash(1). Is ksh(1) available maybe ?
   SH=`which ksh`
   if [ X$SH = X ]
   then
      # Nope. Try with bash(1)
      SH=`which bash`
      if [ X$SH = X ]
      then
	 # We're out of luck, let's settle to sh(1).
   	 SH=/bin/sh
      fi
   fi
fi
SH="#!$SH"

# Look for required mawk(1)
MAWK=`which mawk`
if [ X$MAWK = X ]
then
   echo "$0: unable to find mawk(1) in \$PATH" >&2
   exit 1
fi
MAWK="#!$MAWK -We"

# Look for required perl(1)
PERL=`which perl`
if [ X$PERL = X ]
then
   echo "$0: unable to find perl(1) in \$PATH" >&2
   exit 1
fi
PERL="#!$PERL"

# Create target directories. Not all mkdir(1) support the '-p' flag.

echo "$0: creating $PREFIX ..." >&2
mkdir $DESTDIR$PREFIX 2>/dev/null

if $TEST -d $DESTDIR$PREFIX
then :
else
   echo "$0: unable to create target directory '$DESTDIR$PREFIX'" >&2
   exit 1
fi

echo "$0: creating $DESTDIR$PREFIX ..." >&2
mkdir $DESTDIR$PREFIX 2>/dev/null

if $TEST -d $DESTDIR$PREFIX
then :
else
   echo "$0: unable to create target directory '$DESTDIR$PREFIX'" >&2
   exit 1
fi

#cd $DESTDIR$PREFIX
#if [ $? -ne 0 ]
#   echo "$0: unable to 'cd' into '$DESTDIR$PREFIX'" >&2
#   exit 1
#fi

echo "$0: creating subdirs in $DESTDIR$PREFIX ..." >&2
mkdir $DESTDIR$BINDIR $DESTDIR$LIBDIR \
      $DESTDIR$DOCDIR $DESTDIR$HELPDIR 2>/dev/null

if $TEST -d $DESTDIR$BINDIR
then :
else
   echo "$0: unable to create target directories under '$DESTDIR$PREFIX'" >&2
   exit 1
fi

# Copy sh(1) files.
echo "$0: copying sh(1) files ..." >&2
for i in sh/*
do
   j=`basename $i`
   awk 'NR==1 {print "'"$SH"'"; next} {print}' $i |
   sed -e 's,@DOCPATH@,'$HELPDIR',g' \
       -e 's,@STDIN@,'$STDIN',g' \
       -e 's,@STDOUT@,'$STDOUT',g' \
       -e 's,@STDERR@,'$STDERR',g' > $DESTDIR$BINDIR/$j.$$
   mv $DESTDIR$BINDIR/$j.$$ $DESTDIR$BINDIR/$j
   chmod 755 $DESTDIR$BINDIR/$j
done

# Copy mawk(1) files.
echo "$0: copying mawk(1) files ..." >&2
for i in mawk/*
do
   j=`basename $i`
   awk 'NR==1 {print "'"$MAWK"'"; next} {print}' $i |
   sed -e 's,@DOCPATH@,'$HELPDIR',g' \
       -e 's,@STDIN@,'$STDIN',g' \
       -e 's,@STDOUT@,'$STDOUT',g' \
       -e 's,@STDERR@,'$STDERR',g' > $DESTDIR$BINDIR/$j.$$
   mv $DESTDIR$BINDIR/$j.$$ $DESTDIR$BINDIR/$j
   chmod 755 $DESTDIR$BINDIR/$j
done

# Set up compatibility symlinks.
rm -f $DESTDIR$BINDIR/project \
      $DESTDIR$BINDIR/select \
      $DESTDIR$BINDIR/justify
(cd $DESTDIR
 ln -s $BINDIR/column $BINDIR/project
 ln -s $BINDIR/row $BINDIR/select
 ln -s $BINDIR/prtable $BINDIR/justify
)

# Copy perl(1) files.
echo "$0: copying perl(1) files ..." >&2
for i in perl/*
do
   j=`basename $i`
   awk 'NR==1 {print "'"$PERL"'"; next} {print}' $i |
   sed 's,@DOCPATH@,'$HELPDIR',g' > $DESTDIR$BINDIR/$j.$$
   mv $DESTDIR$BINDIR/$j.$$ $DESTDIR$BINDIR/$j
   chmod 755 $DESTDIR$BINDIR/$j
done

# Copy documentation files.
echo "$0: copying documentation files ..." >&2
if cp doc/* $DESTDIR$DOCDIR
then :
else
   echo "$0: unable to copy documentation files to '$DESTDIR$DOCDIR'" >&2
   exit 1
fi

# Copy help files.
echo "$0: copying help files ..." >&2
for i in help/*
do
   j=`basename $i`
   sed 's,@DOCPATH@,'$HELPDIR',g' $i > $DESTDIR$HELPDIR/$j.$$
   mv $DESTDIR$HELPDIR/$j.$$ $DESTDIR$HELPDIR/$j
done

# Copy misc. library stuff.
echo "$0: copying extra library stuff ..." >&2
if cp $LIBSTUFF $DESTDIR$LIBDIR
then :
else
   echo "$0: unable to copy misc. library stuff to '$DESTDIR$LIBDIR'" >&2
   exit 1
fi

# Copy extra documentation stuff.
echo "$0: copying extra documentation stuff ..." >&2
if cp $DOCSTUFF $DESTDIR$DOCDIR
then :
else
   echo "$0: unable to copy misc. documentation stuff to '$DESTDIR$DOCDIR'" >&2
   exit 1
fi

# Compile the source programs.

echo "$0: compiling source code ..." >&2
for i in src/*.c
do
   j=`basename $i .c`
   $CC $CFLAGS $CDEFS -o $DESTDIR$BINDIR/$j $i
   if [ $? -ne 0 ]
   then
      echo "$0: compile of $i failed" >&2
      exit 1
   fi
   # Not all Unix boxes have strip(1).
   # strip $DESTDIR$BINDIR/$bin_file
done

# Set version information.
echo $VERSION > $DESTDIR$DOCDIR/nosql_version

exit 0

# All done.