File: install.com

package info (click to toggle)
nethack 3.4.3-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,512 kB
  • ctags: 16,957
  • sloc: ansic: 196,792; cpp: 7,083; sh: 6,785; yacc: 2,005; lex: 377; makefile: 120; awk: 89; sed: 11
file content (268 lines) | stat: -rw-r--r-- 9,676 bytes parent folder | download | duplicates (22)
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
$ ! vms/install.com -- set up nethack 'playground'
$ !
$ ! Use vmsbuild.com to create nethack.exe, makedefs, and lev_comp *first*.
$ !
$ ! Edit this file to define gamedir & gameuic, or else invoke it with two
$ ! command line parameters, as in:
$ !	@[.sys.vms]install "disk$users:[games.nethack]" "games"
$ ! or	@[.sys.vms]install "[-.play]" "[40,1]"
$ !
$	! default location is old playground, default owner is installer
$	gamedir = f$trnlnm("NETHACKDIR")	!location of playground
$	if gamedir.eqs."" then  gamedir = f$trnlnm("HACKDIR")
$	gameuic = f$user()			!owner of playground
$	! --- nothing below this line should need to be changed ---
$	if p1.nes."" then  gamedir := 'p1'
$	if p2.nes."" then  gameuic := 'p2'
$
$	! note: all filespecs contain some punctuation,
$	!	to avoid inadvertent logical name interaction
$	play_files = "PERM.,RECORD.,LOGFILE.,PANICLOG."
$	help_files = "HELP.,HH.,CMDHELP.,WIZHELP.,OPTHELP.,HISTORY.,LICENSE."
$	data_files = "DATA.,RUMORS.,ORACLES.,OPTIONS.,QUEST.DAT"
$	guidebook  = "[.doc]Guidebook.txt"
$	invoc_proc = "[.sys.vms]nethack.com"
$	trmcp_file = "[.sys.share]termcap"
$	spec_files = "AIR.LEV,ASMODEUS.LEV,ASTRAL.LEV,BAALZ.LEV,BIGRM-%.LEV," -
		   + "CASTLE.LEV,EARTH.LEV,FAKEWIZ%.LEV,FIRE.LEV," -
		   + "JUIBLEX.LEV,KNOX.LEV,MEDUSA-%.LEV,MINEFILL.LEV," -
		   + "MINETN-%.LEV,MINEND-%.LEV,ORACLE.LEV,ORCUS.LEV," -
		   + "SANCTUM.LEV,SOKO%-%.LEV,TOWER%.LEV,VALLEY.LEV," -
		   + "WATER.LEV,WIZARD%.LEV"
$	spec_input = "bigroom.des castle.des endgame.des " -
		   + "gehennom.des knox.des medusa.des mines.des " -
		   + "oracle.des sokoban.des tower.des yendor.des"
$	qstl_files = "%%%-GOAL.LEV,%%%-FIL%.LEV,%%%-LOCA.LEV,%%%-STRT.LEV"
$	qstl_input = "Arch.des Barb.des Caveman.des Healer.des " -
		   + "Knight.des Monk.des Priest.des Ranger.des Rogue.des " -
		   + "Samurai.des Tourist.des Wizard.des Valkyrie.des"
$	dngn_files = "DUNGEON."
$	dngn_input = "dungeon.pdf"
$	dlb_files  = help_files + "," + data_files + "," -
		   + spec_files + "," + qstl_files + "," + dngn_files
