aboutsummaryrefslogtreecommitdiff
path: root/packages/vms/compare_curl_source.com
blob: a720afc63047985c29a4c96133a4eb9d61943264 (plain)
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
$! Compare_curl_source.com
$!
$! $Id$
$!
$! This procedure compares the files in two directories and reports the
$! differences.  It is customized for the vmsports repository layout.
$!
$! It needs to be customized to the local site directories.
$!
$! This is used by me for these purposes:
$!     1. Compare the original source of a project with an existing
$!        VMS port.
$!     2. Compare the checked out repository of a project with the
$!        the local working copy to make sure they are in sync.
$!     3. Keep a copy directory up to date.  The third is needed by
$!        me because VMS Backup can create a saveset of files from a
$!        NFS mounted volume.
$!
$! First the files in the original source directory which is assumed to be
$! under source code control are compared with the copy directory.
$!
$! Then the files are are only in the copy directory are listed.
$!
$! The result will five diagnostics about of files:
$!    1. Files that are not generation 1.
$!    2. Files missing in the copy directory.
$!    3. Files in the copy directory not in the source directory.
$!    4. Files different from the source directory.
$!    5. Files that VMS DIFF can not process.
$!
$! This needs to be run on an ODS-5 volume.
$!
$! If UPDATE is given as a second parameter, files missing or different in the
$! copy directory will be updated.
$!
$! By default:
$!    The directory src_root:[project_name] will be translated to something like
$!    DISK:[dir.dir.reference.project_name] and this will be used
$!    to calculate DISK:[dir.dir.vms_source.project_name] for the VMS specific
$!    source directory.
$!
$!    The copy directory is vms_root:[project_name]
$!    The UPDATE parameter is ignored.
$!
$!    This setting is used to make sure that the working vms directory
$!    and the repository checkout directory have the same contents.
$!
$! If P1 is "SRCBCK" then this
$!     The source directory tree is: src_root:[project_name]
$!     The copy directory is src_root1:[project_name]
$!
$!   src_root1:[project_name] is used by me to work around that VMS backup will
$!   not use NFS as a source directory so I need to make a copy.
$!
$!   This is to make sure that the backup save set for the unmodified
$!   source is up to date.
$!
$!   If your repository checkout is not on an NFS mounted volume, you do not
$!   need to use this option or have the logical name src_root1 defined.
$!
$! If P1 is "VMSBCK" then this changes the two directories:
$!    The source directory is vms_root:[project_name]
$!    The copy directory is vms_root1:[project_name]
$!
$!   vms_root:[project_name] is where I do the VMS specific edits.
$!   vms_root1:[project_name] is used by me to work around that VMS backup will
$!   not use NFS as a source directory so I need to make a copy.
$!
$!   This is to make sure that the backup save set for the unmodified
$!   source is up to date.
$!
$! Copyright 2011 - 2020, John Malmberg
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
$! copyright notice and this permission notice appear in all copies.
$!
$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
$!
$! 18-Aug-2011  J. Malmberg
$!==========================================================================
$!
$! Update missing/changed files.
$ update_file = 0
$ if (p2 .eqs. "UPDATE")
$ then
$   update_file = 1
$ endif
$!
$ myproc = f$environment("PROCEDURE")
$ myprocdir = f$parse(myproc,,,"DIRECTORY") - "[" - "]" - "<" - ">"
$ myprocdir = f$edit(myprocdir, "LOWERCASE")
$ mydefault = f$environment("DEFAULT")
$ mydir = f$parse(mydefault,,,"DIRECTORY")
$ mydir = f$edit(mydir, "LOWERCASE")
$ odelim = f$extract(0, 1, mydir)
$ mydir = mydir - "[" - "]" - "<" - ">"
$ mydev = f$parse(mydefault,,,"DEVICE")
$!
$ ref = ""
$ if P1 .eqs. ""
$ then
$   ref_base_dir = myprocdir
$   wrk_base_dir = mydir
$   update_file = 0
$   resultd = f$parse("src_root:",,,,"NO_CONCEAL")
$   resultd = f$edit(resultd, "LOWERCASE")
$   resultd = resultd - "][" - "><" - ".;" - ".."
$   resultd_len = f$length(resultd) - 1
$   delim = f$extract(resultd_len, 1, resultd)
$   ref_root_base = mydir + delim
$   resultd = resultd - ref_root_base - "reference." + "vms_source."
$   ref = resultd + ref_base_dir
$   wrk = "VMS_ROOT:" + odelim + wrk_base_dir
$   resultd_len = f$length(resultd) - 1
$   resultd = f$extract(0, resultd_len, resultd) + delim
$   ref_root_dir = f$parse(resultd,,,"DIRECTORY")
$   ref_root_dir = f$edit(ref_root_dir, "LOWERCASE")
$   ref_root_dir = ref_root_dir - "[" - "]"
$   ref_base_dir = ref_root_dir + "." + ref_base_dir
$ endif
$!
$ if p1 .eqs. "SRCBCK"
$ then
$   ref_base_dir = "curl"
$   wrk_base_dir = "curl"
$   ref = "src_root:[" + ref_base_dir
$   wrk = "src_root1:[" + wrk_base_dir
$   if update_file
$   then
$       if f$search("src_root1:[000000]curl.dir") .eqs. ""
$       then
$           create/dir/prot=o:rwed src_root1:[curl]
$       endif
$   endif
$ endif
$!
$!
$ if p1 .eqs. "VMSBCK"
$ then
$   ref_base_dir = "curl"
$   wrk_base_dir = "curl"
$   ref = "vms_root:[" + ref_base_dir
$   wrk = "vms_root1:[" + wrk_base_dir
$   if update_file
$   then
$       if f$search("vms_root1:[000000]curl.dir") .eqs. ""
$       then
$           create/dir/prot=o:rwed vms_root1:[curl]
$       endif
$   endif
$ endif
$!
$!
$ if ref .eqs. ""
$ then
$   write sys$output "Unknown compare type specified!"
$   exit 44
$ endif
$!
$!
$! Future - check the device types involved for the
$! the syntax to check.
$ ODS2_SYNTAX = 0
$ NFS_MANGLE = 0
$ PWRK_MANGLE = 0
$!
$ vax = f$getsyi("HW_MODEL") .lt. 1024
$ if vax
$ then
$   ODS2_SYNTAX = 1
$ endif
$!
$ report_missing = 1
$!
$ if .not. ODS2_SYNTAX
$ then
$   set proc/parse=extended
$ endif
$!
$loop:
$   ref_spec = f$search("''ref'...]*.*;",1)
$   if ref_spec .eqs. "" then goto loop_end
$!
$   ref_dev = f$parse(ref_spec,,,"DEVICE")
$   ref_dir = f$parse(ref_spec,,,"DIRECTORY")
$   ref_dir = f$edit(ref_dir, "LOWERCASE")
$   ref_name = f$parse(ref_spec,,,"NAME")
$   ref_type = f$parse(ref_spec,,,"TYPE")
$!
$!
$   rel_path = ref_dir - "[" - ref_base_dir
$!  rel_path_len = f$length(rel_path) - 1
$!  delim = f$extract(rel_path_len, 1, rel_path)
$!  rel_path = rel_path - ".]" - ".>" - "]" - ">"
$!  rel_path = rel_path + delim
$!
$   if ODS2_SYNTAX
$   then
$!       if rel_path .eqs. ".examples.scripts^.noah]"
$!       then
$!           rel_path = ".examples.scripts_noah]"
$!       endif
$!       if rel_path .eqs. ".examples.scripts^.v2]"
$!       then
$!           rel_path = ".examples.scripts_v2]"
$!       endif
$   endif
$!
$   wrk_path = wrk + rel_path
$!
$   ref_name_type = ref_name + ref_type
$!
$   if ODS2_SYNTAX
$   then
$   endif
$!
$   wrk_spec = wrk_path + ref_name_type
$!
$!
$   wrk_chk = f$search(wrk_spec, 0)
$   if wrk_chk .eqs. ""
$   then
$       if report_missing
$       then
$           write sys$output "''wrk_spec' is missing"
$        endif
$        if update_file
$        then
$            copy/log 'ref_spec' 'wrk_spec'
$        endif
$        goto loop
$   endif
$!
$   wrk_name = f$parse(wrk_spec,,,"NAME")
$   wrk_type = f$parse(wrk_spec,,,"TYPE")
$   wrk_fname = wrk_name + wrk_type"
$   ref_fname = ref_name + ref_type
$!
$   if ref_fname .nes. wrk_fname
$   then
$       write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
$   endif
$!
$   ref_type = f$edit(ref_type, "UPCASE")
$   if ref_type .eqs. ".DIR" then goto loop
$!
$   if ODS2_SYNTAX
$   then
$       ref_fname = f$edit(ref_fname, "LOWERCASE")
$   endif
$!
$!  These files are in the wrong format for VMS diff, and we don't change them.
$   ref_skip = 0
$   if ref_type .eqs. ".PDF" then ref_skip = 1
$   if ref_type .eqs. ".HTML" then ref_skip = 1
$   if ref_type .eqs. ".HQX" then ref_skip = 1
$   if ref_type .eqs. ".P12" then ref_skip = 1
$   if ref_type .eqs. "."
$   then
$       if f$locate("test", ref_fname) .eq. 0 then ref_skip = 1
$       if ref_fname .eqs. "configure." then ref_skip = 1
$   endif
$   if ref_fname .eqs. "MACINSTALL.TXT" then ref_skip = 1
$   if ref_fname .eqs. "$macinstall.txt" then ref_skip = 1
$   if ref_fname .eqs. "curl.mcp$5nxml$5nsit$5nhqx" then ref_skip = 1
$   if ref_fname .eqs. "curl_GUSIConfig.cpp" then ref_skip = 1
$   if ref_fname .eqs. "curl_$gusic$onfig.cpp" then ref_skip = 1
$   if ref_fname .eqs. "macos_main.cpp" then ref_skip = 1
$!
$!
$   if ref_skip .ne. 0
$   then
$      if report_missing
$      then
$          write sys$output "Skipping diff of ''ref_fname'"
$      endif
$      goto loop
$   endif
$!
$!
$   wrk_ver = f$parse(wrk_chk,,,"VERSION")
$   if wrk_ver .nes. ";1"
$   then
$       write sys$output "Version for ''wrk_spec' is not 1"
$   endif
$   set noon
$   diff/out=nl: 'wrk_spec' 'ref_spec'
$   if $severity .nes. "1"
$   then
$       write sys$output "''wrk_spec' is different from ''ref_spec'"
$       if update_file
$       then
$           delete 'wrk_spec';*
$           copy/log 'ref_spec' 'wrk_spec'
$       endif
$   endif
$   set on
$
$!
$   goto loop
$loop_end:
$!
$!
$missing_loop:
$!  For missing loop, check the latest generation.
$   ref_spec = f$search("''wrk'...]*.*;")
$   if ref_spec .eqs. "" then goto missing_loop_end
$!
$   ref_dev = f$parse(ref_spec,,,"DEVICE")
$   ref_dir = f$parse(ref_spec,,,"DIRECTORY")
$   ref_dir = f$edit(ref_dir, "LOWERCASE")
$   ref_name = f$parse(ref_spec,,,"NAME")
$   ref_type = f$parse(ref_spec,,,"TYPE")
$   ref_name_type = ref_name + ref_type
$!
$   rel_path = ref_dir - "[" - wrk_base_dir
$!
$!
$   wrk_path = ref + rel_path
$   wrk_spec = wrk_path + ref_name + ref_type
$   wrk_name = f$parse(wrk_spec,,,"NAME")
$   wrk_type = f$parse(wrk_spec,,,"TYPE")
$!
$   wrk_fname = wrk_name + wrk_type"
$   ref_fname = ref_name + ref_type
$!
$   wrk_skip = 0
$   ref_utype = f$edit(ref_type,"UPCASE")
$   ref_ufname = f$edit(ref_fname,"UPCASE")
$!
$   if wrk_skip .eq. 0
$   then
$       wrk_chk = f$search(wrk_spec, 0)
$       if wrk_chk .eqs. ""
$       then
$           if report_missing
$           then
$               write sys$output "''wrk_spec' is missing"
$           endif
$           goto missing_loop
$       endif
$   else
$       goto missing_loop
$   endif
$!
$   if ref_fname .nes. wrk_fname
$   then
$       write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
$   endif
$!
$   if ref_utype .eqs. ".DIR" then goto missing_loop
$!
$   wrk_ver = f$parse(wrk_chk,,,"VERSION")
$   if wrk_ver .nes. ";1"
$   then
$      write sys$output "Version for ''wrk_spec' is not 1"
$   endif
$!
$   goto missing_loop
$!
$!
$missing_loop_end:
$!
$exit