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
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
#!/bin/csh -f
#
# INSTALL -- Install the X11IRAF files and binaries.
#
#
#============================================================================
unset noclobber
onintr x11iraf_cleanup_
unalias cd cp cmp echo ln mv rm sed set grep ls chmod chown pwd touch sort
set path = (/sbin /usr/sbin /bin /usr/bin /usr/ucb /etc /usr/etc $path /usr /local/bin /opt/local/bin /local/bin /home/local/bin )
#============================================================================
# Global Variables.
#============================================================================
set hilite = 1
#============================================================================
# Utility aliases.
#============================================================================
alias PUT "mv -f \!*; chown $user \!$ " # [MACHDEP]
alias BOLD_ON "(if ($hilite) tput bold)"
alias BOLD_OFF "(if ($hilite) tput sgr0)"
alias SO_ON "(if ($hilite) tput smso)"
alias SO_OFF "(if ($hilite) tput rmso)"
alias DO_OK "(echo -n '[ '; BOLD_ON; echo -n ' OK '; BOLD_OFF; echo ' ]')"
alias DO_WARN "(echo -n '[ '; BOLD_ON; echo -n 'WARN'; BOLD_OFF; echo ' ]')"
alias DO_FAIL "(echo -n '[ '; SO_ON; echo -n 'FAIL'; SO_OFF; echo ' ]')"
alias MSG "(echo -n ' ';BOLD_ON;echo -n '*** ';BOLD_OFF; echo \!*)"
alias MSGN "(echo -n ' ';BOLD_ON;echo -n '*** ';BOLD_OFF; echo -n \!*)"
alias MSGB "(echo -n ' ';BOLD_ON;echo -n '*** ';echo \!*; BOLD_OFF)"
alias MSGBN "(echo -n ' ';BOLD_ON;echo -n '*** ';echo -n \!*;BOLD_OFF)"
alias ERRMSG "(echo -n ' ';BOLD_ON;echo -n 'ERROR: ';BOLD_OFF; echo \!*)"
alias WARNING "(echo -n ' ';BOLD_ON;echo -n 'WARNING: ';BOLD_OFF; echo \!*)"
alias NEWLINE "(echo '')"
alias PROMPT "(BOLD_ON; echo -n \!*; BOLD_OFF; echo -n ' (yes): ')"
alias PROMPT_N "(BOLD_ON; echo -n \!*; BOLD_OFF; echo -n ' (no): ')"
#============================================================================
# Get the current platform architecture.
#============================================================================
set UNAME=""
if (-e /usr/bin/uname) then
set uname_cmd = /usr/bin/uname
set UNAME=`/usr/bin/uname | tr '[A-Z]' '[a-z]'`
else if (-e /bin/uname) then
set uname_cmd = /bin/uname
set UNAME=`/bin/uname | tr '[A-Z]' '[a-z]'`
else
set UNAME = "INDEF"
endif
switch ($UNAME)
case sunos:
if (`$uname_cmd -m | cut -c2-` == "86pc") then
set arch = "sunos"
else
setenv OSVERSION `uname -r | cut -c1`
if ($OSVERSION == 5) then
set arch = "ssun"
else
set arch = "sparc"
endif
endif
breaksw
case linux:
if (`$uname_cmd -m` == "ppc") then
if (-f /etc/redhat-release) then
set arch = "linuxppc"
else
set arch = "mklinux"
endif
else
if (-f /etc/redhat-release) then
set arch = "redhat"
else if (-f /etc/SuSE-release) then
set arch = "suse"
else
set arch = "linux"
endif
endif
breaksw
case darwin:
case macosx:
case macintel:
if (`$uname_cmd -m` == "i386") then
set arch = "macintel"
else
set arch = "macosx"
endif
breaksw
case freebsd:
set arch = "freebsd"
breaksw
case hp-ux:
set arch = "hp700"
breaksw
case irix:
set arch = "irix"
breaksw
case irix64:
set arch = "irix"
breaksw
case aix:
set arch = "rs6000"
breaksw
case osf1:
set arch = "alpha"
breaksw
case ultrix:
set arch = "ultrix"
breaksw
default:
echo "ERROR: No 'uname' command found to determine architecture."
bad_arch:
NEWLINE
echo -n "Enter architecture name: "
set arch = "$<"
if (! -e bin.$arch) then
echo -n "Invalid architecture, try again..."
goto bad_arch
endif
breaksw
endsw
#############################################################################
# Process command line options.
#############################################################################
set exec = yes
while ("$1" != "")
switch ("$1")
case -n: # no execute
set exec = no
breaksw
case -hl: # disable highlighting
set hilite = 0
alias BOLD_ON "(if ($hilite) tput bold)"
alias BOLD_OFF "(if ($hilite) tput sgr0)"
alias SO_ON "(if ($hilite) tput smso)"
alias SO_OFF "(if ($hilite) tput rmso)"
breaksw
case +hl: # enable highlighting
set hilite = 1
alias BOLD_ON "(if ($hilite) tput bold)"
alias BOLD_OFF "(if ($hilite) tput sgr0)"
alias SO_ON "(if ($hilite) tput smso)"
alias SO_OFF "(if ($hilite) tput rmso)"
breaksw
case -h: # print help summary
goto Usage
default:
echo "install: unknown argument $1"
breaksw
endsw
if ("$2" == "") then
break
else
shift
endif
end
#############################################################################
# Check that we're running as 'root'
#############################################################################
if (-e /usr/bin/whoami) then
set WHOAMI = `/usr/bin/whoami`
else if (-e /usr/ucb/whoami) then
set WHOAMI = `/usr/ucb/whoami`
else if (-e /bin/whoami) then
set WHOAMI = `/bin/whoami`
endif
if ($WHOAMI != "root" && $exec == "yes") then
clear
NEWLINE ; NEWLINE
BOLD_ON
echo "======================================================================"
echo -n "WARNING"
BOLD_OFF
echo ": This script must be run as root for changes to take effect."
echo " If you decide to proceed, the 'no-op' flag will be enabled"
echo " by default. No changes will be made to the system files,"
echo " however you will be able to see what the script does."
BOLD_ON
echo "======================================================================"
BOLD_OFF
NEWLINE
no_op_proc_:
PROMPT "Proceed with a no-op installation anyway? "
set ans = "$<"
if ("$ans" != "") then
if ($ans == 'n' || $ans == 'N' || $ans == 'no' || $ans == 'NO') then
exit 0
endif
endif
NEWLINE
set exec = no
endif
#############################################################################
# Print the banner message.
#############################################################################
clear
NEWLINE
BOLD_ON
echo " X11IRAF V2.0 Installation"
echo " ========================="
BOLD_OFF
NEWLINE
# Print a quick usage summary.
NEWLINE
echo -n " For each prompt: hit "
BOLD_ON ; echo -n "<CR>"; BOLD_OFF;
echo -n " to accept the default value, "
BOLD_ON ; echo -n "'q'" ; BOLD_OFF
echo ' to quit,'
echo -n " or "
BOLD_ON ; echo -n "'help'"; BOLD_OFF
echo -n " or ";
BOLD_ON ; echo -n "'?'"; BOLD_OFF
echo -n " to print an explanation of the prompt."
NEWLINE
NEWLINE
#############################################################################
# Get the X11IRAF distribution file directory, assume it's the local
# directory but prompt if we don't find the files we expect.
#############################################################################
set xroot = "./"
do_root:
if (!(-e "$xroot/bin.$arch" && \
-e "$xroot/lib.$arch" && \
-e "$xroot/app-defaults")) then
echo -n "Directory containing the X11IRAF distribution files ($xroot): "
set xroot = "$<"
if ("$xroot" != "") then
if (! (-d "$xroot")) then
echo "Directory $xroot not found."
NEWLINE
goto do_root
endif
else if (! (-e "$xroot/bin.$arch" && \
-e "$xroot/lib.$arch" && \
-e "$xroot/app-defaults")) then
echo " *** This directory doesn't appear to contains all the"
echo " *** X11IRAF distribution files for this platform."
NEWLINE
set xroot = "./"
goto do_root
endif
endif
#############################################################################
# Install the binaries.
#############################################################################
set xgt = `which xgterm |& grep -i "^\/"`
if ($status == 0) then
set d_xbin = $xgt:h
else
set d_xbin = /usr/local/bin
endif
set BINFILES = \
"ism_wcspix.e obmsh resize vximtool xgterm ximtool ximtool-alt xtapemon"
NEWLINE ; BOLD_ON
echo "Binary Installation:"
echo "--------------------"
NEWLINE ; BOLD_OFF
echo " The local commands directory is the place where the commands"
echo " such as 'xgterm' and 'ximtool' will be installed. This should"
echo " be a directory in a common search path such as /usr/local/bin."
if ("$WHOAMI" != "root") then
echo " Since you are not running as the root user the files may be"
echo " installed in a personal directory such as $HOME/bin"
endif
do_bin:
NEWLINE
echo -n " Local commands directory ($d_xbin): "
set xbin = "$<"
if ("$xbin" == "") then
set xbin = $d_xbin
endif
# Check whether we're going to replace the existing binary or change
# the directory. Use only xgterm as the test.
set xgt = `which xgterm |& grep -i "^\/"`
if ($status == 0) then
if ("$xgt" != $xbin/xgterm) then
NEWLINE
echo " *** Some X11IRAF commands are already installed at a"
echo " *** different location, e.g. $xgt"
NEWLINE
db_pr:
echo -n " *** Would you like to delete these first (yes/no)? "
set c = "$<"
if ("$c" != "") then
if ($c == 'y' || $c == 'Y' || $c == 'yes' || $c == 'YES') then
NEWLINE
set xgt_root = $xgt:h
echo -n " Removing old binaries from $xgt_root ... "
if ($exec == "yes") then
foreach i ($BINFILES)
/bin/rm -f $xgt_root/$i
end
endif
echo -n " "
DO_OK
else
NEWLINE ; NEWLINE
endif
else
goto db_pr
endif
endif
endif
# Create the bin directory if needed.
if (! -e $xbin && "$exec" == "yes") then
mkdir $xbin
if ($status != 0) then
goto do_bin
endif
endif
# Copy the bin files to the new directory.
NEWLINE
set errstat = 0
if (-e bin.$arch) then
chdir bin.$arch
echo -n " Installing new binaries in $xbin ..."
if ("$exec" == "yes") then
foreach i (*)
cp $i $xbin >& /dev/null
if ($status == 1) then
DO_FAIL
ERRMSG "Cannot copy '$i' to $xbin"
set errstat = 1
break
endif
end
endif
if ($errstat == 0) then
DO_OK
endif
chdir ..
else
echo " *** No bin.$arch directory found, skipping installation."
endif
#############################################################################
# Install the man pages.
#############################################################################
if (-e /usr/local/man/man1) then
set d_xman = /usr/local/man/man1
else if (-e /opt/local/man/man1) then
set d_xman = /opt/local/man/man1
else if (-e /usr/man/man1) then
set d_xman = /usr/man/man1
else if (-e /share/man/man1) then
set d_xman = /share/man/man1
else if (-e /usr/share/man/man1) then
set d_xman = /usr/share/man/man1
else
set d_xman = "none found"
endif
NEWLINE ; NEWLINE
BOLD_ON
echo "Manual Page Installation:"
echo "-------------------------"
BOLD_OFF
NEWLINE
if ("$WHOAMI" != "root") then
echo " Since you are not running as the root user you cannot install"
echo " the manual pages for the X11IRAF tasks. These can still be"
echo " read by either formatting the pages yourself with a command"
echo " such as "
echo " % nroff -man -tbl xgterm.1 "
NEWLINE
echo " or you can define the MANPATH environment variable to search"
echo " this directory. For example,"
NEWLINE
echo ' setenv MANPATH $MANPATH'":$cwd/man "
else
echo " Man pages are available for each of the X11IRAF tasks, some"
echo " tasks will also provide online documentation. Manual pages"
echo " may be installed either in the main system directory or in "
echo " a local directory as long as that is accessible through a"
echo " MANPATH environment variable."
endif
do_man:
NEWLINE
echo -n " Local man page directory ($d_xman): "
set xman = "$<"
if ("$xman" == "") then
set xman = $d_xman
endif
# Create the man directory if needed.
if (! -e $xman && "$exec" == "yes") then
mkdir $xman
if ($status != 0) then
goto do_man
endif
endif
# Copy the man pages to the new directory.
NEWLINE
set errstat = 0
if (-e man) then
chdir man
echo -n " Installing man pages at $xman ..."
if ("$exec" == "yes") then
foreach i (*)
cp $i $xman >& /dev/null
if ($status == 1) then
DO_FAIL
ERRMSG "Cannot copy '$i' to $xman"
set errstat = 1
break
endif
end
endif
if ($errstat == 0) then
DO_OK
endif
chdir ..
else
echo " *** No 'man' directory found, skipping installation."
endif
#############################################################################
# Install the app-defaults files.
#############################################################################
if (-d /usr/lib/X11/app-defaults) then
set d_xapp = /usr/lib/X11/app-defaults
else if (-d /etc/X11/app-defaults) then
set d_xapp = /usr/lib/app-defaults
else if (-d /usr/X11R6/lib/app-defaults) then
set d_xapp = /usr/X11R6/lib/app-defaults
else if (-d /usr/X11R6/etc/app-defaults) then
set d_xapp = /usr/X11R6/etc/app-defaults
else if (-d /usr/openwin/lib/app-defaults) then
set d_xapp = /usr/openwin/lib/app-defaults
else if (-d /usr/lib/app-defaults) then
set d_xapp = /usr/lib/app-defaults
else
set d_xapp = "none found"
endif
NEWLINE ; NEWLINE
BOLD_ON
echo "Application Default Resource Installation:"
echo "------------------------------------------"
BOLD_OFF
NEWLINE
echo " The app-defaults directory contains the default X resources for"
echo " the XGterm task. This is not required for the program to work"
echo " but provides for more readable menu entries, fonts, etc."
echo " The directory is normally part of the X11 tree but may be any "
echo " directory specified in an XFILESEARCHPATH environment variable."
do_app:
NEWLINE
echo -n " System app-defaults directory ($d_xapp): "
set xapp = "$<"
if ("$xapp" == "") then
set xapp = $d_xapp
endif
# Create the app-defaults directory if needed.
if (! -e $xapp && "$exec" == "yes") then
mkdir $xapp
if ($status != 0) then
goto do_app
endif
endif
# Copy the app-defaults files to the new directory.
NEWLINE
set errstat = 0
if (-e app-defaults) then
chdir app-defaults
echo -n " Installing app-defaults in $xapp ..."
if ("$exec" == "yes") then
foreach i (*)
if($i == "XGterm" && ($arch == "macosx"||$arch == "macintel")) then
; # no-op
else
cp $i $xapp >& /dev/null
endif
if ($status == 1) then
DO_FAIL
ERRMSG "Cannot copy '$i' to $xapp"
set errstat = 1
break
endif
end
endif
if ($errstat == 0) then
DO_OK
endif
chdir ..
else
echo " *** No 'app-defaults' directory found, skipping installation."
endif
#############################################################################
# Install the (optional) CDL library.
#############################################################################
set d_xlib = /usr/local/lib
set d_xinc = /usr/local/include
NEWLINE ; NEWLINE
BOLD_ON
echo "Client Display Library (CDL) Installation:"
echo "------------------------------------------"
BOLD_OFF
NEWLINE
echo " The CDL is an interface for C/Fortran programs to display images"
echo " to XImtool and compatible display servers. This library is not"
echo " required in the runtime system for XImtool but can be useful for"
echo " developing local applications needing a display capability."
echo " The local lib directory is the place where the CDL library file "
echo " will be installed, the local include directory is where the needed"
echo " nclude files for the library will be installed."
do_lib:
NEWLINE
echo -n " Would you like to install this library? (yes): "
set ans = "$<"
set ans = `echo $ans | tr A-Z a-z`
if ("$ans" != "n" && "$ans" != "no") then
NEWLINE
echo -n " Local lib directory ($d_xlib): "
set xlib = "$<"
if ("$xlib" == "") then
set xlib = $d_xlib
endif
# Create the local lib directory if needed.
if (! -e $xlib && "$exec" == "yes") then
mkdir $xlib
if ($status != 0) then
goto do_lib
endif
endif
# Copy the library files to the new directory.
NEWLINE
set errstat = 0
if (-e lib.$arch) then
chdir lib.$arch
echo -n " Installing CDL libraries in $xlib ..."
if ("$exec" == "yes") then
foreach i (libcdl.a)
cp $i $xlib >& /dev/null
if ($status == 1) then
DO_FAIL
ERRMSG "Cannot copy '$i' to $xlib"
set errstat = 1
break
endif
end
endif
if ($errstat == 0) then
DO_OK
endif
chdir ..
else
echo " *** No lib.$arch directory found, skipping installation."
endif
# Install the include files.
do_inc:
NEWLINE
echo -n " Local include directory ($d_xinc): "
set xinc = "$<"
if ("$xinc" == "") then
set xinc = $d_xinc
endif
# Create the local lib directory if needed.
if (! -e $xinc && "$exec" == "yes") then
mkdir $xinc
if ($status != 0) then
goto do_inc
endif
endif
# Copy the include files to the new directory.
NEWLINE
set errstat = 0
if (-e include) then
chdir include
echo -n " Installing include files in $xinc ..."
if ("$exec" == "yes") then
foreach i (cdl*)
cp $i $xinc >& /dev/null
if ($status == 1) then
DO_FAIL
ERRMSG "Cannot copy '$i' to $xlib"
set errstat = 1
break
endif
end
endif
if ($errstat == 0) then
DO_OK
endif
chdir ..
else
echo " *** No 'include' directory found, skipping installation."
endif
else
echo " Skipping CDL library installation."
endif
NEWLINE
echo "Installation complete."
NEWLINE
x11iraf_cleanup_:
# Normal exit.
exit 0
Usage:
echo "Usage: install [-n] [-h] [-hl]"
echo ""
echo " where -n # no execute"
echo " -h # print this help summary"
echo " +hl # enable highlighted text"
echo " -hl # disable highlighted text"
exit 0
|