$	data_libry = "nh-data.dlb"
$	xtrn_files = "LICENSE.,HISTORY.,OPTIONS."
$ makedefs := $sys$disk:[-.util]makedefs
$ lev_comp := $sys$disk:[-.util]lev_comp
$ dgn_comp := $sys$disk:[-.util]dgn_comp
$ dlb	   := $sys$disk:[-.util]dlb
$ milestone = "write sys$output f$fao("" !5%T "",0),"
$ if p3.nes."" .and. f$edit(p4,"UPCASE").nes."VERBOSE" then  milestone = "!"
$ echo = "write sys$output"
$ warn = echo	!could be "write sys$error"
$!
$! make sure we've got a playground location
$ gamedir := 'gamedir'
$ if gamedir.eqs."" then  gamedir = "[.play]"	!last ditch default
$ gamedir = f$parse(gamedir,,,,"SYNTAX_ONLY") - ".;"
$ if gamedir.eqs."" then  write sys$error "% must specify playground directory"
$ if gamedir.eqs."" then  exit %x1000002C	!ss$_abort
$
$!
$!	['p3' is used in Makefile.top]
$ if p3.nes."" then  goto make_'p3'
$
$	milestone "<installation...>"
$!
$make_data_plus_dlb:
$make_data:
$	! start from a known location -- [.sys.vms]
$	set default 'f$parse(f$environment("PROCEDURE"),,,"DIRECTORY")'
$! generate miscellaneous data files
$	set default [-.-.dat]	!move to data directory
$	milestone "(data)"
$ makedefs -d	!data.base -> data
$	milestone "(rumors)"
$ makedefs -r	!rumors.tru + rumors.fal -> rumors
$	milestone "(oracles)"
$ makedefs -h	!oracles.txt -> oracles
$	milestone "(dungeon preprocess)"
$ makedefs -e	!dungeon.def -> dungeon.pdf
$	milestone "(quest text)"
$ makedefs -q	!quest.txt -> quest.dat
$	milestone "(special levels)"
$ lev_comp 'spec_input' !special levels
$	milestone "(quest levels)"
$ lev_comp 'qstl_input' !quest levels
$	milestone "(dungeon compile)"
$ dgn_comp 'dngn_input' !dungeon database
$	set default [-]		!move up
$ if p3.nes."" .and. f$edit(p3,"UPCASE").nes."DATA_PLUS_DLB" then  exit
$
$make_dlb:
$	! start from a known location -- [.sys.vms]
$	set default 'f$parse(f$environment("PROCEDURE"),,,"DIRECTORY")'
$! construct data library
$	set default [-.-.dat]	!move to data directory
$	milestone "(dlb setup)"
$! since DLB doesn't support wildcard expansion and we don't have shell
$! file globbing, start by making a file listing its intended contents
$ create nhdat.lst
$	if f$search("nhdat.lst;-1").nes."" then -
		purge/noConfirm/noLog nhdat.lst
$! an old data file might fool us later, so get rid of it
$	if f$search(data_libry).nes."" then -
		delete/noConfirm/noLog 'data_libry';*
$	if f$trnlnm("PFILE$").nes."" then  close/noLog pfile$
$ open/Append pfile$ nhdat.lst
$ i = 0
$dloop:
$   g = f$element(i,",",dlb_files)
$   if g.eqs."," then  goto ddone
$   wild = f$locate("*",g).ne.f$locate("%",g)
$   fcnt = 0
$floop:
$	f = f$search(g)
$	if f.eqs."" then  goto fdone
$	fcnt = fcnt + 1
$! strip device, directory, and version from name
$	f = f$parse(f,,,"NAME") + f$parse(f,,,"TYPE")
$! strip trailing dot, if present, and change case
$	f = f$edit(f + "#" - ".#" - "#","LOWERCASE")
$	if f$extract(3,1,f).eqs."-" then -	!"xyz-foo.lev" -> "Xyz-foo.lev"
		f = f$edit(f$extract(0,1,f),"UPCASE") + f$extract(1,255,f)
