File: easyinst

package info (click to toggle)
blackened 1.8.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,916 kB
  • ctags: 3,389
  • sloc: ansic: 46,055; sh: 554; makefile: 270; perl: 46
file content (509 lines) | stat: -rwxr-xr-x 10,446 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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
#!/bin/sh
#
# this script is a front end to `configure' which also asks a few
# other questions such as default server, etc.
# $Id: easyinst,v 1.5 2001/12/01 21:42:07 toast Exp $
#
# $defserver
# $sysinstall (exists and is nonempty if system install)
# $prefix
# $bindir
# $libdir
# $irclink
#
# Eventually, if $HOME/.blackened.easyinst.status defines no previous
# $libdir, and the environment variable $IRCLIB is set and non-nul,
# $libdir will default to that.
#

#
# Check if this is run through sh...
#
export PATH || \
(echo "This shell does not look like sh... buggy OS."; sh $0; kill $$)

#
# File to save configuration in...
#

# I guess root doesn't want a /.blackened.easyinst.status file created
if test -w /; then
  savefile=/tmp/blackened.easyinst.status
else
  savefile=$HOME/.blackened.easyinst.status
fi

#
# The famous "no default" string
#
nodef="no default"

#
# We like "blackened" just fine
#
irclink="blackened"

#
# Checking out how to suppress new lines...
#
if [ "`echo -n a`" = "a" ]; then
  n='-n'
  c=''
else
  n=''
  c='\c'
fi

sed=/usr/bin/sed
#
# Set up ~user expansion
cat >.tildexp <<EOF
#!/bin/sh
case "\$1" in
~/*|~)
  echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  ;;
~*)
  if test -f /bin/csh; then
    /bin/csh -f -c "glob \$1"
    failed=$?
    echo ""
    exit \$failed
  else
    name=\`$expr x\$1 : '..\([^/]*\)'\`
    dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
    if test ! -d "\$dir"; then
      me=\`basename \$0\`
      echo "\$me: can't locate home directory for: \$name" \>\&2
      exit 1
    fi
    case "\$1" in
    */*)
      echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
      ;;
    *)
      echo \$dir
      ;;
    esac
  fi
  ;;
*)
  echo \$1
  ;;
esac
EOF
chmod a+x .tildexp

#
# Set up shell script to read input
#
myecho="case \"\$xxxm\" in
'') echo $n \"\$rp $c\" >&4;;
*)  case \"\$rp\" in
  '') echo $n \"[\$xxxm] $c\";;
  *)
    if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge ${COLUMNS-80}; then
      echo \"\$rp\" >&4
      echo $n \"[\$xxxm] $c\" >&4
    else
      echo $n \"\$rp [\$xxxm] $c\" >&4
    fi
    ;;
  esac;;
esac"
cat <<EOF > .myread
xxxm=\$dflt
$myecho
ans='!'
case "\$fastread" in
yes) case "\$dflt" in
  '') ;;
  *) ans='';
    case "\$silent-\$rp" in
    true-) ;;
    *) echo " " >&4;;
    esac;;
  esac;;
*) case "\$silent" in
  true) case "\$rp" in
    '') ans='';;
    esac;;
  esac;;
