-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlibinstall
executable file
·523 lines (476 loc) · 14 KB
/
libinstall
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
#! /bin/sh
# libinstall - installation script for the MiNTLib (binary distributions).
# Copyright (C) 1999-2001 Guido Flohr <guido@freemint.de>.
#
# This file is part of the MiNTLib project, and may only be used
# modified and distributed under the terms of the MiNTLib project
# license, COPYMINT. By continuing to use, modify, or distribute
# this file you indicate that you have read the license and
# understand and accept it fully.
here=`pwd`
echo_n="/bin/echo -n"
required_programs="cp cat sed awk tr grep sort uniq chmod rm"
install=
gcc=
mkinstalldirs=./mkinstalldirs
PRIMARY_YDATA="africa antarctica asia australasia \
europe northamerica southamerica"
YDATA="$PRIMARY_YDATA pacificnew etcetera factory backward"
NDATA="systemv"
SDATA="solar87 solar88 solar89"
TDATA="$YDATA $NDATA $SDATA"
check_environment()
{
# Check if run from current directory.
if test ! -x ./$0; then
echo "Error: $0 must be run from current directory."
exit 1
fi
echo "Welcome to the MiNTLib installation script. First we have to check"
echo "if your system is ready to install the MiNTLib."
sleep 3 2>/dev/null
missing=""
for p in $required_programs; do
$echo_n "Checking for $p..."
found=no
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
if test -x $dir/$p; then
found=yes
echo " $dir/$p"
break
fi
done
IFS="$save_ifs"
if test $found = no; then
missing="$missing $p"
echo "missing"
fi
done
$echo_n "Checking for ln..."
found=no
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
if test -x $dir/ln; then
found=yes
echo " $dir/ln"
break
fi
done
IFS="$save_ifs"
if test $found = no; then
ln_s="cp"
echo "missing, will take cp instead"
else
ln_s="ln -s"
fi
export ln_s
if test -n "$missing"; then
echo "The following required programs are missing on your system:"
for p in $missing; do
echo " $p"
done
cat <<EOF
Either you have not set up your PATH envariable correctly or you don't
have the programs. All of these standard programs should be widely
available for anonymous download from various ftp servers. If you
can't find them please contact the MiNTLib maintainer (see README)
or the MiNT mailing list (currently mint@fishpool.com).
Good bye for now!
EOF
exit 1
fi
}
add_missing ()
{
$echo_n "Checking for install..."
try_install="$INSTALL install ginstall $here/install-sh"
for install in $try_install; do
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
if test -x $dir/$try; then
if test $install != $here/install-sh; then
install="$install -c"
fi
echo " $dir/$install"
break
fi
done
IFS="$save_ifs"
break
done
$echo_n "Checking for gcc..."
try_gccs="$CC gcc cc"
gcc=""
for try_gcc in $try_gccs; do
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
if test -x $dir/$try_gcc; then
echo " $dir/$try_gcc"
gcc=$try_gcc
break
fi
done
IFS="$save_ifs"
if test x"$gcc" != x; then
break
fi
done
if test x"$gcc" = x; then
echo " missing"
fi
$echo_n "Checking for korn shell..."
found=no
try_kshs="$KSH ksh bash ksh" # ksh is listed twice on purpose!
for KSH in $try_kshs; do
search_path="/bin":$PATH
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $search_path; do
if test -x $dir/$KSH; then
echo " $dir/$KSH"
found=yes
break
fi
done
IFS="$save_ifs"
if test x$found != xno; then
break
fi
done
if test x$found != xyes; then
echo " missing"
fi
unset TIMEZONE
. /etc/sparemint/timezone >/dev/null 2>/dev/null
if test "x$TIMEZONE" != "xFactory"; then
LOCALTIME="$TIMEZONE"
POSIXRULES="$TIMEZONE"
fi
if test "$LOCALTIME" = "Factory" -o "$POSIXRULES" = "Factory"; then
cat <<EOF
WARNING: It seems like you haven't edited the file \`configvars'
because either the variable \`LOCALTIME' or \`POSIXRULES' is still
set to \`Factory'. You should exit the installation now and
restart after you have edited \`configvars'.
You will find a list of possible time zones in the file \`tz/zonelist'.
EOF
$echo_n "Exit the installation for now [y/N]? "
read reply
case $reply in
[yY]*) exit 1 ;;
*) ;;
esac
cat <<EOF
OK, you can later correct the settings for your local time zone by
zic -l TIMEZONE
and change the default rules with
zic -p TIMEZONE
Replace TIMEZONE with one of the values you find in the file
$here/zonenames.
EOF
sleep 3 2>/dev/null
fi
if test x$UID != x0; then
cat <<EOF
WARNING: You are not the superuser. It is very unlikely that you
will manage to install the MiNTLib without superuser permissions.
You should become superuser (for example with the su command) and
then continue the installation).
EOF
$echo_n "Exit the installation for now [Y/n]? "
read reply
case $reply in
[nN]*) ;;
*) exit 1 ;;
esac
fi
}
install_headers ()
{
echo "Installing library header files."
if test -n "$gcc"; then
if test "$HEADER_CLEANUP" != "no"; then
$echo_n "First we will clean up your old system include files..."
MINTLIB_VERSION=$VERSION CC=$gcc include/clean-include
echo " done"
fi
else
cat include/00README
echo
echo "You can reread this message in the file include/00README."
sleep 3 2>/dev/null
fi
# Evaluate include/MISCFILES.
for dir in "" arpa bits mint net netinet protocols sys; do
test x$dir = x && dir= || dir=$dir/
headers=`cat include/"$dir"MISCFILES | \
sed -e 's,#.*,,g' -e 's,MISCFILES *= *,,g' | \
tr '[ \t]' '\n' | \
grep '\.h$'`
$mkinstalldirs $includedir/$dir
for header in $headers; do
echo " $install -m 644 include/$dir$header $includedir/$dir$header"
$install -m 644 include/$dir$header $includedir/$dir$header || exit 1
done
done
}
install_startup ()
{
echo "Installing startup files."
files="crt0.o gcrt0.o"
$mkinstalldirs $libdir
startupdir=startup
test -d $startupdir || startupdir=lib # Binary distribution!
for file in $files; do
echo " $install -m 644 $startupdir/$file $libdir"
$install -m 644 $startupdir/$file $libdir || exit 1
done
}
install_manpages ()
{
echo "Installing manual pages."
sections="1 2 3 4 5 6 7 8"
for section in $sections; do
manpages=`ls */*.$section 2>/dev/null`
if test x != "x$manpages"; then
installdir=$mandir/man$section
$mkinstalldirs $installdir
for manpage in $manpages; do
page=`echo $manpage | sed 's,.*/,,g'`
echo "rm -f $installdir/$page $installdir/$page.gz $installdir/$page.Z"
rm -f $installdir/$page $installdir/$page.gz $installdir/$page.Z
echo " $install -m 644 $manpage $installdir/$page"
$install -m 644 $manpage $installdir/$page
done
fi
done
}
install_libs ()
{
echo "Installing libraries."
$mkinstalldirs $libdir
for type in "" _p _g 020 v4e; do
case x$type in
x020)
libinstdir=$libdir/m68020-60
libheredir=lib020
type=
;;
xv4e)
libinstdir=$libdir/m5475
libheredir=libv4e
type=
;;
x_p|x_g)
libinstdir=$libdir
libheredir=lib$type
;;
*)
libinstdir=$libdir
libheredir=lib
;;
esac
for lib in c iio socket; do
libname=lib$lib$type.a
test -f $libheredir/$libname || continue
echo " $install -m 644 $libheredir/$libname $libinstdir"
$install -m 644 $libheredir/$libname $libinstdir || exit 1
done
done
}
install_tz ()
{
echo "Installing time zone database."
$echo_n " Creating tz/yearistype..."
rm -f tz/yearistype
cp tz/yearistype.sh tz/yearistype && chmod +x tz/yearistype || exit 1
echo " done"
$echo_n " Creating tz/tzselect..."
rm -f tz/tzselect
sed \
-e 's|AWK=[^}]*|AWK=awl|g' \
-e 's|TZDIR=[^}]*|TZDIR=$TZDIR|' \
<tz/tzselect.ksh >tz/tzselect
chmod +x tz/tzselect || exit 1
echo " done"
echo " Deleting stale zoneinfo files..."
echo " rm -f $TZDIR/localtime"
rm -f $TZDIR/localtime
echo " rm -f $TZDIR/posixrules"
rm -f $TZDIR/posixrules
if test ! -f /etc/sparemint/timezone; then
echo "creating /etc/sparemint/timezone, please read it."
cat >/etc/sparemint/timezone <<EOF
#! /bin/sh
# This is /etc/sparemint/timezone.
#
# This file is a shell script fragment that is read by installation
# routines to select your preferred timezone. To get a list of
# possible timezones run the script "tzselect" (usually installed
# as /usr/sbin/tzselect) to guess a timezone interactively. If
# this doesn't work you can also have a look at the timezone database,
# usually installed in /usr/share/zoneinfo. Choose any one of the
# files found there, such as "Europe/Paris" or "America/New_York"
# as your timezone.
#
# Please note that there must not be any whitespace around the
# equality sign following.
TIMEZONE=$LOCALTIME
# If TIMEZONE above was set to "Factory" you have not yet installed
# your timezone correctly (changing this here file only helps you
# now you re-install the MiNTLib). You should now run the program
# "zic" to permanently set your timezone. Do it as
#
# zic -l Europe/Paris -p Europe/Paris
#
# or
#
# zic -l America/New_York -p America/New_York
#
# depending on what timezone you chose. See the manual page zic(8)
# for details.
EOF
else
. /etc/sparemint/timezone
if test "x$TIMEZONE" != x; then
echo "Reading /etc/sparemint/timezone for your timezone configuration."
LOCALTIME=$TIMEZONE
POSIXRULES=$TIMEZONE
fi
fi
cat <<EOF
Now compiling the timezone database. This may require some time. In
the meantime you can say hello to your family in case they still know you.
If you don't have a family ... you have a couple of minutes spare time
now.
EOF
# Poor man's make rules.
case $REDO in
posix_right)
REDO="posix_only posix_spare right_spare"
;;
right_posix)
REDO="right_only posix_spare right_spare"
;;
posix_only|right_only)
;;
*)
cat <<EOF
error: You must choose one of the values
right_only
posix_only
right_posix
posix_right
for the variable REDO in \`configvars'. Please edit \`configvars'
and re-install the database.
EOF
exit 1
;;
esac
tdata=""
for srcfile in $TDATA; do
tdata="$tdata tz/$srcfile"
done
$mkinstalldirs $TZDIR
for target in $REDO; do
case $target in
posix_only|posix_spare)
tzdir=$TZDIR
test $target = posix_spare && tzdir=$tzdir/posix
cat <<EOF
Installing posixly correct (not accounting leapseconds) database in
$tzdir.
tz/zic -y tz/yearistype -d $tzdir -L /dev/null $tdata
EOF
tz/zic -y tz/yearistype -d $tzdir -L /dev/null $tdata || exit 1
;;
right_only|right_spare)
tzdir=$TZDIR
test $target = right_spare && tzdir=$tzdir/right
cat <<EOF
Installing time zone database (with leapsecond calculation) in
$tzdir.
tz/zic -y tz/yearistype -d $tzdir -L tz/leapseconds $tdata
EOF
tz/zic -y tz/yearistype -d $tzdir -L /dev/null $tdata || exit 1
;;
esac
done
echo " Installing system-wide default time zone and tabular data."
echo " $install -m 644 tz/iso3166.tab $TZDIR"
$install -m 644 tz/iso3166.tab $TZDIR || exit 1
echo " $install -m 644 tz/zone.tab $TZDIR"
$install -m 644 tz/zone.tab $TZDIR || exit 1
echo " tz/zic -y tz/yearistype -d $TZDIR -l $LOCALTIME -p $POSIXRULES"
tz/zic -y tz/yearistype -d $TZDIR -l $LOCALTIME -p $POSIXRULES || exit 1
echo " Installing time zone tools in $sbindir."
progs="zic zdump tzselect"
$mkinstalldirs $sbindir
for prog in $progs; do
echo " $install -m 755 tz/$prog $sbindir"
$install -m 755 tz/$prog $sbindir || exit 1
done
echo " Installing time zone tools in $bootsbindir."
progs="tzinit"
$mkinstalldirs $bootsbindir
for prog in $progs; do
echo " $install -m 755 tz/$prog $bootsbindir"
$install -m 755 tz/$prog $bootsbindir || exit 1
done
}
# Include Makefile fragment and ignore errors.
. configvars 2>/dev/null
case "x$CROSS" in
x)
CROSS=
;;
y|Y|yes|YES|Yes)
CROSS=yes
;;
esac
check_environment
add_missing
echo "Everything seems to be set up alright."
if test -f Makefile -a "x$CROSS" = "x"; then
cat <<EOF
The MiNTLib is now shipped with an exhaustive test suite that checks if
your MiNTLib is fully functional. If you haven't yet updated your system
to FreeMiNT a lot of tests will fail because of missing features that
are required in a modern operating system. Even with FreeMiNT some tests
may fail, either because they really reveal bugs that are still waiting
to be fixed or because you don't use a recent kernel.
To compile and run the test suite can take more than one hour, depending
on your system's performance. It may also need a considerable amount
of memory (and fail if you don't have enough RAM).
If after reading the above you decide not to run the test suite it's still
not a hazard game to install the library. The program \`zic' that is
used here during the installation has been compiled and link with the
library you are going to install. If the library is broken it is very
likely that the program will also crash or fail.
EOF
$echo_n "Run the test suite now [N/y]? "
read reply
case $reply in
[yY]*) make -k check
;;
*) echo "OK, you can always run it later by typing \`make -k check'."
;;
esac
fi
# Installing the time zone database is already a very basic test for
# the library. It should therefore be done before installing the
# library or header files.
if test x$CROSS = x; then
install_tz
else
echo "Not installing time zone database for cross compilation."
fi
install_headers
install_startup
install_libs
install_manpages
cat <<EOF
Installation completed. Good luck and have fun when writing free
software that you contribute to the FreeMiNT community or the
MiNTLib project.
EOF