-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
zginstall.rex
executable file
·2245 lines (2109 loc) · 80 KB
/
zginstall.rex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* REXX - must start in column 1 */
/* --------------------------------------------------------- *
| Name: zginstall.rex |
| |
| Function: ZIGI Package Installation Script |
| |
| Syntax: ./zginstall.rex hlq \ option |
| |
| Usage: If hlq is not provided it will be prompted for |
| and used for the z/OS dataset hlq. |
| |
| \ - delimeter |
| |
| x - any non-blank will cause zginstall to |
| copy individual files into the PDS instead |
| of all at once.. |
| |
| Installation: This script should be installed in the root |
| OMVS directory for the ZIGI managed Git |
| repository. |
| |
| It is included in this library so that it |
| can be accessed by ZIGI to prime a new, or |
| existing, repository. |
| |
| Usage Notes: |
| 1. Prompt for |
| - default HLQ to be used |
| 2. Sequential files that have no lowercase |
| will be processed. |
| 3. Directories that are all uppercase will |
| be assumed to be PDS directories |
| 4. Upon completing the upload of all z/OS |
| datasets the hlq.ZGSTAT.EXEC dataset will |
| be generated. It will be pre-configured for |
| the uploaded datasets and when executed will |
| apply the ISPF statistics to all partitioned |
| dataset members from the ISPF statistics |
| files found in the .zigi directory. |
| |
| Author: Lionel B. Dyck |
| |
| History: (most recent on top) |
| 05/14/24 LBD - Fix binary find in .gitattributes|
| 04/21/24 PJF - Support ascii to ebcdic tagging |
| 02/16/24 LBD - Correct 2 bad chars x'05' |
| 06/15/23 LBD - Add env ICONV_EBCDIC_ZOS_UNIX=1 |
| 01/23/23 LBD - Add zgpop4 panel |
| 01/21/23 LBD - Update zigistat subroutine |
| 05/16/22 LBD - Remove duplicate routines |
| 04/09/22 LBD - Update zigistat to current level |
| - Create zgstat.exec if mixed ds |
| 06/03/21 LBD - Change SHAREAS to REQUIRED |
| 05/14/21 HBK - Don't parse lowercase folders |
| 05/11/21 LBD - Correction for mixed text/binary |
| 05/06/21 LBD - support allmems > 32k |
| 01/06/21 LBD - use .zigi/dsn for z/OS dataset |
| determination |
| 11/17/20 LBD - Use Dovetail PUTPDS if available |
| as it is faster than cp |
| 10/25/20 LBD - Improve usssafe routine |
| 10/11/20 LBD - Correct test for existing dsns |
| 08/08/20 LBD - Generalize get_binfiles |
| 07/29/20 LBD - Add _EDC_ZERO_RECLEN=Y to env. |
| 07/24/20 LBD - Adjust Popup Panel Location |
| - Prompt to Proceed after display |
| of target datasets |
| 07/12/20 LBD - Define OMVS env stem |
| 07/04/20 LBD - Use Clear to clear screen |
| 06/29/20 LBD - Add generic installer prose |
| 06/28/20 LBD - Add text graphics |
| - Add prose about INPUT state |
| 06/27/20 LBD - Use a single cp if the pds is |
| not mixed (text & binary) |
| 06/26/20 LBD - Fixup zgstat.exec dsname quotes |
| 06/11/20 LBD - Redesign self contained exec |
| 06/10/20 LBD - Tweak for zgstat.exec dsn |
| 06/09/20 LBD - Creation from zigickot |
| ---------------------------------------------------------- |
| zigi - the z/OS ISPF Git Interface |
| Copyright (C) 2020-2023 - Henri Kuiper and Lionel Dyck |
| |
| This program is free software: you can redistribute it |
| and/or modify it under the terms of the GNU General |
| Public License as published by the Free Software |
| Foundation, either version 3 of the License, or (at |
| your option) any later version. |
| |
| This program is distributed in the hope that it will be |
| useful, but WITHOUT ANY WARRANTY; without even the |
| implied warranty of MERCHANTABILITY or FITNESS FOR A |
| PARTICULAR PURPOSE. See the GNU General Public License |
| for more details. |
| |
| You should have received a copy of the GNU General |
| Public License along with this program. If not, see |
| <https://www.gnu.org/licenses/>. |
* ---------------------------------------------------------- */
arg options
parse value options with ckothlq'\'opt
ckothlq = strip(ckothlq)
/* /bin/clear does not work for TERM=xterm-256color */
/* If TERM=xterm-256color then invoke clear with TERM=xterm */
x = bpxwunix('echo $TERM',,so.,se.)
curterm = strip(so.1)
if curterm = "xterm-256color" then do
env.0 = 1
env.1 = "TERM=xterm"
x = bpxwunix("clear",,,,env.)
end
else
x = bpxwunix('clear')
say copies('-',73)
say " .zZ. Zz "
say " ZZZZZZZZ ZZZZZZZ "
say " ZZZZZZZZZZZZZZZZZZZZZZ ZZ ZZZ zZ "
say " ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZ .zZZ ZZ "
say " ZZZZZZZZZZZZZZZZ ZZZZZZZ ZZ ZZZ ..zZZZ Zz "
say " ZZZZZZZZZZ, ZZZZZZZZZ ZZZ ZzZ ZZ ZZ ZZZZZZZ"
say " ZZZZ ZZZZZZZZ ZZZ ZZZZZZZZZZZ ZZZZZZZZZZZ "
say " ZZZZZZZZ ZZZZ ZZZZZZ ZZZZZZZZZg "
say " ZZZZZZZZ ZZZ ZZZZZZZZZ "
say " ZZZZZZZ zZZZZZZZZZZZZZZ Common"
say " ZZZZZZZ ZZZZZZZZZZZZZZ Installation"
say " .ZZZZZZZ ZZZZZZZZZZZZZZ Tool"
say " ZZZZZZZZZZZZZZZZZZZZZZ "
say " ZZZZZZZZZZZZZZZZZ zOS ISPF Git Interface "
say " ZZZZZZZZZZZZ "
say " ZZZZZZZZZZ The git interface for the rest of us"
say " ZZZZZZZZ "
say " ZZZZZZZ Henri Kuiper & Lionel Dyck "
say copies('-',73)
/* --------------------- *
| Set Default Env and |
| Get current directory |
* --------------------- */
env.1 = '_BPX_SHAREAS=MUST'
env.2 = '_BPX_SPAWN_SCRIPT=YES'
env.3 = '_EDC_ZERO_RECLEN=Y'
env.4 = 'ICONV_EBCDIC_ZOS_UNIX=1'
env.0 = 4
cmd = 'pwd'
x = bpxwunix(cmd,,so.,se.,env.)
ckotdir = strip(so.1)
x = bpxwunix('command -v putpds',,so.,se.)
if so.0 = 0 then enhanced = 0
else do
enhanced = 1
putpds = so.1
end
/* -------------------------------------------------------------- *
| First check if the repository directory is an unzipped manual |
| download or a git-supported directory, and if it is unzipped |
| and needs conversion then do so according to the rules found |
| in the .gitattributes file |
* -------------------------------------------------------------- */
rc = ChkIfGIT(ckotdir)
if rc <> 0 & rc <> 4 & rc <> 8 then exit rc /* Conversion error */
if rc = 8 then exit rc /* Conversion not possible, see msgs */
Restart:
/* ------------------- *
| Prompt for z/OS HLQ |
* ------------------- */
if ckothlq = '' then do
say 'Enter the z/OS High Level Qualifier to use:'
pull ckothlq
if ckothlq = '' then do
say 'no qualifier entered - exiting for now.'
exit 8
end
ckothlq = translate(strip(ckothlq))
end
/* -------------------------------------------------------- *
| Issue the ls command to get file names and sizes for all |
| files in the current directory and sub-directories. |
* -------------------------------------------------------- */
cmd = 'ls -laRk' ckotdir
rc = bpxwunix(cmd,,stdout.,stderr.,env.)
/* ---------------------------------------------- *
| Display any error messages and if so then exit |
* ---------------------------------------------- */
if stderr.0 > 0 then do
do i = 1 to stderr.0
say stderr.i
end
exit 8
end
/* ------------------------- *
| Define our work variables |
* ------------------------- */
parse value '' with subs files null zgstat_flag
mgen = 0
hit = 0
filec = 0
/* -------------------------------------------------------------- *
| Inform the user that if there are directories with a lot of |
| members to be copied into a PDS tht the OMVS shell may enter |
| an INPUT state and to just press F10 - meanwhile the copy (cp) |
| is proceeding. |
* -------------------------------------------------------------- */
if opt = null then do
call zmsg ' '
call zmsg 'If the repository being installed has partitioned datasets'
call zmsg 'with a large number of members, the copy operation will take'
call zmsg 'longer than the TN3270 polling expects. This will cause'
call zmsg 'the OMVS Shell to change from RUNNING to INPUT.'
call zmsg 'Just press the F10 key to return to a RUNNING state. '
call zmsg ' '
call zmsg 'Do not worry, however, as the copy operation is still running'
call zmsg 'and will report out when it completes (but only if the shell'
call zmsg 'is in a RUNNING state.'
call zmsg ' '
end
/* ------------------------------------ *
| Read in ../.zigi/dsn to get dcb info |
| and for z/OS dsn info |
* ------------------------------------ */
cmd = 'cd' ckotdir '&& ls -la .zigi'
x = bpxwunix(cmd,,co.,ce.,env.)
if x > 0 then do
def_recfm = 'FB'
def_lrecl = 80
def_blksize = 32720
def. = null
end
else do
ckdd = 'ck'time('s')
x = bpxwunix("cat '"ckotdir"/.zigi/dsn'",,ck.)
def. = null
zdsn. = null
do i = 1 to ck.0
if left(ck.i,1) = '#' then iterate
if word(ck.i,1) = '*' then do
parse value ck.i with . def_dsorg def_recfm def_lrecl def_blksize .
end
else do
dsn = word(ck.i,1) /* dataset name less hlq */
def.dsn = subword(ck.i,2) /* dataset dsorg */
zdsn.dsn = word(ck.i,6) /* file extension */
end
end
end
Address TSO
/* ------------------------------- *
| Get the list of Binary Datasets |
* ------------------------------- */
call get_binfiles
/* ---------------------------------------------------- *
| Process the results of the ls command to: |
| 1. collect number of members per sub-directory |
| 2. collect bytes count (in k) for each sub-directory |
| 3. collect info on sequential files |
* ---------------------------------------------------- */
if stdout.0 > 0 then
do i = 1 to stdout.0
select
when pos(ckotdir,stdout.i) > 0 then do
parse value stdout.i with (ckotdir)sub':'
if left(sub,1) = '/' then sub = substr(sub,2)
if strip(sub) /= '' then do
size.sub = 0
dir.sub = 0
si = 0
if left(sub,1) /= '.' then do
xx = translate(sub,'??????????????????????????',,
'abcdefghijklmnopqrstuvwxyz')
if pos('?',xx) > 0 then iterate /* No lowercase things */
subs = subs sub
end
end
end
when word(stdout.i,1) = 'total' then do
hit = hit + 1
end
when hit > 1 & left(stdout.i,1) = '-' then
if strip(sub) /= '' then do
size.sub = size.sub + word(stdout.i,5)
dir.sub = dir.sub + 1
end
when hit = 1 & left(stdout.i,1) = '-' then do
file = word(stdout.i,9)
if def.file = null then iterate
if left(file,1) = '.' then iterate
fx = translate(file,'??????????????????????????', ,
'abcdefghijklmnopqrstuvwxyz')
if pos('?',fx) > 0 then iterate
size.file = word(stdout.i,5)
files = files file
end
otherwise nop
end
end
call zmsg 'The following Datasets will be Created or Recreated:'
if words(files) > 0 then
do fi = 1 to words(files)
wdsn = "'"ckothlq"."word(files,fi)"'"
call zmsg wdsn
if check_file(wdsn) > 0
then call zmsg '--- Dataset exists and will be recreated.'
end
do fi = 1 to words(subs)
wdsn = "'"ckothlq"."word(subs,fi)"'"
call zmsg wdsn
if check_file(wdsn) > 0
then call zmsg '--- Dataset exists and will be recreated.'
end
call zmsg ' '
say ' '
say 'Enter Y to Proceed or anything to Retry:'
pull zgans
if translate(zgans) /= 'Y' then do
ckothlq = null
signal ReStart
end
/* -------------------------------------------- *
| Process the individual files, if any |
| Allocation and Copy |
* -------------------------------------------- */
do i = 1 to words(files)
parse value '' with zs1 zs2 zs3 zs4 zs5 zs6 zs7 zs8 zs9
sub = word(files,i)
fileg = "'"ckothlq"."sub"'"
odir = "'"ckotdir"/"sub"'"
bin = is_binfile(sub)
if bin = 1 then do
type = 'Binary'
zgstat_flag = 1
end
else type = 'Text'
say 'Copying' odir 'to' fileg 'as' type
filec = filec + 1
zfile.filec = fileg
x = check_file(fileg)
if x > 0 then do
call outtrap 'x.'
'delete' fileg
call outtrap 'off'
end
tracks = (size.sub%50000 + 1) * 2
call get_dcb
'alloc ds('fileg') new spa('tracks','tracks') tr dsorg(ps)' ,
'recfm('recfm') lrecl('lrecl') blksize('blksize')'
'free ds('fileg')'
'oget' odir fileg type
end
/* -------------------------------------------- *
| Process the sub-directories and initiate the |
| Allocation and Copy |
| Ignore subdirectories |
* -------------------------------------------- */
do isub = 1 to words(subs)
parse value '' with zs1 zs2 zs3 zs4 zs5 zs6 zs7 zs8 zs9
sub = word(subs,isub)
bin = is_binfile(sub)
if bin = 1 then do
type = 'Binary'
zgstat_flag = 1
end
else type = 'Text'
fx = translate(sub,'??????????????????????????', ,
'abcdefghijklmnopqrstuvwxyz')
if pos('?',fx) > 0 then iterate
tracks = (size.sub%50000 + 1) * 2
call alloc_copy_pds
end
/* ------------------------------------------ *
| Now update and create the zgstat.exec file |
* ------------------------------------------ */
if enhanced = 0 | zgstat_flag = 1 then do
c = 0
hit = 0
last = sourceline()
do i = 1 to last
card = sourceline(i)
if left(card,8) = '>ZGSTATE' then leave
if hit = 0 then
if left(card,8) = '>ZGSTAT ' then do
hit = 1
iterate
end
else iterate
if pos('$$$$$$',card) > 0 then do
parse value card with var '=' .
if translate(var) = 'REPODIR' then
card = " repodir ='"ckotdir"'"
if translate(var) = 'HLQ' then
card = " hlq ='"ckothlq"'"
end
c = c + 1
zg.c = card
end
zg.0 = c
Address syscall
path = ckotdir'/lrhg.rex'
'open' path O_rdwr+O_creat+O_trunc 660
if retval = -1 then do
say 'Unable to open the output file for ZGSTAT.EXEC'
say 'so ISPF statistics will not be able to be recreated.'
exit 8
end
fd = retval
do i = 1 to zg.0
rec = zg.i ESC_N
'write' fd 'rec' length(rec)
end
'close' fd
Address TSO
zgstat_dsn = "'"ckothlq".ZGSTAT.EXEC'"
say ' '
cmd = 'cp -v lrhg.rex "//'zgstat_dsn '"'
cmd = cmd '&& rm lrhg.rex'
x = bpxwunix(cmd,,so.,se.,env.)
if so.0 > 0 then
do i = 1 to so.0;say so.i;end
if se.0 > 0 then
do i = 1 to se.0;say se.i;end
end
/* -------------------- *
| Done with everything |
* -------------------- */
say ' '
say 'Completed - z/OS datasets created:'
say ' '
do i = 1 to filec
say zfile.i
end
if enhanced = 0 | zgstat_flag = 1 then do
say ' '
say 'Note that using this installation path does not allow the ISPF'
say 'statistics to be recreated. Other than the missing ISPF statistics'
say 'everything has been successfully installed on z/OS.'
if if enhanced /= 0 then if zgstat_flag = 1 then do
say ' '
say 'One, or more, partitioned datasets (PDS) had both text and binary'
say 'members. This prevented the ISPF statistics from being created'
say 'for that PDS.'
end
say ' '
say 'To recreate the ISPF statistics execute the following command'
say 'after returning to TSO/ISPF:'
say ' '
say 'TSO EX' zgstat_dsn 'EX'
say ' '
say 'After it completes successfully it can be deleted.'
end
Exit
zmsg:
parse arg message
if strip(message) = null then
message = copies('-',63)
say '* 'left(message,63)' *'
return
/* ----------------------------------------------------- */
/* number format code thanks to Doug Nadel */
/* ----------------------------------------------------- */
fix_num: procedure
arg bytes
str=strip(translate('0,123,456,789,abc,def', ,
right(bytes,16,','), ,
'0123456789abcdef'),'L',',')
bytes = strip(str)
return bytes
/* ----------------------------------------------------------------- *
| Allocate the PDS and perform the copy using cp |
| - if the target PDS exists as a PDS, delete and realloc as a PDSE |
| - if the target is a PDSE then it will NOT be reallocated |
| - The target PDS will be allocated as a PDSE version 2. |
| - if maxgen (mgen) is provided then member generations will |
| also be defined at allocation |
| - Uppercase and remove defined extension for members |
* ----------------------------------------------------------------- */
Alloc_Copy_PDS:
pds = "'"ckothlq"."sub"'"
odir = "'"ckotdir"/"sub"/'"
filec = filec + 1
zfile.filec = pds
x = check_file(pds)
if x > 0 then do
call outtrap 'x.'
Address TSO ,
'delete' pds
call outtrap 'off'
end
call get_dcb
if recfm = 'U' then do
type = 'Load module'
end
say 'Copying' odir 'to' pds
if mgen > 0 then gens = 'maxgens('mgen')'
else gens = null
'Alloc new spa('tracks','tracks') recfm('recfm') lrecl('lrecl')' ,
'Blksize('blksize') Dsntype(Library,2) dsorg(po) dir(1)' ,
'dsn('pds')' gens
'Free ds('pds')'
/* ---------------------------------------------------- *
| Read directory to get all member file names and then |
| adjust according and then do individual cp |
* ---------------------------------------------------- */
target = strip(pds,'B',"'")
address syscall
rdir = strip(odir,'B',"'")
rdir = strip(rdir,'T','/')
'readdir' rdir 'mems.'
tcount = mems.0 - 2
mixed = check_mixed_bintext(sub)
if mixed = 0 then do
bin = is_binfile(sub)
if bin = 1 then binopt = '-B'
else binopt = null
if recfm = 'U' then binopt = '-X -I'
if binopt = null then type = 'Text'
else if binopt = '-B' then type = 'Binary'
else if recfm = 'U' then type = 'Load module'
if type = 'Binary' then
zgstat_flag = 1
say 'Copying' tcount 'members as' type
if enhanced = 0 | recfm = 'U' then do
zos = usssafe("//'"target"'")
cmd = 'cp -A -U -v' binopt usssafe(rdir'/*') '"'zos'"'
end
else do
putpds_opts = null
if pos('-B',binopt) > 0 then putpds_opts = '-b'
sp = lastpos('/',rdir,length(rdir)-1)
sfile = substr(rdir,sp+1)
putpds_opts = putpds_opts '-M st='ckotdir'/.zigi/'sfile
zos = usssafe("//"target)
cmd = putpds putpds_opts usssafe(rdir)'/*' zos
end
x = docmd(cmd)
if x > 0 then do
say ' '
say 'Copy command:' cmd
say ' '
say 'Standard messages:'
say ' '
do vs = 1 to so.0;say so.vs;end
say ' '
say 'Error messages:'
say ' '
do vs = 1 to se.0;say se.vs;end
end
end
else do /* mixed text and binary in same PDS */
mcount = 0
do ii = 1 to mems.0
if mems.ii = "." | mems.ii = ".." then do
/* skip the . and .. things */
iterate
end
m = mems.ii /* ignore the translation */
if zdsn.sub /= null then
if right(m,length(zdsn.sub)) = zdsn.sub then do
parse value m with m'.'.
m = translate(m)
end
src = rdir'/'mems.ii
bin = is_binfile(sub'/'mems.ii)
if bin = 1 then binopt = '-B'
else binopt = null
if recfm = 'U' then binopt = '-X -I'
src = usssafe(mems.ii)
if left(src,1) = '#' then src = '\'src
zos = usssafe("//'"target"("m")'")
mcount = mcount + 1
if binopt = null then type = 'Text'
else if binopt = '-B' then type = 'Binary'
else if recfm = 'U' then type = 'Load module'
if type = 'Binary' then
zgstat_flag = 1
say left('Copying' mcount 'of' tcount,24) 'Member:' m 'as' type
cmd = 'cd' usssafe(rdir)
cmd = cmd '&& cp -U -v' binopt src '"'zos'"'
x = docmd(cmd)
if x > 0 then do
say ' '
say 'Standard messages:'
say ' '
do vs = 1 to so.0;say so.vs;end
say ' '
say 'Error messages:'
say ' '
do vs = 1 to se.0;say se.vs;end
end
end
end
return
get_dcb:
if def.sub /= null then do
parse value def.sub with dsorg recfm lrecl blksize .
recfm = left(recfm,1) substr(recfm,2,1) substr(recfm,3,1)
end
else do
recfm = left(def_recfm,1) substr(def_recfm,2,1) substr(def_recfm,3,1)
lrecl = def_lrecl
blksize = def_blksize
end
return
Check_File: Procedure
arg dsn
call outtrap 'x.'
Address TSO 'Listd' dsn
call outtrap 'off'
if x.0 > 3 then return 8
else return 0
/* ---------------------------------------- *
| Check if a PDS has mixed binary and text |
| 0 = not mixed 1 = mixed |
* ---------------------------------------- */
Check_Mixed_BinText:
parse arg checkForBinFile
cmbtRC = 0
if datatype(binfiles.0) /= 'NUM' then return 0
do bi = 1 to binfiles.0
parse value binfiles.bi with cmbtfile'/'cmbtmbr
parse value checkForBinFile with checkFile'/'checkmbr
if cmbtfile = checkFile then
if cmbtmbr = '*' then cmbtRC = 0
else return 1
if binfiles.bi = checkForBinFile then return 1
end
return cmbtRC
usssafe:
parse arg safe_command
safe_ret = 1
if pos('\$',safe_command) > 0 then safe_ret = 0
if pos('\#',safe_command) > 0 then safe_ret = 0
if safe_ret = 0 then return safe_command
if pos('$',safe_command) > 0 then safe_ret = 1
if pos('#',safe_command) > 0 then safe_ret = 1
if safe_ret = 0 then return safe_command
safe$pos = 1
do forever
pos$safe = pos('$',safe_command,safe$pos)
if pos$safe < 1 then leave
left$safe = left(safe_command,pos$safe-1)
right$save = substr(safe_command,pos$safe)
safe_command = left$safe'\'right$save
safe$pos = pos$safe + 2
end
safe$pos = 1
do forever
pos$safe = pos('#',safe_command,safe$pos)
if pos$safe < 1 then return safe_command
left$safe = left(safe_command,pos$safe-1)
right$save = substr(safe_command,pos$safe)
safe_command = left$safe'\'right$save
safe$pos = pos$safe + 2
end
return safe_command
strreplace: Procedure
string = arg(1)
strfrom = arg(2)
strto = arg(3)
null = ''
if pos(strfrom,string) = 0 then return string
newString = null
do i = 1 to length(string)
if substr(string,i,1) /= strfrom
then newstring = newstring''substr(string,i,1)
else newstring = newstring''strto
end
return newstring
get_binfiles:
/* ---------------------------------------------------------\
| Name: binfiles |
| |
| Function: Fills the global binfiles. stem with all |
| current repo files that are added as binary. |
\---------------------------------------------------------- */
cmd = 'cd' ckotdir'/ &&' ,
'cat -W filecodeset=UTF-8' ckotdir'/.gitattributes' ,
' | grep BINARY' ,
'| cut -d" " -f1'
x = docmd(cmd)
if so.0 = 0 then do
binfiles.0 = 0
return 0
end
do b = 1 to so.0
binfiles.b = so.b
end
binfiles.0 = so.0
return 0
is_binfile: procedure expose binfiles.
/* ---------------------------------------------------------\
| Name: is_binfile |
| |
| Function: Checks the global binfiles. stem for the |
| provided dataset or dataset/member |
\---------------------------------------------------------- */
parse arg file
if datatype(binfiles.0) /= 'NUM' then return 0
do bi = 1 to binfiles.0
if right(binfiles.bi,1) = '*' then do
parse value file with test'/'.
if left(binfiles.bi,length(binfiles.bi)-2) = test
then return 1
end
if binfiles.bi = file then return 1
end
return 0
docmd:
parse arg cmd
drop so. se.
x = bpxwunix(cmd,,so.,se.,env.)
return x
ChkIfFile:
/* -------------------------------------------- *
| Check if a file is a regular file |
| rc 0 it is not |
| rc 1 it is |
* -------------------------------------------- */
parse arg _file
Address SYSCALL "lstat" _file "_stat."
if _stat.0 < 1 | _stat.ST_TYPE <> S_ISREG then
return 0
else
return 1
ChkIfDir:
/* -------------------------------------------- *
| Check if a file is a directory |
| rc 0 it is not |
| rc 1 it is |
* -------------------------------------------- */
parse arg _file
Address SYSCALL "lstat" _file "_stat."
if _stat.0 < 1 | _stat.ST_TYPE <> S_ISDIR then
return 0
else
return 1
ChkIfEBC:
/* -------------------------------------------- *
| Check if a file's CCSID is IBM1047 or not |
| rc 0 it is not |
| rc 1 it is |
* -------------------------------------------- */
parse arg _file
Address SYSCALL "lstat" _file "_stat."
if _stat.0 < 1 | _stat.ST_TYPE <> S_ISREG then
return 0
else
if substr(_stat.ST_CCSID, 1, 2) = '0417'X then
return 1
else
return 0
SayErrors:
/* -------------------------------------------- *
| Display STDOUT and STDERR from a command |
| when the command failed for some reason |
* -------------------------------------------- */
parse arg _emsg
say _emsg
say ' '
say 'Standard messages:'
say ' '
do vs = 1 to so.0;say so.vs;end
say ' '
say 'Error messages:'
say ' '
do vs = 1 to se.0;say se.vs;end
return
CvtToEBC:
/* -------------------------------------------- *
| Convert a file to IBM1047 encoding |
| rc 0 it was successfully converted |
| rc <> 0 an error occurred, see output msgs |
* -------------------------------------------- */
parse arg _file
_febc = _file".ebc"
_rc = docmd("/bin/iconv -f ISO8859-1 -t IBM-1047" _file ">" _febc)
if _rc > 0 then do
SayErrors("Conversion of" _file "failed with RC="_rc)
return _rc
end
_rc = docmd("rm -f" _file)
if _rc > 0 then do
SayErrors("Removal of" _file "failed with RC="_rc)
return _rc
end
_rc = docmd("mv" _febc _file)
if _rc > 0 then do
SayErrors("Rename of" _febc "failed with RC="_rc)
return _rc
end
_rc = docmd("chtag -tc IBM1047" _file)
if _rc > 0 then do
SayErrors("Tagging of" _file "failed with RC="_rc)
return _rc
end
return 0
ChkIfGIT:
/* -------------------------------------------- *
| ChkIfGIT to convert unzipped git zip files |
| to IBM-1047 encoding according to the rules |
| listed in the .gitattributes file |
| rc 0 FIles needed and were converted |
| rc 4 FIles do not need conversion |
| rc 8 Files needed to perform the conversion |
| are missing |
| Other rc <> 0 Return code from the |
| conversion process |
* -------------------------------------------- */
/* Get output top directory for conversion */
parse arg outdir
parse value '' with null /* Needed by zmsg */
call zmsg " "
if ChkIfDir(outdir"/.git") = 0 then do
call zmsg "This appears to be a manually unzipped directory"
call zmsg "Checking if all required conversion tools are here"
end
else do
call zmsg "This appears to be a git-created directory"
call zmsg "No encoding conversion is required"
return 4
end
if ChkIfFile(outdir"/.gitattributes") = 0 then do
call zmsg "There is no .gitattributes file in this directory"
call zmsg "Please re-download and rerun"
return 8
end
if ChkIfFile(outdir"/zgcvtenc.awk") = 0 then do
call zmsg "Conversion script zgcvtenc.awk not found"
call zmsg "Please re-download and rerun"
return 8
end
if ChkIfEBC(outdir"/zgcvtenc.awk") = 1 then do
call zmsg "Files appear to already have been converted to EBCDIC"
call zmsg "Please continue with the normal installation procedure"
return 4
end
call zmsg " "
call zmsg "Conversion tools and files seem to all be present"
call zmsg "Files in this unzipped directory will be converted"
call zmsg "as specified by the rules in the .gitattributes file"
call zmsg " "
/* Save the current Address mode */
saveAddr = address()
/* Switch to SHell mode for necessary tasks */
Address SH
/* Remove output files for the zgcvtenc process */
rmlist = outdir"/zgcvtenc.err" outdir"/zgcvtenc.log"
rmlist = rmlist outdir"/zgcvtenc.lst" outdir"/zgcvtenc.dbglog"
rmlist = rmlist outdir"/.gitattributes.ebc"
"rm -f" rmlist
/* Create list of files for script zgcvtenc.awk to process */
"ls -RFA1 >" outdir"/zgcvtenc.lst"
/* POSIX awk requires scripts to be encoded in EBCDIC */
rc = CvtToEBC(outdir"/zgcvtenc.awk")
/* -------------------------------------------------------- *
| The script zgcvtenc.awk requires file .gitattributes.ebc |
| to be a copy of .gitattributes encoded as IBM-1047 text |
| The original ASCII .gitattributes file is not changed |
* -------------------------------------------------------- */
"cp" outdir"/.gitattributes" outdir"/.gitattributes.ebc"
rc = CvtToEBC(outdir"/.gitattributes.ebc")
/* Must add a final pattern to .gitattributes to ignore *ccsid* files */
"echo ""*cvtenc* binary"" >>" outdir"/.gitattributes.ebc"
/* The script zgcvtenc.awk requires environment variable PWD */
nextenvc = env.0 + 1
env.nextenvc = "PWD="outdir
env.0 = nextenvc
/* Now we are ready to run the conversion process */
rc = docmd("awk -f" outdir"/zgcvtenc.awk" outdir"/zgcvtenc.lst >" ,
outdir"/zgcvtenc.log 2>" outdir"/zgcvtenc.err")
call zmsg "Return code from conversion process is" rc
call zmsg " "
/* Restore original Address and environment settings*/
Address value saveAddr
env.nextenvc = ""
env.0 = nextenvc - 1
/* Exit with return code from conversion process */
return rc
/*
>ZGSTAT *** Inline ZGSTAT that will be updated and uploaded */
/*--------------------- rexx procedure -------------------- *
| Name: ZGSTAT |
| |
| Function: To work with the ZIGI Generic Installation |
| tool to add the ISPF statistics to the ZIGI |
| managed partitioned datasets after they have |
| been created by the ZGINSTALL. |
| |
| Syntax: ex zgstat ex |
| |
| Dependencies: Uses a modified copy of the ZIGI zigistat |
| exec |
| |
| Author: Lionel B. Dyck |
| |
| History: (most recent on top) |
| 06/11/20 LBD - Put inline in zginstall.rex |
| 06/10/20 LBD - Usability enhancements |
| 06/09/20 LBD - Creation |
| |
| ---------------------------------------------------------- |
| ZIGI - the z/OS ISPF Git Interface |
| Copyright (C) 2020 - Henri Kuiper and Lionel Dyck |
| |
| This program is free software: you can redistribute it |
| and/or modify it under the terms of the GNU General |
| Public License as published by the Free Software |
| Foundation, either version 3 of the License, or (at |
| your option) any later version. |
| |
| This program is distributed in the hope that it will be |
| useful, but WITHOUT ANY WARRANTY; without even the |
| implied warranty of MERCHANTABILITY or FITNESS FOR A |
| PARTICULAR PURPOSE. See the GNU General Public License |
| for more details. |
| |
| You should have received a copy of the GNU General |
| Public License along with this program. If not, see |
| <https://www.gnu.org/licenses/>. |
* ---------------------------------------------------------- */
/* ------------------------------*
| Check to see if we're in ISPF |
* ----------------------------- */
parse source . . . . s5 . . s8 .
if s8 /= 'ISPF' then do
say s5 'must be run under ISPF'
exit 8
end /* if s8 */
/* ------------------------------------------------ *
| These variables will be updated by zginstall.rex |
* ------------------------------------------------ */
repodir = '$$$$$$'
hlq = '$$$$$$'
Address ISPExec
load_info = loadispf()
address syscall ,
'readdir' repodir 'files.'
if files.0 = 0 then do
zedsmsg = 'Error'
zedlmsg = 'The directory specified is not the correct directory.'
'setmsg msg(isrz001)'
exit 8
end
do if = 1 to files.0
file = files.if
if left(file,1) = '.' then iterate
/* check for lower case so ignore these */
fx = translate(file,'??????????????????????????', ,
'abcdefghijklmnopqrstuvwxyz')
if pos('?',fx) > 0 then iterate
dsname = "'"hlq"."file"'"
x = listdsi(dsname)