1$! File: Build_GNV_CURL_PCSI_DESC.COM
2$!
3$! $Id$
4$!
5$! Build the *.pcsi$text file in the following sections:
6$!   Required software dependencies.
7$!   install/upgrade/postinstall steps.
8$!      1. Duplicate filenames need an alias procedure. (N/A for curl)
9$!      2. ODS-5 filenames need an alias procedure. (N/A for curl)
10$!      3. Special alias links for executables (curl. -> curl.exe)
11$!         if a lot, then an alias procedure is needed.
12$!      4. Rename the files to lowercase.
13$!   Move Release Notes to destination
14$!   Source kit option
15$!   Create directory lines
16$!   Add file lines for curl.
17$!   Add Link alias procedure file (N/A for curl)
18$!   Add [.SYS$STARTUP]curl_startup file
19$!   Add Release notes file.
20$!
21$! The file PCSI_GNV_CURL_FILE_LIST.TXT is read in to get the files other
22$! than the release notes file and the source backup file.
23$!
24$! The PCSI system can really only handle ODS-2 format filenames and
25$! assumes that there is only one source directory.  It also assumes that
26$! all destination files with the same name come from the same source file.
27$! Fortunately CURL does not trip most of these issues, so those steps
28$! above are marked N/A.
29$!
30$! A rename action section is needed to make sure that the files are
31$! created in the GNV$GNU: in the correct case, and to create the alias
32$! link [usr.bin]curl. for [usr.bin]curl.exe.
33$!
34$! Copyright 2009, John Malmberg
35$!
36$! Permission to use, copy, modify, and/or distribute this software for any
37$! purpose with or without fee is hereby granted, provided that the above
38$! copyright notice and this permission notice appear in all copies.
39$!
40$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
41$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
42$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
43$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
44$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
45$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
46$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
47$!
48$!
49$! 15-Jun-2009  J. Malmberg
50$!
51$!===========================================================================
52$!
53$ kit_name = f$trnlnm("GNV_PCSI_KITNAME")
54$ if kit_name .eqs. ""
55$ then
56$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
57$   goto all_exit
58$ endif
59$ producer = f$trnlnm("GNV_PCSI_PRODUCER")
60$ if producer .eqs. ""
61$ then
62$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
63$   goto all_exit
64$ endif
65$ filename_base = f$trnlnm("GNV_PCSI_FILENAME_BASE")
66$ if filename_base .eqs. ""
67$ then
68$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
69$   goto all_exit
70$ endif
71$!
72$!
73$! Parse the kit name into components.
74$!---------------------------------------
75$ producer = f$element(0, "-", kit_name)
76$ base = f$element(1, "-", kit_name)
77$ product = f$element(2, "-", kit_name)
78$ mmversion = f$element(3, "-", kit_name)
79$ majorver = f$extract(0, 3, mmversion)
80$ minorver = f$extract(3, 2, mmversion)
81$ updatepatch = f$element(4, "-", kit_name)
82$ if updatepatch .eqs. "-" then updatepatch = ""
83$!
84$! kit type of "D" means a daily build
85$ kit_type = f$edit(f$extract(0, 1, majorver), "upcase")
86$!
87$!
88$ product_line = "product ''producer' ''base' ''product'"
89$ if updatepatch .eqs. ""
90$ then
91$     product_name = " ''majorver'.''minorver'"
92$ else
93$     product_name = " ''majorver'.''minorver'-''updatepatch'"
94$ endif
95$ product_line = product_line + " ''product_name' full;"
96$!write sys$output product_line
97$!
98$!
99$!
100$! Create the file as a VMS text file.
101$!----------------------------------------
102$ base_file = kit_name
103$ create 'base_file'.pcsi$desc
104$!
105$!
106$! Start building file.
107$!----------------------
108$ open/append pdsc 'base_file'.pcsi$desc
109$!
110$ write pdsc product_line
111$!
112$! Required product dependencies.
113$!----------------------------------
114$ vmsprd = "DEC"
115$ if base .eqs. "I64VMS" then vmsprd = "HP"
116$!
117$ write pdsc "   software ''vmsprd' ''base' VMS ;"
118$ arch_type = f$getsyi("ARCH_NAME")
119$ node_swvers = f$getsyi("node_swvers")
120$ vernum = f$extract(1, f$length(node_swvers), node_swvers)
121$ majver = f$element(0, ".", vernum)
122$ minverdash = f$element(1, ".", vernum)
123$ minver = f$element(0, "-", minverdash)
124$ dashver = f$element(1, "-", minverdash)
125$ if dashver .eqs. "-" then dashver = ""
126$ vmstag = majver + minver + dashver
127$ code = f$extract(0, 1, arch_type)
128$ arch_code = f$extract(0, 1, arch_type)
129$ write pdsc -
130 "   if (not <software ''vmsprd' ''base' VMS version minimum ''node_swvers'>) ;"
131$ write pdsc "      error NEED_VMS''vmstag';"
132$ write pdsc "   end if;"
133$!
134$write pdsc "   software VMSPORTS ''base' ZLIB ;"
135$write pdsc -
136    "   if (not <software VMSPORTS ''base' ZLIB version minimum V1.2-8>) ;"
137$write pdsc "      error NEED_ZLIB;"
138$write pdsc "   end if;"
139$!
140$!
141$!
142$! install/upgrade/postinstall steps.
143$!-----------------------------------
144$!      1. Duplicate filenames need an alias procedure. (N/A for curl)
145$!      2. ODS-5 filenames need an alias procedure. (N/A for curl)
146$!      3. Special alias links for executables (curl. -> curl.exe)
147$!         if a lot, then an alias procedure is needed.
148$!      4. Rename the files to lowercase.
149$!
150$!
151$!   Alias links needed.
152$!-------------------------
153$ add_alias_lines = ""
154$ rem_alias_lines = ""
155$ line_out = ""
156$!
157$!   Read through the file list to set up aliases and rename commands.
158$!---------------------------------------------------------------------
159$ open/read flst pcsi_gnv_curl_file_list.txt
160$!
161$inst_alias_loop:
162$   read/end=inst_alias_loop_end flst line_in
163$   line_in = f$edit(line_in,"compress,trim,uncomment")
164$   if line_in .eqs. "" then goto inst_alias_loop
165$   pathname = f$element(0, " ", line_in)
166$   linkflag = f$element(1, " ", line_in)
167
168$   if linkflag .nes. "->" then goto inst_alias_write
169$!
170$   linktarget = f$element(2, " ", line_in)
171$   if kit_type .eqs. "D"
172$   then
173$       old_start = f$locate("[gnv.usr", pathname)
174$       if old_start .lt. f$length(pathname)
175$       then
176$           pathname = "[gnv.beta" + pathname - "[gnv.usr"
177$           linktarget = "[gnv.beta" + linktarget - "[gnv.usr"
178$       endif
179$   endif
180$   nlink = "pcsi$destination:" + pathname
181$   ntarg = "pcsi$destination:" + linktarget
182$   new_add_alias_line = -
183  """if f$search(""""''nlink'"""") .eqs. """""""" then" + -
184  " set file/enter=''nlink' ''ntarg'"""
185$   if add_alias_lines .nes. ""
186$   then
187$       add_alias_lines = add_alias_lines + "," + new_add_alias_line
188$   else
189$       add_alias_lines = new_add_alias_line
190$   endif
191$!
192$   new_rem_alias_line = -
193  """if f$search(""""''nlink'"""") .nes. """""""" then" + -
194  " set file/remove ''nlink';"""
195$   if rem_alias_lines .nes. ""
196$   then
197$      rem_alias_lines = rem_alias_lines + "," + new_rem_alias_line
198$   else
199$      rem_alias_lines = new_rem_alias_line
200$   endif
201$!
202$   goto inst_alias_loop
203$!
204$inst_alias_write:
205$!
206$!  execute install / remove
207$   write pdsc "   execute install ("
208$! add aliases
209$   i = 0
210$ex_ins_loop:
211$       line = f$element(i, ",", add_alias_lines)
212$       i = i + 1
213$       if line .eqs. "" then goto ex_ins_loop
214$       if line .eqs. "," then goto ex_ins_loop_end
215$       if line_out .nes. "" then write pdsc line_out,","
216$       line_out = line
217$       goto ex_ins_loop
218$ex_ins_loop_end:
219$   write pdsc line_out
220$   line_out = ""
221$   write pdsc "      )"
222$   write pdsc "   remove ("
223$! remove aliases
224$   i = 0
225$ex_rem_loop:
226$       line = f$element(i, ",", rem_alias_lines)
227$       i = i + 1
228$       if line .eqs. "" then goto ex_rem_loop
229$       if line .eqs. "," then goto ex_rem_loop_end
230$       if line_out .nes. "" then write pdsc line_out,","
231$       line_out = line
232$       goto ex_rem_loop
233$ex_rem_loop_end:
234$   write pdsc line_out
235$   line_out = ""
236$   write pdsc "      ) ;"
237$!
238$!  execute upgrade
239$   write pdsc "   execute upgrade ("
240$   i = 0
241$ex_upg_loop:
242$       line = f$element(i, ",", rem_alias_lines)
243$       i = i + 1
244$       if line .eqs. "" then goto ex_upg_loop
245$       if line .eqs. "," then goto ex_upg_loop_end
246$       if line_out .nes. "" then write pdsc line_out,","
247$       line_out = line
248$       goto ex_upg_loop
249$ex_upg_loop_end:
250$   write pdsc line_out
251$   line_out = ""
252$! remove aliases
253$   write pdsc "      ) ;"
254$!
255$!  execute postinstall
256$   write pdsc "   execute postinstall ("
257$   if arch_code .nes. "V"
258$   then
259$       line_out = "   ""set process/parse=extended"""
260$   endif
261$   i = 0
262$ex_pins_loop:
263$       line = f$element(i, ",", add_alias_lines)
264$       i = i + 1
265$       if line .eqs. "" then goto ex_pins_loop
266$       if line .eqs. "," then goto ex_pins_loop_end
267$       if line_out .nes. "" then write pdsc line_out,","
268$       line_out = line
269$       goto ex_pins_loop
270$ex_pins_loop_end:
271$   if line_out .eqs. "" then line_out = "   ""continue"""
272$!   write pdsc line_out
273$!   line_out = ""
274$! add aliases and follow with renames.
275$!
276$goto inst_dir
277$!
278$inst_dir_loop:
279$   read/end=inst_alias_loop_end flst line_in
280$   line_in = f$edit(line_in,"compress,trim,uncomment")
281$   if line_in .eqs. "" then goto inst_dir_loop
282$inst_dir:
283$   pathname = f$element(0, " ", line_in)
284$   if kit_type .eqs. "D"
285$   then
286$       if pathname .eqs. "[gnv]usr.dir"
287$       then
288$           pathname = "[gnv]beta.dir"
289$       else
290$           old_start = f$locate("[gnv.usr", pathname)
291$           if old_start .lt. f$length(pathname)
292$           then
293$               pathname = "[gnv.beta" + pathname - "[gnv.usr"
294$           endif
295$       endif
296$   endif
297$!
298$!  Ignore the directory entries for now.
299$!-----------------------------------------
300$   filedir = f$parse(pathname,,,"DIRECTORY")
301$   if pathname .eqs. filedir then goto inst_dir_loop
302$!
303$!  process .dir extensions for rename
304$!  If this is not a directory then start processing files.
305$!-------------------------
306$   filetype = f$parse(pathname,,,"TYPE")
307$   filetype_u = f$edit(filetype, "upcase")
308$   filename = f$parse(pathname,,,"NAME")
309$   if filetype_u .nes. ".DIR" then goto inst_file
310$!
311$!  process directory lines for rename.
312$!--------------------------------------
313$   if line_out .nes. ""
314$   then
315$       write pdsc line_out,","
316$       line_out = ""
317$   endif
318$   if arch_code .nes. "V"
319$   then
320$       if line_out .nes. "" then write pdsc line_out,","
321$       line_out = "   ""rename pcsi$destination:''pathname' ''filename'.DIR"""
322$   else
323$       if line_out .nes. "" then write pdsc line_out
324$       line_out = ""
325$   endif
326$   goto inst_dir_loop
327$!
328$!
329$!   process file lines for rename
330$!---------------------------------
331$inst_file_loop:
332$   read/end=inst_alias_loop_end flst line_in
333$   line_in = f$edit(line_in,"compress,trim,uncomment")
334$   if line_in .eqs. "" then goto inst_dir_loop
335$   pathname = f$element(0, " ", line_in)
336$   if kit_type .eqs. "D"
337$   then
338$       if pathname .eqs. "[gnv]usr.dir"
339$       then
340$           pathname = "[gnv]beta.dir"
341$       else
342$           old_start = f$locate("[gnv.usr", pathname)
343$           if old_start .lt. f$length(pathname)
344$           then
345$               pathname = "[gnv.beta" + pathname - "[gnv.usr"
346$           endif
347$       endif
348$   endif
349$!
350$!  Filenames with $ in them are VMS special and do not need to be lowercased.
351$!  --------------------------------------------------------------------------
352$   if f$locate("$", pathname) .lt. f$length(pathname) then goto inst_file_loop
353$!
354$   filetype = f$parse(pathname,,,"TYPE")
355$   filename = f$parse(pathname,,,"NAME") + filetype
356$inst_file:
357$   if arch_code .nes. "V"
358$   then
359$       if line_out .nes. "" then write pdsc line_out,","
360$       filetype = f$parse(pathname,,,"TYPE")
361$       filename = f$parse(pathname,,,"NAME") + filetype
362$       line_out = "   ""rename pcsi$destination:''pathname' ''filename'"""
363$   else
364$       if line_out .nes. "" then write pdsc line_out
365$       line_out = ""
366$   endif
367$   goto inst_file_loop
368$!
369$inst_alias_loop_end:
370$!
371$write pdsc line_out
372$write pdsc "        ) ;"
373$close flst
374$!
375$!   Move Release Notes to destination
376$!-------------------------------------
377$write pdsc "   information RELEASE_NOTES phase after ;"
378$!
379$!   Source kit option
380$!---------------------
381$write pdsc "   option SOURCE default 0;"
382$write pdsc "   directory ""[gnv.common_src]"" PROTECTION PUBLIC ;"
383$write pdsc -
384    "        file ""[gnv.common_src]''filename_base'_original_src.bck"""
385$write pdsc -
386    "          source [common_src]''filename_base'_original_src.bck ;"
387$if f$search("gnv$gnu:[vms_src]''filename_base'_vms_src.bck") .nes. ""
388$then
389$    write pdsc "   directory ""[gnv.vms_src]"" PROTECTION PUBLIC ;"
390$    write pdsc "        file ""[gnv.vms_src]''filename_base'_vms_src.bck"""
391$    write pdsc "          source [vms_src]''filename_base'_vms_src.bck ;"
392$endif
393$write pdsc "   end option;"
394$!
395$!
396$! Read through the file list again.
397$!----------------------------------
398$open/read flst pcsi_gnv_curl_file_list.txt
399$!
400$!
401$!   Create directory lines
402$!-------------------------
403$flst_dir_loop:
404$   read/end=flst_loop_end flst line_in
405$   line_in = f$edit(line_in,"compress,trim,uncomment")
406$   if line_in .eqs. "" then goto flst_dir_loop
407$!
408$   filename = f$element(0, " ", line_in)
409$   linkflag = f$element(1, " ", line_in)
410$   if linkflag .eqs. "->" then goto flst_dir_loop
411$!
412$!  Ignore .dir extensions
413$!-------------------------
414$   filetype = f$edit(f$parse(filename,,,"TYPE"), "upcase")
415$   if filetype .eqs. ".DIR" then goto flst_dir_loop
416$!
417$   destname = filename
418$   if kit_type .eqs. "D"
419$   then
420$       old_start = f$locate("[gnv.usr", destname)
421$       if old_start .lt. f$length(destname)
422$       then
423$           destname = "[gnv.beta" + destname - "[gnv.usr"
424$       endif
425$   endif
426$!
427$!  It should be just a directory then.
428$!-------------------------------------
429$   filedir = f$edit(f$parse(filename,,,"DIRECTORY"), "lowercase")
430$!  If this is not a directory then start processing files.
431$!---------------------------------------------------------
432$   if filename .nes. filedir then goto flst_file
433$!
434$   write pdsc "   directory ""''destname'"" PROTECTION PUBLIC ;"
435$   goto flst_dir_loop
436$!
437$!
438$!   Add file lines for curl.
439$!---------------------------
440$flst_file_loop:
441$   read/end=flst_loop_end flst line_in
442$   line_in = f$edit(line_in,"compress,trim,uncomment")
443$   if line_in .eqs. "" then goto inst_file_loop
444$   filename = f$element(0, " ", line_in)
445$   destname = filename
446$   if kit_type .eqs. "D"
447$   then
448$       old_start = f$locate("[gnv.usr", destname)
449$       if old_start .lt. f$length(destname)
450$       then
451$           destname = "[gnv.beta" + destname - "[gnv.usr"
452$       endif
453$   endif
454$flst_file:
455$   srcfile = filename - "gnv."
456$   write pdsc "   file ""''destname'"" "
457$   write pdsc "     source ""''srcfile'"" ;"
458$   goto flst_file_loop
459$!
460$flst_loop_end:
461$ close flst
462$!
463$!   Add Link alias procedure file (N/A for curl)
464$!------------------------------------------------
465$!
466$!   Add [.SYS$STARTUP]curl_startup file
467$!---------------------------------------
468$ if kit_type .eqs. "D"
469$ then
470$   write pdsc "   file ""[sys$startup]curl_daily_startup.com"""
471$ else
472$   write pdsc "   file ""[sys$startup]curl_startup.com"""
473$ endif
474$ write pdsc "     source [usr.lib]curl_startup.com ;"
475$!
476$!   Add Release notes file.
477$!------------------------------
478$ write pdsc -
479    "   file ""[SYSHLP]''filename_base'.release_notes"" release notes ;"
480$!
481$! Close the product file
482$!------------------------
483$ write pdsc "end product;"
484$!
485$close pdsc
486$!
487$all_exit:
488$ exit
489