compare_curl_source.com 10 KB

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