1
$! Compare_gawk_source.com
3
$! This procedure compares the files in two directories and reports the
6
$! It needs to be customized to the local site directories.
8
$! This is used by me for these purposes:
9
$! 1. Compare the original source of a project with an existing
11
$! 2. Compare the checked out repository of a project with the
12
$! the local working copy to make sure they are in sync.
13
$! 3. Keep a copy directory up to date. The third is needed by
14
$! me because VMS Backup can create a saveset of files from a
15
$! NFS mounted volume.
17
$! First the files in the original source directory which is assumed to be
18
$! under source codde control are compared with the copy directory.
20
$! Then the files are are only in the copy directory are listed.
22
$! The result will five diagnostics about of files:
23
$! 1. Files that are not generation 1.
24
$! 2. Files missing in the copy directory.
25
$! 3. Files in the copy directory not in the source directory.
26
$! 4. Files different from the source directory.
27
$! 5. Files that VMS DIFF can not process.
29
$! This needs to be run on an ODS-5 volume.
31
$! If UPDATE is given as a second parameter, files missing or different in the
32
$! copy directory will be updated.
35
$! The source directory is source_root:[gawk.reference.gawk],
36
$! the logical used on my system for the GNV Mecurial repository checkout.
37
$! If source_root: is not defined, then src_root:[gawk] will be
38
$! translated to something like DISK:[dir.gawk.reference.gawk]
39
$! and then DISK:[dir.gawk.vms_source.gawk] will be used.
41
$! The copy directory is vms_root:[gawk]
42
$! The UPDATE parameter is ignored.
44
$! This setting is used to make sure that the working vms directory
45
$! and the VMS specific repository checkout directory have the same
46
$! contents if they are different.
48
$! If P1 is "SRCBCK" then this
49
$! The source directory tree is: src_root:[gawk]
50
$! The copy directory is src_root1:[gawk]
52
$! src_root1:[gawk] is used by me to work around that VMS backup will
53
$! not use NFS as a source directory so I need to make a copy.
55
$! This is to make sure that the backup save set for the unmodified
56
$! source is up to date.
58
$! If your repository checkout is not on an NFS mounted volume, you do not
59
$! need to use this option or have the logical name src_root1 defined.
61
$! If P1 is "VMSBCK" then this changes the two directories:
62
$! The source directory is vms_root:[gawk]
63
$! The copy directory is vms_root1:[gawk]
66
$! src_root1:[gawk] is used by me to work around that VMS backup will
67
$! not use NFS as a source directory so I need to make a copy.
69
$! This is to make sure that the backup save set for the unmodified
70
$! source is up to date.
72
$! If your repository checkout is not on an NFS mounted volume, you do not
73
$! need to use this option or have the logical name src_root1 defined.
75
$! 02-Jan-2014 J. Malmberg
76
$!==========================================================================
78
$! Update missing/changed files.
80
$if (p2 .eqs. "UPDATE")
85
$myproc = f$environment("PROCEDURE")
86
$myprocdir = f$parse(myproc,,,"DIRECTORY") - "[" - "]" - "<" - ">"
87
$myprocdir = f$edit(myprocdir, "LOWERCASE")
88
$mydefault = f$environment("DEFAULT")
89
$mydir = f$parse(mydefault,,,"DIRECTORY")
90
$mydir = f$edit(mydir, "LOWERCASE")
91
$odelim = f$extract(0, 1, mydir)
92
$mydir = mydir - "[" - "]" - "<" - ">"
93
$mydev = f$parse(mydefault,,,"DEVICE")
98
$ ref_base_dir = myprocdir - ".vms"
99
$ wrk_base_dir = mydir
101
$ resultd = f$parse("src_root:",,,,"NO_CONCEAL")
102
$ resultd = f$edit(resultd, "LOWERCASE")
103
$ resultd = resultd - "][" - "><" - ".;" - ".."
104
$ resultd_len = f$length(resultd) - 1
105
$ delim = f$extract(resultd_len, 1, resultd)
106
$ ref_root_base = mydir + delim
107
$ if f$locate(".reference.", resultd) .lt. resultd_len
109
$ resultd = resultd - ref_root_base - "reference." + "vms_source."
111
$ resultd = resultd - ref_root_base - "gnu." + "gnu_vms."
113
$ ref = resultd + ref_base_dir
114
$ wrk = "VMS_ROOT:" + odelim + wrk_base_dir
115
$ resultd_len = f$length(resultd) - 1
116
$ resultd = f$extract(0, resultd_len, resultd) + delim
117
$ ref_root_dir = f$parse(resultd,,,"DIRECTORY")
118
$ ref_root_dir = f$edit(ref_root_dir, "LOWERCASE")
119
$ ref_root_dir = ref_root_dir - "[" - "]"
120
$ ref_base_dir = ref_root_dir + "." + ref_base_dir
123
$if p1 .eqs. "SRCBCK"
125
$ ref_base_dir = "gawk"
126
$ wrk_base_dir = "gawk"
127
$ ref = "src_root:[" + ref_base_dir
128
$ wrk = "src_root1:[" + wrk_base_dir
131
$ if f$search("src_root1:[000000]gawk.dir") .eqs. ""
133
$ create/dir/prot=o:rwed src_root1:[gawk]
139
$if p1 .eqs. "VMSBCK"
141
$ ref_base_dir = "gawk"
142
$ wrk_base_dir = "gawk"
143
$ ref = "vms_root:[" + ref_base_dir
144
$ wrk = "vms_root1:[" + wrk_base_dir
147
$ if f$search("vms_root1:[000000]gawk.dir") .eqs. ""
149
$ create/dir/prot=o:rwed vms_root1:[gawk]
157
$ write sys$output "Unknown compare type specified!"
163
$! Future - check the device types involved for the
164
$! the syntax to check.
169
$vax = f$getsyi("HW_MODEL") .lt. 1024
177
$if .not. ODS2_SYNTAX
179
$ set proc/parse=extended
183
$ ref_spec = f$search("''ref'...]*.*;",1)
184
$ if ref_spec .eqs. "" then goto loop_end
186
$ ref_dev = f$parse(ref_spec,,,"DEVICE")
187
$ ref_dir = f$parse(ref_spec,,,"DIRECTORY")
188
$ ref_dir = f$edit(ref_dir, "LOWERCASE")
189
$ ref_name = f$parse(ref_spec,,,"NAME")
190
$ ref_type = f$parse(ref_spec,,,"TYPE")
193
$ if f$locate(".CVS]", ref_dir) .lt. f$length(ref_dir) then goto loop
194
$ if f$locate(".cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
195
$ if f$locate(".$cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
196
$ if f$locate(".^.git", ref_dir) .lt. f$length(ref_dir) then goto loop
197
$ if f$locate(".$5ngit", ref_dir) .lt. f$length(ref_dir) then goto loop
199
$ rel_path = ref_dir - "[" - ref_base_dir
200
$! rel_path_len = f$length(rel_path) - 1
201
$! delim = f$extract(rel_path_len, 1, rel_path)
202
$! rel_path = rel_path - ".]" - ".>" - "]" - ">"
203
$! rel_path = rel_path + delim
209
$ wrk_path = wrk + rel_path
211
$ ref_name_type = ref_name + ref_type
213
$ if ref_name_type .eqs. "CVS.DIR" then goto loop
214
$ if ref_name_type .eqs. "cvs.dir" then goto loop
215
$ if ref_name_type .eqs. "$CVS.DIR" then goto loop
216
$ if ref_name_type .eqs. "^.git.DIR" then goto loop
217
$ if ref_name_type .eqs. "$5ngit.DIR" then goto loop
218
$ if ref_name_type .eqs. "$5NGIT.DIR" then goto loop
224
$ wrk_spec = wrk_path + ref_name_type
227
$ wrk_chk = f$search(wrk_spec, 0)
228
$ if wrk_chk .eqs. ""
232
$ write sys$output "''wrk_spec' is missing"
236
$ copy/log 'ref_spec' 'wrk_spec'
241
$ wrk_name = f$parse(wrk_spec,,,"NAME")
242
$ wrk_type = f$parse(wrk_spec,,,"TYPE")
243
$ wrk_fname = wrk_name + wrk_type"
244
$ ref_fname = ref_name + ref_type
246
$ if ref_fname .nes. wrk_fname
248
$ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
251
$ ref_type = f$edit(ref_type, "UPCASE")
252
$ if ref_type .eqs. ".DIR" then goto loop
256
$ ref_fname = f$edit(ref_fname, "LOWERCASE")
259
$! These files have records to long to diff, and we don't change them anyway.
261
$ if ref_type .eqs. ".GMO" then ref_skip = 1
262
$ if ref_type .eqs. ".PDF" then ref_skip = 1
263
$ if ref_type .eqs. ".PNG" then ref_skip = 1
264
$ if ref_type .eqs. ".JPG" then ref_skip = 1
265
$ if ref_fname .eqs. "inftest.ok" then ref_skip = 1
266
$ if ref_fname .eqs. "longsub.in" then ref_skip = 1
267
$ if ref_fname .eqs. "longsub.ok" then ref_skip = 1
268
$ if ref_fname .eqs. "nasty2.ok" then ref_skip = 1
269
$ if ref_fname .eqs. "profile5.awk" then ref_skip = 1
270
$ if ref_fname .eqs. "profile5.ok" then ref_skip = 1
271
$ if ref_fname .eqs. "po.m4" then ref_skip = 1
278
$ write sys$output "Skipping diff of ''ref_fname'"
284
$ wrk_ver = f$parse(wrk_chk,,,"VERSION")
285
$ if wrk_ver .nes. ";1"
287
$ write sys$output "Version for ''wrk_spec' is not 1"
290
$ diff/out=nl: 'wrk_spec' 'ref_spec'
291
$ if $severity .nes. "1"
293
$ write sys$output "''wrk_spec' is different from ''ref_spec'"
296
$ delete 'wrk_spec';*
297
$ copy/log 'ref_spec' 'wrk_spec'
308
$! For missing loop, check the latest generation.
309
$ ref_spec = f$search("''wrk'...]*.*;")
310
$ if ref_spec .eqs. "" then goto missing_loop_end
312
$ ref_dev = f$parse(ref_spec,,,"DEVICE")
313
$ ref_dir = f$parse(ref_spec,,,"DIRECTORY")
314
$ ref_dir = f$edit(ref_dir, "LOWERCASE")
315
$ ref_name = f$parse(ref_spec,,,"NAME")
316
$ ref_type = f$parse(ref_spec,,,"TYPE")
318
$ rel_path = ref_dir - "[" - wrk_base_dir
321
$ wrk_path = ref + rel_path
322
$ wrk_spec = wrk_path + ref_name + ref_type
323
$ wrk_name = f$parse(wrk_spec,,,"NAME")
324
$ wrk_type = f$parse(wrk_spec,,,"TYPE")
326
$ wrk_fname = wrk_name + wrk_type"
327
$ ref_fname = ref_name + ref_type
330
$ ref_utype = f$edit(ref_type,"UPCASE")
331
$ ref_ufname = f$edit(ref_fname,"UPCASE")
336
$ wrk_chk = f$search(wrk_spec, 0)
337
$ if wrk_chk .eqs. ""
341
$ write sys$output "''wrk_spec' is missing"
349
$ if ref_fname .nes. wrk_fname
351
$ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
354
$ if ref_utype .eqs. ".DIR" then goto missing_loop
356
$ wrk_ver = f$parse(wrk_chk,,,"VERSION")
357
$ if wrk_ver .nes. ";1"
359
$ write sys$output "Version for ''wrk_spec' is not 1"