Debian Codegraph @

vms/compare_gawk_source.com

raw
1 $! Compare_gawk_source.com
2 $!
3 $! This procedure compares the files in two directories and reports the
4 $! differences.
5 $!
6 $! It needs to be customized to the local site directories.
7 $!
8 $! This is used by me for these purposes:
9 $! 1. Compare the original source of a project with an existing
10 $! VMS port.
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.
16 $!
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.
19 $!
20 $! Then the files are are only in the copy directory are listed.
21 $!
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.
28 $!
29 $! This needs to be run on an ODS-5 volume.
30 $!
31 $! If UPDATE is given as a second parameter, files missing or different in the
32 $! copy directory will be updated.
33 $!
34 $! By default:
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.
40 $!
41 $! The copy directory is vms_root:[gawk]
42 $! The UPDATE parameter is ignored.
43 $!
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.
47 $!
48 $! If P1 is "SRCBCK" then this
49 $! The source directory tree is: src_root:[gawk]
50 $! The copy directory is src_root1:[gawk]
51 $!
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.
54 $!
55 $! This is to make sure that the backup save set for the unmodified
56 $! source is up to date.
57 $!
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.
60 $!
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]
64 $!
65 $! vms_root:
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.
68 $!
69 $! This is to make sure that the backup save set for the unmodified
70 $! source is up to date.
71 $!
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.
74 $!
75 $! 02-Jan-2014 J. Malmberg
76 $!==========================================================================
77 $!
78 $! Update missing/changed files.
79 $update_file = 0
80 $if (p2 .eqs. "UPDATE")
81 $then
82 $ update_file = 1
83 $endif
84 $!
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")
94 $!
95 $ref = ""
96 $if P1 .eqs. ""
97 $then
98 $ ref_base_dir = myprocdir - ".vms"
99 $ wrk_base_dir = mydir
100 $ update_file = 0
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
108 $ then
109 $ resultd = resultd - ref_root_base - "reference." + "vms_source."
110 $ else
111 $ resultd = resultd - ref_root_base - "gnu." + "gnu_vms."
112 $ endif
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
121 $endif
122 $!
123 $if p1 .eqs. "SRCBCK"
124 $then
125 $ ref_base_dir = "gawk"
126 $ wrk_base_dir = "gawk"
127 $ ref = "src_root:[" + ref_base_dir
128 $ wrk = "src_root1:[" + wrk_base_dir
129 $ if update_file
130 $ then
131 $ if f$search("src_root1:[000000]gawk.dir") .eqs. ""
132 $ then
133 $ create/dir/prot=o:rwed src_root1:[gawk]
134 $ endif
135 $ endif
136 $endif
137 $!
138 $!
139 $if p1 .eqs. "VMSBCK"
140 $then
141 $ ref_base_dir = "gawk"
142 $ wrk_base_dir = "gawk"
143 $ ref = "vms_root:[" + ref_base_dir
144 $ wrk = "vms_root1:[" + wrk_base_dir
145 $ if update_file
146 $ then
147 $ if f$search("vms_root1:[000000]gawk.dir") .eqs. ""
148 $ then
149 $ create/dir/prot=o:rwed vms_root1:[gawk]
150 $ endif
151 $ endif
152 $endif
153 $!
154 $!
155 $if ref .eqs. ""
156 $then
157 $ write sys$output "Unknown compare type specified!"
158 $ exit 44
159 $endif
160 $!
161 $!
162 $!
163 $! Future - check the device types involved for the
164 $! the syntax to check.
165 $ODS2_SYNTAX = 0
166 $NFS_MANGLE = 0
167 $PWRK_MANGLE = 0
168 $!
169 $vax = f$getsyi("HW_MODEL") .lt. 1024
170 $if vax
171 $then
172 $ ODS2_SYNTAX = 1
173 $endif
174 $!
175 $report_missing = 1
176 $!
177 $if .not. ODS2_SYNTAX
178 $then
179 $ set proc/parse=extended
180 $endif
181 $!
182 $loop:
183 $ ref_spec = f$search("''ref'...]*.*;",1)
184 $ if ref_spec .eqs. "" then goto loop_end
185 $!
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")
191 $!
192 $!
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
198 $!
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
204 $!
205 $ if ODS2_SYNTAX
206 $ then
207 $ endif
208 $!
209 $ wrk_path = wrk + rel_path
210 $!
211 $ ref_name_type = ref_name + ref_type
212 $!
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
219 $ if ODS2_SYNTAX
220 $ then
221 $!
222 $ endif
223 $!
224 $ wrk_spec = wrk_path + ref_name_type
225 $!
226 $!
227 $ wrk_chk = f$search(wrk_spec, 0)
228 $ if wrk_chk .eqs. ""
229 $ then
230 $ if report_missing
231 $ then
232 $ write sys$output "''wrk_spec' is missing"
233 $ endif
234 $ if update_file
235 $ then
236 $ copy/log 'ref_spec' 'wrk_spec'
237 $ endif
238 $ goto loop
239 $ endif
240 $!
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
245 $!
246 $ if ref_fname .nes. wrk_fname
247 $ then
248 $ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
249 $ endif
250 $!
251 $ ref_type = f$edit(ref_type, "UPCASE")
252 $ if ref_type .eqs. ".DIR" then goto loop
253 $!
254 $ if ODS2_SYNTAX
255 $ then
256 $ ref_fname = f$edit(ref_fname, "LOWERCASE")
257 $ endif
258 $!
259 $! These files have records to long to diff, and we don't change them anyway.
260 $ ref_skip = 0
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
272 $ if ref_fname .eqs. "configure." then ref_skip = 1
273 $ if ref_fname .eqs. "libtool.m4" then ref_skip = 1
274 $!
275 $!
276 $ if ref_skip .ne. 0
277 $ then
278 $ if report_missing
279 $ then
280 $ write sys$output "Skipping diff of ''ref_fname'"
281 $ endif
282 $ goto loop
283 $ endif
284 $!
285 $!
286 $ wrk_ver = f$parse(wrk_chk,,,"VERSION")
287 $ if wrk_ver .nes. ";1"
288 $ then
289 $ write sys$output "Version for ''wrk_spec' is not 1"
290 $ endif
291 $ set noon
292 $ diff/out=nl: 'wrk_spec' 'ref_spec'
293 $ if $severity .nes. "1"
294 $ then
295 $ write sys$output "''wrk_spec' is different from ''ref_spec'"
296 $ if update_file
297 $ then
298 $ delete 'wrk_spec';*
299 $ copy/log 'ref_spec' 'wrk_spec'
300 $ endif
301 $ endif
302 $ set on
303 $
304 $!
305 $ goto loop
306 $loop_end:
307 $!
308 $!
309 $missing_loop:
310 $! For missing loop, check the latest generation.
311 $ ref_spec = f$search("''wrk'...]*.*;")
312 $ if ref_spec .eqs. "" then goto missing_loop_end
313 $!
314 $ ref_dev = f$parse(ref_spec,,,"DEVICE")
315 $ ref_dir = f$parse(ref_spec,,,"DIRECTORY")
316 $ ref_dir = f$edit(ref_dir, "LOWERCASE")
317 $ ref_name = f$parse(ref_spec,,,"NAME")
318 $ ref_type = f$parse(ref_spec,,,"TYPE")
319 $!
320 $ rel_path = ref_dir - "[" - wrk_base_dir
321 $!
322 $!
323 $ wrk_path = ref + rel_path
324 $ wrk_spec = wrk_path + ref_name + ref_type
325 $ wrk_name = f$parse(wrk_spec,,,"NAME")
326 $ wrk_type = f$parse(wrk_spec,,,"TYPE")
327 $!
328 $ wrk_fname = wrk_name + wrk_type"
329 $ ref_fname = ref_name + ref_type
330 $!
331 $ wrk_skip = 0
332 $ ref_utype = f$edit(ref_type,"UPCASE")
333 $ ref_ufname = f$edit(ref_fname,"UPCASE")
334 $!
335 $!
336 $ if wrk_skip .eq. 0
337 $ then
338 $ wrk_chk = f$search(wrk_spec, 0)
339 $ if wrk_chk .eqs. ""
340 $ then
341 $ if report_missing
342 $ then
343 $ write sys$output "''wrk_spec' is missing"
344 $ endif
345 $ goto missing_loop
346 $ endif
347 $ else
348 $ goto missing_loop
349 $ endif
350 $!
351 $ if ref_fname .nes. wrk_fname
352 $ then
353 $ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
354 $ endif
355 $!
356 $ if ref_utype .eqs. ".DIR" then goto missing_loop
357 $!
358 $ wrk_ver = f$parse(wrk_chk,,,"VERSION")
359 $ if wrk_ver .nes. ";1"
360 $ then
361 $ write sys$output "Version for ''wrk_spec' is not 1"
362 $ endif
363 $!
364 $ goto missing_loop
365 $!
366 $!
367 $missing_loop_end:
368 $!
369 $exit