compare_curl_source.com (10602B)
1 $! Compare_curl_source.com 2 $! 3 $! This procedure compares the files in two directories and reports the 4 $! differences. It is customized for the vmsports repository layout. 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 code control are compared with the copy directory. 19 $! 20 $! Only files present in the copy directory are listed. 21 $! 22 $! Diagnostics are displayed about the 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 directory src_root:[project_name] will be translated to something like 36 $! DISK:[dir.dir.reference.project_name] and this will be used 37 $! to calculate DISK:[dir.dir.vms_source.project_name] for the VMS specific 38 $! source directory. 39 $! 40 $! The copy directory is vms_root:[project_name] 41 $! The UPDATE parameter is ignored. 42 $! 43 $! This setting is used to make sure that the working vms directory 44 $! and the repository checkout directory have the same contents. 45 $! 46 $! If P1 is "SRCBCK" then this 47 $! The source directory tree is: src_root:[project_name] 48 $! The copy directory is src_root1:[project_name] 49 $! 50 $! src_root1:[project_name] is used by me to work around that VMS backup will 51 $! not use NFS as a source directory so I need to make a copy. 52 $! 53 $! This is to make sure that the backup save set for the unmodified 54 $! source is up to date. 55 $! 56 $! If your repository checkout is not on an NFS mounted volume, you do not 57 $! need to use this option or have the logical name src_root1 defined. 58 $! 59 $! If P1 is "VMSBCK" then this changes the two directories: 60 $! The source directory is vms_root:[project_name] 61 $! The copy directory is vms_root1:[project_name] 62 $! 63 $! vms_root:[project_name] is where I do the VMS specific edits. 64 $! vms_root1:[project_name] is used by me to work around that VMS backup will 65 $! not use NFS as a source directory so I need to make a copy. 66 $! 67 $! This is to make sure that the backup save set for the unmodified 68 $! source is up to date. 69 $! 70 $! Copyright (C) John Malmberg 71 $! 72 $! Permission to use, copy, modify, and/or distribute this software for any 73 $! purpose with or without fee is hereby granted, provided that the above 74 $! copyright notice and this permission notice appear in all copies. 75 $! 76 $! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 77 $! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 78 $! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 79 $! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 80 $! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 81 $! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 82 $! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 83 $! 84 $! SPDX-License-Identifier: ISC 85 $! 86 $!========================================================================== 87 $! 88 $! Update missing/changed files. 89 $ update_file = 0 90 $ if (p2 .eqs. "UPDATE") 91 $ then 92 $ update_file = 1 93 $ endif 94 $! 95 $ myproc = f$environment("PROCEDURE") 96 $ myprocdir = f$parse(myproc,,,"DIRECTORY") - "[" - "]" - "<" - ">" 97 $ myprocdir = f$edit(myprocdir, "LOWERCASE") 98 $ mydefault = f$environment("DEFAULT") 99 $ mydir = f$parse(mydefault,,,"DIRECTORY") 100 $ mydir = f$edit(mydir, "LOWERCASE") 101 $ odelim = f$extract(0, 1, mydir) 102 $ mydir = mydir - "[" - "]" - "<" - ">" 103 $ mydev = f$parse(mydefault,,,"DEVICE") 104 $! 105 $ ref = "" 106 $ if P1 .eqs. "" 107 $ then 108 $ ref_base_dir = myprocdir 109 $ wrk_base_dir = mydir 110 $ update_file = 0 111 $ resultd = f$parse("src_root:",,,,"NO_CONCEAL") 112 $ resultd = f$edit(resultd, "LOWERCASE") 113 $ resultd = resultd - "][" - "><" - ".;" - ".." 114 $ resultd_len = f$length(resultd) - 1 115 $ delim = f$extract(resultd_len, 1, resultd) 116 $ ref_root_base = mydir + delim 117 $ resultd = resultd - ref_root_base - "reference." + "vms_source." 118 $ ref = resultd + ref_base_dir 119 $ wrk = "VMS_ROOT:" + odelim + wrk_base_dir 120 $ resultd_len = f$length(resultd) - 1 121 $ resultd = f$extract(0, resultd_len, resultd) + delim 122 $ ref_root_dir = f$parse(resultd,,,"DIRECTORY") 123 $ ref_root_dir = f$edit(ref_root_dir, "LOWERCASE") 124 $ ref_root_dir = ref_root_dir - "[" - "]" 125 $ ref_base_dir = ref_root_dir + "." + ref_base_dir 126 $ endif 127 $! 128 $ if p1 .eqs. "SRCBCK" 129 $ then 130 $ ref_base_dir = "curl" 131 $ wrk_base_dir = "curl" 132 $ ref = "src_root:[" + ref_base_dir 133 $ wrk = "src_root1:[" + wrk_base_dir 134 $ if update_file 135 $ then 136 $ if f$search("src_root1:[000000]curl.dir") .eqs. "" 137 $ then 138 $ create/dir/prot=o:rwed src_root1:[curl] 139 $ endif 140 $ endif 141 $ endif 142 $! 143 $! 144 $ if p1 .eqs. "VMSBCK" 145 $ then 146 $ ref_base_dir = "curl" 147 $ wrk_base_dir = "curl" 148 $ ref = "vms_root:[" + ref_base_dir 149 $ wrk = "vms_root1:[" + wrk_base_dir 150 $ if update_file 151 $ then 152 $ if f$search("vms_root1:[000000]curl.dir") .eqs. "" 153 $ then 154 $ create/dir/prot=o:rwed vms_root1:[curl] 155 $ endif 156 $ endif 157 $ endif 158 $! 159 $! 160 $ if ref .eqs. "" 161 $ then 162 $ write sys$output "Unknown compare type specified!" 163 $ exit 44 164 $ endif 165 $! 166 $! 167 $! Future - check the device types involved for the 168 $! the syntax to check. 169 $ ODS2_SYNTAX = 0 170 $ NFS_MANGLE = 0 171 $ PWRK_MANGLE = 0 172 $! 173 $ vax = f$getsyi("HW_MODEL") .lt. 1024 174 $ if vax 175 $ then 176 $ ODS2_SYNTAX = 1 177 $ endif 178 $! 179 $ report_missing = 1 180 $! 181 $ if .not. ODS2_SYNTAX 182 $ then 183 $ set proc/parse=extended 184 $ endif 185 $! 186 $loop: 187 $ ref_spec = f$search("''ref'...]*.*;",1) 188 $ if ref_spec .eqs. "" then goto loop_end 189 $! 190 $ ref_dev = f$parse(ref_spec,,,"DEVICE") 191 $ ref_dir = f$parse(ref_spec,,,"DIRECTORY") 192 $ ref_dir = f$edit(ref_dir, "LOWERCASE") 193 $ ref_name = f$parse(ref_spec,,,"NAME") 194 $ ref_type = f$parse(ref_spec,,,"TYPE") 195 $! 196 $! 197 $ rel_path = ref_dir - "[" - ref_base_dir 198 $! rel_path_len = f$length(rel_path) - 1 199 $! delim = f$extract(rel_path_len, 1, rel_path) 200 $! rel_path = rel_path - ".]" - ".>" - "]" - ">" 201 $! rel_path = rel_path + delim 202 $! 203 $ if ODS2_SYNTAX 204 $ then 205 $! if rel_path .eqs. ".examples.scripts^.noah]" 206 $! then 207 $! rel_path = ".examples.scripts_noah]" 208 $! endif 209 $! if rel_path .eqs. ".examples.scripts^.v2]" 210 $! then 211 $! rel_path = ".examples.scripts_v2]" 212 $! endif 213 $ endif 214 $! 215 $ wrk_path = wrk + rel_path 216 $! 217 $ ref_name_type = ref_name + ref_type 218 $! 219 $ if ODS2_SYNTAX 220 $ then 221 $ endif 222 $! 223 $ wrk_spec = wrk_path + ref_name_type 224 $! 225 $! 226 $ wrk_chk = f$search(wrk_spec, 0) 227 $ if wrk_chk .eqs. "" 228 $ then 229 $ if report_missing 230 $ then 231 $ write sys$output "''wrk_spec' is missing" 232 $ endif 233 $ if update_file 234 $ then 235 $ copy/log 'ref_spec' 'wrk_spec' 236 $ endif 237 $ goto loop 238 $ endif 239 $! 240 $ wrk_name = f$parse(wrk_spec,,,"NAME") 241 $ wrk_type = f$parse(wrk_spec,,,"TYPE") 242 $ wrk_fname = wrk_name + wrk_type" 243 $ ref_fname = ref_name + ref_type 244 $! 245 $ if ref_fname .nes. wrk_fname 246 $ then 247 $ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'""" 248 $ endif 249 $! 250 $ ref_type = f$edit(ref_type, "UPCASE") 251 $ if ref_type .eqs. ".DIR" then goto loop 252 $! 253 $ if ODS2_SYNTAX 254 $ then 255 $ ref_fname = f$edit(ref_fname, "LOWERCASE") 256 $ endif 257 $! 258 $! These files are in the wrong format for VMS diff, and we don't change them. 259 $ ref_skip = 0 260 $ if ref_type .eqs. ".PDF" then ref_skip = 1 261 $ if ref_type .eqs. ".HTML" then ref_skip = 1 262 $ if ref_type .eqs. ".P12" then ref_skip = 1 263 $ if ref_type .eqs. "." 264 $ then 265 $ if f$locate("test", ref_fname) .eq. 0 then ref_skip = 1 266 $ if ref_fname .eqs. "configure." then ref_skip = 1 267 $ endif 268 $! 269 $! 270 $ if ref_skip .ne. 0 271 $ then 272 $ if report_missing 273 $ then 274 $ write sys$output "Skipping diff of ''ref_fname'" 275 $ endif 276 $ goto loop 277 $ endif 278 $! 279 $! 280 $ wrk_ver = f$parse(wrk_chk,,,"VERSION") 281 $ if wrk_ver .nes. ";1" 282 $ then 283 $ write sys$output "Version for ''wrk_spec' is not 1" 284 $ endif 285 $ set noon 286 $ diff/out=nl: 'wrk_spec' 'ref_spec' 287 $ if $severity .nes. "1" 288 $ then 289 $ write sys$output "''wrk_spec' is different from ''ref_spec'" 290 $ if update_file 291 $ then 292 $ delete 'wrk_spec';* 293 $ copy/log 'ref_spec' 'wrk_spec' 294 $ endif 295 $ endif 296 $ set on 297 $ 298 $! 299 $ goto loop 300 $loop_end: 301 $! 302 $! 303 $missing_loop: 304 $! For missing loop, check the latest generation. 305 $ ref_spec = f$search("''wrk'...]*.*;") 306 $ if ref_spec .eqs. "" then goto missing_loop_end 307 $! 308 $ ref_dev = f$parse(ref_spec,,,"DEVICE") 309 $ ref_dir = f$parse(ref_spec,,,"DIRECTORY") 310 $ ref_dir = f$edit(ref_dir, "LOWERCASE") 311 $ ref_name = f$parse(ref_spec,,,"NAME") 312 $ ref_type = f$parse(ref_spec,,,"TYPE") 313 $ ref_name_type = ref_name + ref_type 314 $! 315 $ rel_path = ref_dir - "[" - wrk_base_dir 316 $! 317 $! 318 $ wrk_path = ref + rel_path 319 $ wrk_spec = wrk_path + ref_name + ref_type 320 $ wrk_name = f$parse(wrk_spec,,,"NAME") 321 $ wrk_type = f$parse(wrk_spec,,,"TYPE") 322 $! 323 $ wrk_fname = wrk_name + wrk_type" 324 $ ref_fname = ref_name + ref_type 325 $! 326 $ wrk_skip = 0 327 $ ref_utype = f$edit(ref_type,"UPCASE") 328 $ ref_ufname = f$edit(ref_fname,"UPCASE") 329 $! 330 $ if wrk_skip .eq. 0 331 $ then 332 $ wrk_chk = f$search(wrk_spec, 0) 333 $ if wrk_chk .eqs. "" 334 $ then 335 $ if report_missing 336 $ then 337 $ write sys$output "''wrk_spec' is missing" 338 $ endif 339 $ goto missing_loop 340 $ endif 341 $ else 342 $ goto missing_loop 343 $ endif 344 $! 345 $ if ref_fname .nes. wrk_fname 346 $ then 347 $ write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'""" 348 $ endif 349 $! 350 $ if ref_utype .eqs. ".DIR" then goto missing_loop 351 $! 352 $ wrk_ver = f$parse(wrk_chk,,,"VERSION") 353 $ if wrk_ver .nes. ";1" 354 $ then 355 $ write sys$output "Version for ''wrk_spec' is not 1" 356 $ endif 357 $! 358 $ goto missing_loop 359 $! 360 $! 361 $missing_loop_end: 362 $! 363 $exit