Blame vms/compare_gawk_source.com

Packit 575503
$! Compare_gawk_source.com
Packit 575503
$!
Packit 575503
$! This procedure compares the files in two directories and reports the
Packit 575503
$! differences.
Packit 575503
$!
Packit 575503
$! It needs to be customized to the local site directories.
Packit 575503
$!
Packit 575503
$! This is used by me for these purposes:
Packit 575503
$!     1. Compare the original source of a project with an existing
Packit 575503
$!        VMS port.
Packit 575503
$!     2. Compare the checked out repository of a project with the
Packit 575503
$!        the local working copy to make sure they are in sync.
Packit 575503
$!     3. Keep a copy directory up to date.  The third is needed by
Packit 575503
$!        me because VMS Backup can create a saveset of files from a
Packit 575503
$!        NFS mounted volume.
Packit 575503
$!
Packit 575503
$! First the files in the original source directory which is assumed to be
Packit 575503
$! under source codde control are compared with the copy directory.
Packit 575503
$!
Packit 575503
$! Then the files are are only in the copy directory are listed.
Packit 575503
$!
Packit 575503
$! The result will five diagnostics about of files:
Packit 575503
$!    1. Files that are not generation 1.
Packit 575503
$!    2. Files missing in the copy directory.
Packit 575503
$!    3. Files in the copy directory not in the source directory.
Packit 575503
$!    4. Files different from the source directory.
Packit 575503
$!    5. Files that VMS DIFF can not process.
Packit 575503
$!
Packit 575503
$! This needs to be run on an ODS-5 volume.
Packit 575503
$!
Packit 575503
$! If UPDATE is given as a second parameter, files missing or different in the
Packit 575503
$! copy directory will be updated.
Packit 575503
$!
Packit 575503
$! By default:
Packit 575503
$!    The source directory is source_root:[gawk.reference.gawk],
Packit 575503
$!    the logical used on my system for the GNV Mecurial repository checkout.
Packit 575503
$!    If source_root: is not defined, then src_root:[gawk] will be
Packit 575503
$!    translated to something like DISK:[dir.gawk.reference.gawk]
Packit 575503
$!    and then DISK:[dir.gawk.vms_source.gawk] will be used.
Packit 575503
$!
Packit 575503
$!    The copy directory is vms_root:[gawk]
Packit 575503
$!    The UPDATE parameter is ignored.
Packit 575503
$!
Packit 575503
$!    This setting is used to make sure that the working vms directory
Packit 575503
$!    and the VMS specific repository checkout directory have the same
Packit 575503
$!    contents if they are different.
Packit 575503
$!
Packit 575503
$! If P1 is "SRCBCK" then this
Packit 575503
$!     The source directory tree is: src_root:[gawk]
Packit 575503
$!     The copy directory is src_root1:[gawk]
Packit 575503
$!
Packit 575503
$!   src_root1:[gawk] is used by me to work around that VMS backup will
Packit 575503
$!   not use NFS as a source directory so I need to make a copy.
Packit 575503
$!
Packit 575503
$!   This is to make sure that the backup save set for the unmodified
Packit 575503
$!   source is up to date.
Packit 575503
$!
Packit 575503
$!   If your repository checkout is not on an NFS mounted volume, you do not
Packit 575503
$!   need to use this option or have the logical name src_root1 defined.
Packit 575503
$!
Packit 575503
$! If P1 is "VMSBCK" then this changes the two directories:
Packit 575503
$!    The source directory is vms_root:[gawk]
Packit 575503
$!    The copy directory is vms_root1:[gawk]
Packit 575503
$!
Packit 575503
$!   vms_root:
Packit 575503
$!   src_root1:[gawk] is used by me to work around that VMS backup will
Packit 575503
$!   not use NFS as a source directory so I need to make a copy.
Packit 575503
$!
Packit 575503
$!   This is to make sure that the backup save set for the unmodified
Packit 575503
$!   source is up to date.
Packit 575503
$!
Packit 575503
$!   If your repository checkout is not on an NFS mounted volume, you do not
Packit 575503
$!   need to use this option or have the logical name src_root1 defined.
Packit 575503
$!
Packit 575503
$! 02-Jan-2014   J. Malmberg
Packit 575503
$!==========================================================================
Packit 575503
$!
Packit 575503
$! Update missing/changed files.
Packit 575503
$update_file = 0
Packit 575503
$if (p2 .eqs. "UPDATE")
Packit 575503
$then
Packit 575503
$   update_file = 1
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$myproc = f$environment("PROCEDURE")
Packit 575503
$myprocdir = f$parse(myproc,,,"DIRECTORY") - "[" - "]" - "<" - ">"
Packit 575503
$myprocdir = f$edit(myprocdir, "LOWERCASE")
Packit 575503
$mydefault = f$environment("DEFAULT")
Packit 575503
$mydir = f$parse(mydefault,,,"DIRECTORY")
Packit 575503
$mydir = f$edit(mydir, "LOWERCASE")
Packit 575503
$odelim = f$extract(0, 1, mydir)
Packit 575503
$mydir = mydir - "[" - "]" - "<" - ">"
Packit 575503
$mydev = f$parse(mydefault,,,"DEVICE")
Packit 575503
$!
Packit 575503
$ref = ""
Packit 575503
$if P1 .eqs. ""
Packit 575503
$then
Packit 575503
$   ref_base_dir = myprocdir - ".vms"
Packit 575503
$   wrk_base_dir = mydir
Packit 575503
$   update_file = 0
Packit 575503
$   resultd = f$parse("src_root:",,,,"NO_CONCEAL")
Packit 575503
$   resultd = f$edit(resultd, "LOWERCASE")
Packit 575503
$   resultd = resultd - "][" - "><" - ".;" - ".."
Packit 575503
$   resultd_len = f$length(resultd) - 1
Packit 575503
$   delim = f$extract(resultd_len, 1, resultd)
Packit 575503
$   ref_root_base = mydir + delim
Packit 575503
$   if f$locate(".reference.", resultd) .lt. resultd_len
Packit 575503
$   then
Packit 575503
$      resultd = resultd - ref_root_base - "reference." + "vms_source."
Packit 575503
$   else
Packit 575503
$      resultd = resultd - ref_root_base - "gnu." + "gnu_vms."
Packit 575503
$   endif
Packit 575503
$   ref = resultd + ref_base_dir
Packit 575503
$   wrk = "VMS_ROOT:" + odelim + wrk_base_dir
Packit 575503
$   resultd_len = f$length(resultd) - 1
Packit 575503
$   resultd = f$extract(0, resultd_len, resultd) + delim
Packit 575503
$   ref_root_dir = f$parse(resultd,,,"DIRECTORY")
Packit 575503
$   ref_root_dir = f$edit(ref_root_dir, "LOWERCASE")
Packit 575503
$   ref_root_dir = ref_root_dir - "[" - "]"
Packit 575503
$   ref_base_dir = ref_root_dir + "." + ref_base_dir
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$if p1 .eqs. "SRCBCK"
Packit 575503
$then
Packit 575503
$   ref_base_dir = "gawk"
Packit 575503
$   wrk_base_dir = "gawk"
Packit 575503
$   ref = "src_root:[" + ref_base_dir
Packit 575503
$   wrk = "src_root1:[" + wrk_base_dir
Packit 575503
$   if update_file
Packit 575503
$   then
Packit 575503
$       if f$search("src_root1:[000000]gawk.dir") .eqs. ""
Packit 575503
$       then
Packit 575503
$           create/dir/prot=o:rwed src_root1:[gawk]
Packit 575503
$       endif
Packit 575503
$   endif
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$!
Packit 575503
$if p1 .eqs. "VMSBCK"
Packit 575503
$then
Packit 575503
$   ref_base_dir = "gawk"
Packit 575503
$   wrk_base_dir = "gawk"
Packit 575503
$   ref = "vms_root:[" + ref_base_dir
Packit 575503
$   wrk = "vms_root1:[" + wrk_base_dir
Packit 575503
$   if update_file
Packit 575503
$   then
Packit 575503
$       if f$search("vms_root1:[000000]gawk.dir") .eqs. ""
Packit 575503
$       then
Packit 575503
$           create/dir/prot=o:rwed vms_root1:[gawk]
Packit 575503
$       endif
Packit 575503
$   endif
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$!
Packit 575503
$if ref .eqs. ""
Packit 575503
$then
Packit 575503
$   write sys$output "Unknown compare type specified!"
Packit 575503
$   exit 44
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$!
Packit 575503
$!
Packit 575503
$! Future - check the device types involved for the
Packit 575503
$! the syntax to check.
Packit 575503
$ODS2_SYNTAX = 0
Packit 575503
$NFS_MANGLE = 0
Packit 575503
$PWRK_MANGLE = 0
Packit 575503
$!
Packit 575503
$vax = f$getsyi("HW_MODEL") .lt. 1024
Packit 575503
$if vax
Packit 575503
$then
Packit 575503
$   ODS2_SYNTAX = 1
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$report_missing = 1
Packit 575503
$!
Packit 575503
$if .not. ODS2_SYNTAX
Packit 575503
$then
Packit 575503
$   set proc/parse=extended
Packit 575503
$endif
Packit 575503
$!
Packit 575503
$loop:
Packit 575503
$  ref_spec = f$search("''ref'...]*.*;",1)
Packit 575503
$  if ref_spec .eqs. "" then goto loop_end
Packit 575503
$!
Packit 575503
$  ref_dev = f$parse(ref_spec,,,"DEVICE")
Packit 575503
$  ref_dir = f$parse(ref_spec,,,"DIRECTORY")
Packit 575503
$  ref_dir = f$edit(ref_dir, "LOWERCASE")
Packit 575503
$  ref_name = f$parse(ref_spec,,,"NAME")
Packit 575503
$  ref_type = f$parse(ref_spec,,,"TYPE")
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  if f$locate(".CVS]", ref_dir) .lt. f$length(ref_dir) then goto loop
Packit 575503
$  if f$locate(".cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
Packit 575503
$  if f$locate(".$cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
Packit 575503
$  if f$locate(".^.git", ref_dir) .lt. f$length(ref_dir) then goto loop
Packit 575503
$  if f$locate(".$5ngit", ref_dir) .lt. f$length(ref_dir) then goto loop
Packit 575503
$!
Packit 575503
$  rel_path = ref_dir - "[" - ref_base_dir
Packit 575503
$!  rel_path_len = f$length(rel_path) - 1
Packit 575503
$!  delim = f$extract(rel_path_len, 1, rel_path)
Packit 575503
$!  rel_path = rel_path - ".]" - ".>" - "]" - ">"
Packit 575503
$!  rel_path = rel_path + delim
Packit 575503
$!
Packit 575503
$  if ODS2_SYNTAX
Packit 575503
$  then
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  wrk_path = wrk + rel_path
Packit 575503
$!
Packit 575503
$  ref_name_type = ref_name + ref_type
Packit 575503
$!
Packit 575503
$  if ref_name_type .eqs. "CVS.DIR" then goto loop
Packit 575503
$  if ref_name_type .eqs. "cvs.dir" then goto loop
Packit 575503
$  if ref_name_type .eqs. "$CVS.DIR" then goto loop
Packit 575503
$  if ref_name_type .eqs. "^.git.DIR" then goto loop
Packit 575503
$  if ref_name_type .eqs. "$5ngit.DIR" then goto loop
Packit 575503
$  if ref_name_type .eqs. "$5NGIT.DIR" then goto loop
Packit 575503
$  if ODS2_SYNTAX
Packit 575503
$  then
Packit 575503
$!
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  wrk_spec = wrk_path + ref_name_type
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  wrk_chk = f$search(wrk_spec, 0)
Packit 575503
$  if wrk_chk .eqs. ""
Packit 575503
$  then
Packit 575503
$    if report_missing
Packit 575503
$    then
Packit 575503
$      write sys$output "''wrk_spec' is missing"
Packit 575503
$    endif
Packit 575503
$    if update_file
Packit 575503
$    then
Packit 575503
$      copy/log 'ref_spec' 'wrk_spec'
Packit 575503
$    endif
Packit 575503
$    goto loop
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  wrk_name = f$parse(wrk_spec,,,"NAME")
Packit 575503
$  wrk_type = f$parse(wrk_spec,,,"TYPE")
Packit 575503
$  wrk_fname = wrk_name + wrk_type"
Packit 575503
$  ref_fname = ref_name + ref_type
Packit 575503
$!
Packit 575503
$  if ref_fname .nes. wrk_fname
Packit 575503
$  then
Packit 575503
$    write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  ref_type = f$edit(ref_type, "UPCASE")
Packit 575503
$  if ref_type .eqs. ".DIR" then goto loop
Packit 575503
$!
Packit 575503
$  if ODS2_SYNTAX
Packit 575503
$  then
Packit 575503
$       ref_fname = f$edit(ref_fname, "LOWERCASE")
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$! These files have records to long to diff, and we don't change them anyway.
Packit 575503
$  ref_skip = 0
Packit 575503
$  if ref_type .eqs. ".GMO" then ref_skip = 1
Packit 575503
$  if ref_type .eqs. ".PDF" then ref_skip = 1
Packit 575503
$  if ref_type .eqs. ".PNG" then ref_skip = 1
Packit 575503
$  if ref_type .eqs. ".JPG" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "inftest.ok" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "longsub.in" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "longsub.ok" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "nasty2.ok" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "profile5.awk" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "profile5.ok" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "po.m4" then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "configure." then ref_skip = 1
Packit 575503
$  if ref_fname .eqs. "libtool.m4" then ref_skip = 1
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  if ref_skip .ne. 0
Packit 575503
$  then
Packit 575503
$    if report_missing
Packit 575503
$    then
Packit 575503
$        write sys$output "Skipping diff of ''ref_fname'"
Packit 575503
$    endif
Packit 575503
$    goto loop
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  wrk_ver = f$parse(wrk_chk,,,"VERSION")
Packit 575503
$  if wrk_ver .nes. ";1"
Packit 575503
$  then
Packit 575503
$    write sys$output "Version for ''wrk_spec' is not 1"
Packit 575503
$  endif
Packit 575503
$  set noon
Packit 575503
$  diff/out=nl: 'wrk_spec' 'ref_spec'
Packit 575503
$  if $severity .nes. "1"
Packit 575503
$  then
Packit 575503
$    write sys$output "''wrk_spec' is different from ''ref_spec'"
Packit 575503
$    if update_file
Packit 575503
$    then
Packit 575503
$       delete 'wrk_spec';*
Packit 575503
$       copy/log 'ref_spec' 'wrk_spec'
Packit 575503
$    endif
Packit 575503
$  endif
Packit 575503
$  set on
Packit 575503
$
Packit 575503
$!
Packit 575503
$  goto loop
Packit 575503
$loop_end:
Packit 575503
$!
Packit 575503
$!
Packit 575503
$missing_loop:
Packit 575503
$! For missing loop, check the latest generation.
Packit 575503
$  ref_spec = f$search("''wrk'...]*.*;")
Packit 575503
$  if ref_spec .eqs. "" then goto missing_loop_end
Packit 575503
$!
Packit 575503
$  ref_dev = f$parse(ref_spec,,,"DEVICE")
Packit 575503
$  ref_dir = f$parse(ref_spec,,,"DIRECTORY")
Packit 575503
$  ref_dir = f$edit(ref_dir, "LOWERCASE")
Packit 575503
$  ref_name = f$parse(ref_spec,,,"NAME")
Packit 575503
$  ref_type = f$parse(ref_spec,,,"TYPE")
Packit 575503
$!
Packit 575503
$  rel_path = ref_dir - "[" - wrk_base_dir
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  wrk_path = ref + rel_path
Packit 575503
$  wrk_spec = wrk_path + ref_name + ref_type
Packit 575503
$  wrk_name = f$parse(wrk_spec,,,"NAME")
Packit 575503
$  wrk_type = f$parse(wrk_spec,,,"TYPE")
Packit 575503
$!
Packit 575503
$  wrk_fname = wrk_name + wrk_type"
Packit 575503
$  ref_fname = ref_name + ref_type
Packit 575503
$!
Packit 575503
$  wrk_skip = 0
Packit 575503
$  ref_utype = f$edit(ref_type,"UPCASE")
Packit 575503
$  ref_ufname = f$edit(ref_fname,"UPCASE")
Packit 575503
$!
Packit 575503
$!
Packit 575503
$  if wrk_skip .eq. 0
Packit 575503
$  then
Packit 575503
$     wrk_chk = f$search(wrk_spec, 0)
Packit 575503
$     if wrk_chk .eqs. ""
Packit 575503
$     then
Packit 575503
$         if report_missing
Packit 575503
$         then
Packit 575503
$             write sys$output "''wrk_spec' is missing"
Packit 575503
$         endif
Packit 575503
$         goto missing_loop
Packit 575503
$     endif
Packit 575503
$  else
Packit 575503
$     goto missing_loop
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  if ref_fname .nes. wrk_fname
Packit 575503
$  then
Packit 575503
$    write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  if ref_utype .eqs. ".DIR" then goto missing_loop
Packit 575503
$!
Packit 575503
$  wrk_ver = f$parse(wrk_chk,,,"VERSION")
Packit 575503
$  if wrk_ver .nes. ";1"
Packit 575503
$  then
Packit 575503
$    write sys$output "Version for ''wrk_spec' is not 1"
Packit 575503
$  endif
Packit 575503
$!
Packit 575503
$  goto missing_loop
Packit 575503
$!
Packit 575503
$!
Packit 575503
$missing_loop_end:
Packit 575503
$!
Packit 575503
$exit