esac
while expr "X\$ans" : "X!" >/dev/null; do
  read answ
  set x \$xxxm
  shift
  aok=''; eval "ans=\"\$answ\"" && aok=y
  case  "\$answ" in
  "\$ans")
    case "\$ans" in
    "!")
      sh 1>&4
      echo " "
      $myecho
      ;;
    !*)
      set x \`expr "X\$ans" : "X!\(.*\)\$"\`
      shift
      sh 1>&4 -c "\$*"
      echo " "
      $myecho
      ;;
    esac;;
  *)
    case "\$aok" in
    y)
      echo "*** Substitution done -- please confirm."
      xxxm="\$ans"
      ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
      xxxm="\$ans"
      ans=!
      ;;
    *)
      echo "*** Error -- try again."
      ans=!
      ;;
    esac
    $myecho
    ;;
  esac
  case "\$ans\$xxxm\$nostick" in
  '')
    ans=!
    $myecho
    ;;
  esac
done
case "\$ans" in
'') ans="\$xxxm";;
esac
EOF

trapdeletefiles=".myread .tildexp"

trap '{
  exitstat=$?
  rm -f $trapdeletefiles
  trap "" 0
  echo "Aborting... cleaning up." >&2
  exit $exitstat
}' 0 1 2 15

# Prepare redirection for "silent" mode (to be implemented :)
exec 4>&1

cat << EOF

Welcome to the easy install script.

I will ask you a few questions. Most of the time, a default value will
be printed, and you'll just need to hit the 'Return' key to confirm.
If you get stuck on a question, you may use a ! shell escape to start
a subshell or execute a !command.

Some questions asking for file or directory names allow the use of the ~user
construct to specify the login directory belonging to "user", even if you
don't have a shell which knows about that. They'll be marked "(~user ok)".

The prompter used in this script allows you to use shell variables and
backticks in your answers.  You may use \$1, \$2, etc...  to refer to the words
in the default answer, as if the default line was a set of arguments given to a
script shell.  This means you may also use \$@ to repeat the whole default line,
so you do not have to re-type everything to add something to the default.

Everytime there is a substitution, you will have to confirm.  If there is an
error (e.g. an unmatched backtick), the default answer will remain unchanged
and you will be prompted again.

If you are satisfied with your choices, I will then run a script for you
to work out some of the hairier parts of your system. Good luck!
EOF
dflt="Press 'Return' to go on"
. ./.myread

#
# Trick to load old easyinst values :)
#
if test -r "$savefile"; then
  echo "
I see a $savefile file."
  dflt="y"
  rp="Do you want to use it to set the defaults?"
  . ./.myread
  case "$ans" in
  n*|N*) echo "Ignoring $savefile." ;;
  *)
    echo "Loading previous easyinst choices..."
    trap "{
      rm -f $savefile
      echo 'Fatal error. Please restart easyinst.' >&2
    }" 0
    . $savefile || \
      (
        echo 'Fatal error. Please restart easyinst.' >&2
        rm -f $savefile
        kill $$ \$\$
      )
    ;;
  esac
  trap 0
fi

# Because the previous branch as squished the trap on exit
trap '{
  exitstat=$?
  rm -f $trapdeletefiles
  trap "" 0
  echo "Aborting... cleaning up." >&2
  exit $exitstat
}' 0 1 2 15

# we have to get this from the user:
#  default server and where to install things.

# first we get the default server.

cat << EOF

I need to know the name of the IRC server you intend to use as your
primary link.  You should have done a little research by this time to see
what servers are in your area. You should always pick the absolute closest
server to you.  You can use an IP address instead of a name as well.

EOF

if test "$defserver"; then
  dflt="$defserver"
else
  dflt="$nodef"
fi
rp="Please type the name of a server."

while true; do
  . ./.myread
  case "$ans" in
  "$nodef")
    continue
    ;;
  /*)
    if test -f "$ans"; then :; else
      echo "$ans doesn't seem to exist right now. You'll need to create it."
    fi
    ;;
  *)
    ;;
  esac
  break
done
defserver="$ans"

# got a default server, must be time to get the installation dir.

cat << EOF

Ok, we've got a default server now, next we have to choose where things
are going to go.  First i need to know if you are compiling Blackened
for yourself, or for the system.

EOF
if test "$prefix"; then
  echo "Note: If you want to keep old directory values, just hit 'Return'.
"
  nostick=true
fi

dflt=""
rp="Do you want to install Blackened for the system?"
. ./.myread
case "$ans" in
y*|Y*)
  sysinstall=nap
  prefix="/usr/local"
  bindir=
  libdir=
  ;;
n*|N*)
  sysinstall=
  prefix="${HOME}"
  bindir=
  libdir=
  ;;
*)
  prefix="${prefix-${HOME}}"
  ;;
esac
nostick=""

cat << EOF

We now need to find out the destination area of the installation.
Such a directory will probably have two subdirectories, something
like 'bin' for the binaries, and 'share/blackened' for the libraries.

Hit 'Return' to keep previously computed values.
EOF
dflt="$prefix"
rp='
What is the destination prefix of the installation? (~user ok)'
. ./.myread
ans=`./.tildexp "$ans"`

#
# If we have an answer, reset the other variables so that they get computed.
#
case "$ans" in
"$dflt") ;;
*)
  prefix="$ans"
  bindir=
  libdir=
  ;;
esac

if test -z "$bindir"; then
  bindir="${prefix}/bin"
fi

dflt="$bindir"
rp='
Where do you want to install the Blackened binaries? (~user ok)'
. ./.myread
ans=`./.tildexp "$ans"`

if test "$ans"; then bindir="$ans"; fi

#
# Algorithm used:
# Check if directory ${prefix}/share exists...
#   Yes -> install in ${prefix}/share/blackened
#    No -> install in ${prefix}/Blackened
#

# If no $libdir is defined at this stage, but there's a $IRCLIB
# in the environment, default to this value.

if test -z "$libdir"; then
  if test "${IRCLIB}"; then
    libdir="${IRCLIB}"
  elif test -d "${prefix}/share"; then
    libdir="${prefix}/share/blackened"
  else
    libdir="${prefix}/Blackened"
  fi
fi

dflt="$libdir"
rp='
Where do you want to install the Blackened data files? (~user ok)'
. ./.myread
ans=`./.tildexp "$ans"`

if test "$ans"; then libdir="$ans"; fi

cat << EOF

Now we need to determine what you want to name the sym-link that will
point to the binary executable.

Hit 'Return' to keep previously computed values.
EOF
dflt="$irclink"
rp='
What is the name of the executable sym-link?'
. ./.myread
if test "$ans"; then irclink="$ans"; fi

# ok, we have places to put things now.

cat << EOF

I will summarize below the various choices you've made.

                Default server: $defserver
                        Prefix: $prefix
    Directory for binary files: $bindir
       Directory for libraries: $libdir
           Executable sym-link: $irclink

EOF

rp='Do you want to save those values for future use and proceed?'
dflt='y'
. ./.myread
case "$ans" in
n*|N*)
  echo "Exiting without saving..."
  exit 1
  ;;
*)
  ;;
esac

{
  cat << EOF
#
# ${savefile}
# This file is automagically generated by the command 'easyinst'
# Please do not edit.
#
EOF
  echo '# $Id: easyinst,v 1.5 2001/12/01 21:42:07 toast Exp $'
  echo "# Created: `date`"
  echo '# '
  cat << EOF
defserver="${defserver}"
sysinstall="${sysinstall}"
prefix="${prefix}"
bindir="${bindir}"
libdir="${libdir}"
irclink="${irclink}"

EOF
} > ${savefile}

cat << EOF

I just saved for you the current configuration in
	$savefile

If you have made a typo, hit ^C now, edit this file and restart easyinst.

Now I will configure this version of Blackened using the 'configure'
script provided.

This may take a few minutes, so sit back an enjoy the show...

EOF

# work out what arguments to call configure with.

echo "setting up config.h..."

IRCLIB="$libdir"
export IRCLIB

IRCLINK="$irclink"
export IRCLINK

if test "$defserver"; then
  rm -f include/config.h.old
  mv include/config.h include/config.h.old
  cp include/config.h.dist include/config.h

  sed -e "s@\(#define[ 	]\{1,\}DEFAULT_SERVER[	 ]\{1,\}\).*\$@\1 \"$defserver\"@" \
< include/config.h > include/config.h.new
  rm -f include/config.h
  mv -f include/config.h.new include/config.h
fi


rm -f $trapdeletefiles
trap 0 1 2 15

echo "calling configure..."
./configure --prefix=${prefix}

# End of script
exit 0