$	write pfile$ f
$	if wild then  goto floop
$fdone:
$   if fcnt.eq.0 then  warn "? no file(s) found for """,g,""""
$   i = i + 1
$   goto dloop
$ddone:
$ close pfile$
$	milestone "(dlb create)"
$ dlb "-cfI" 'data_libry' nhdat.lst
$	set default [-]		!move up
$ if p3.nes."" then  exit
$
$!
$! set up the playground and save directories
$	milestone "(directories)"
$make_directories:
$	srctree = f$environment("DEFAULT")
$	set default 'gamedir'
$ if f$parse("[-]").eqs."" then  create/dir/log [-] !default owner & protection
$ if f$parse("[]" ).eqs."" then - !needs to be world writable
   create/directory/owner='gameuic'/prot=(s:rwe,o:rwe,g:rwe,w:rwe)/log []
$ if f$search("SAVE.DIR;1").eqs."" then -
   create/directory/owner='gameuic'/prot=(s:rwe,o:rwe,g:rwe,w:rwe)/log -
	[.SAVE]/version_limit=2
$	set default 'srctree'
$ if p3.nes."" then  exit
$!
$! create empty writeable files -- logfile, scoreboard, multi-user access lock
$! [if old versions are already present, validate and retain them if possible]
$make_writeable_files:
$	milestone "(writeable files)"
!-!$ create/owner='gameuic'/prot=(s:rwed,o:rwed,g:rwed,w:rwed) -
!-!	'gamedir''play_files'
$	i = 0
$ploop:	if f$trnlnm("PFILE$").nes."" then  close/nolog pfile$
$	f = f$element(i,",",play_files)
$	if f.eqs."," then  goto pdone
$	i = i + 1
$	f = gamedir + f
$	if f$search(f).eqs."" then  goto pmake	!make it if not found
$	if f$file_attrib(f,"RFM").nes."STMLF" then  goto prej !must be stream_lf
$	open/read/error=prej pfile$ 'f'
$	read/end=ploop pfile$ pline	!empty is ok
$	close pfile$
$	pfield = f$element(0," ",pline)	!1st field is version number
$	if f$locate(".",pfield).lt.f$length(pfield) then  goto ploop	!keep
$prej:	rename/new_vers 'f' *.old	!reject old version
$pmake:	create/fdl=sys$input:/owner='gameuic' 'f'/log
file
 organization sequential
 protection (system:rwd,owner:rwd,group:rw,world:rw)
record
 format stream_lf
$	goto ploop
$pdone:
$ if p3.nes."" then  exit
$!
$! copy over the remaining game files, then make them readonly
$make_readonly_files:
$	milestone "(readonly files)"
$ if f$search("[.dat]''data_libry'").nes.""
$ then	call copyfiles 'f$string(data_libry+","+xtrn_files)' [.dat] "r"
$ else	!'dlb_files' is too long for a single command
$	k = 200 + f$locate(",",f$extract(200,999,dlb_files))
$	call copyfiles 'f$extract(0,k,dlb_files)' [.dat] "r"
$	call copyfiles 'f$extract(k+1,999,dlb_files)' [.dat] "r"
$ endif
$ if p3.nes."" then  exit
$!
$make_executable:
$	milestone "(nethack.exe)"
$ call copy_file [.src]nethack.exe 'gamedir'nethack.exe "re"
$ if p3.nes."" then  exit
$!
$! provide invocation procedure (if available)
$make_procedure:
$ if f$search(invoc_proc).eqs."" then  goto skip_dcl
$ if f$search("''gamedir'nethack.com").nes."" then -
    if f$cvtime(f$file_attr("''gamedir'nethack.com","RDT")) -
      .ges. f$cvtime(f$file_attr(invoc_proc,"RDT")) then  goto skip_dcl
$	milestone "(nethack.com)"
$ call copy_file 'invoc_proc' 'gamedir'nethack.com "re"
$skip_dcl:
$ if p3.nes."" then  exit
$!
$! provide plain-text Guidebook doc file (if available)
$make_documentation:
$ if f$search(guidebook).eqs."" then  goto skip_doc
$	milestone "(Guidebook)"
$ call copy_file 'guidebook' 'gamedir'Guidebook.doc "r"
$skip_doc:
$ if p3.nes."" then  exit
$!
$! provide last-resort termcap file (if available)
$make_termcap:
$ if f$search(trmcp_file).eqs."" then  goto skip_termcap
$ if f$search("''gamedir'termcap").nes."" then  goto skip_termcap
$	milestone "(termcap)"
$ call copy_file 'trmcp_file' 'gamedir'termcap "r"
$skip_termcap:
$ if p3.nes."" then  exit
$!
$! done
$	milestone "<done>"
$ define/nolog nethackdir 'gamedir'
$ define/nolog hackdir 'gamedir'
$ echo -
    f$fao("!/ Nethack installation complete. !/ Playground is !AS !/",gamedir)
$ exit
$
$!
$! copy one file, resetting the protection on an earlier version first
$copy_file: subroutine
$ if f$search(p2).nes."" then  set file/Prot=(s:rwed,o:rwed) 'p2'
$ copy/Prot=(s:'p3'wd,o:'p3'wd,g:'p3',w:'p3') 'p1' 'p2'
$ set file/Owner='gameuic'/Prot=(s:'p3',o:'p3') 'p2'
$endsubroutine !copy_file
$
$!
$! copy a comma-separated list of wildcarded files, one file at a time
$copyfiles: subroutine
$ i = 0
$lloop:
$   g = f$element(i,",",p1)
$   if g.eqs."," then  goto ldone
$   g = p2 + g
$   wild = f$locate("*",g).ne.f$locate("%",g)
$   fcnt = 0
$eloop:
$	f = f$search(g)
$	if f.eqs."" then  goto edone
$	fcnt = fcnt + 1
$	f = f - f$parse(f,,,"VERSION")
$	e = f$parse(f,,,"NAME") + f$parse(f,,,"TYPE")
$	call copy_file 'f' 'gamedir''e' "''p3'"
$	if wild then  goto eloop
$edone:
$   if fcnt.eq.0 then  warn "? no file(s) found for """,g,""""
$   i = i + 1
$   goto lloop
$ldone:
$endsubroutine !copyfiles
$
$!<eof>