2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
11 ##############################################################################
14 new_tag = new_reltag # new release tag
15 curr_tag = curr_reltag # current release tag
16 prev_tag = prev_reltag # previous release tag
18 new_release = tolower(new_tag)
19 curr_release = tolower(curr_tag)
20 prev_release = tolower(prev_tag)
22 ws = "[\\t ]*" # white-spaces
23 startpat = "^" ws "- project:" # start pattern
24 endpat = startpat # end pattern
25 op = "^" ws "---" ws "$" # match files starts with "---"
27 next_release_tag = "^" ws "next-release-tag: '{stream}'"
29 new_branch = "'stable/" new_release "'"
30 curr_branch = "'stable/" curr_release "'"
31 prev_branch = "'stable/" prev_release "'"
33 # replace block to add new release
34 new_rel_yaml_tag = "- " new_release ":";
35 br_master_yaml_tag = " branch: 'master'";
36 jre_yaml_tag = " jre: 'openjdk8'";
37 curr_rel_yaml_tag = "- " curr_release ":";
38 br_stable_curr_yaml_tag = " branch: 'stable/" curr_release "'";
40 # replace block for autorelease-projects
41 #new_rel_yaml_tag = "- " new_release ":";
42 next_rel_tag_new_yaml_tag = " next-release-tag: '{stream}'";
43 #br_master_yaml_tag = " branch: 'master'";
44 jdk_yaml_tag = " jdk: 'openjdk8'";
45 intg_test_yaml_tag = " integration-test: " new_release;
46 extra_mvn_opts_tag = " extra-mvn-opts: -Dsft.heap.max=4g"
47 #curr_rel_yaml_tag = "- " curr_release ":";
48 next_rel_tag_curr_yaml_tag = " next-release-tag: '{stream}'";
49 #br_stable_curr_yaml_tag = " branch: 'stable/" curr_release "'";
52 smaster = "^" ws "- master:"
53 sstream = "^" ws "stream:"
54 srelease = "^" ws "- " curr_release ":"
55 snext_release_tag = "^" ws "next-release-tag:"
56 #if (l ~ next_release_tag) { next_release_tag = 1; continue; }
57 sbranch = "^" ws "branch: " master
58 sfunctionality = "^" ws "functionality:"
60 debug = 0 # set to 1 to print debug info
61 file_format = 2 # project stream format
70 # exit if release info is not available
71 if ((length(new_release) == 0 || length(curr_release) == 0)) {
75 # read all lines of the file into an array
80 n = NR # total number of lines
81 find_blks() # gets number of blocks between start/end pattern
82 process_blk(arr_bs[1], arr_be[1], 1) # pass start and end of each block and process first block
83 update_file(arr_be[1]) # write processed content
86 print "number of blocks="nb;
87 print "total records in file[]="length(f);
88 print "size of firstblk[]="length(firstblk);
89 print "size of newblk[]="length(newblk);
90 print "size of oldmaster[]="length(oldmaster);
91 print "size of newblk[]="length(newblk);
95 function find_blks( i, l, bs, be) {
96 for (i = 1; i <= n; i++) {
98 if (l ~ startpat) project = 1 # start pattern
99 if (bs > be && l ~ endpat) arr_be[++be] = i - 1 # block end
100 if ( l ~ startpat) arr_bs[++bs] = i - 1 # block start
104 # to handle files with single blocks
105 if (nb == 0 && length(file) > 1 && project == 1) {
107 arr_bs[1] = 1 # start after line '---'
108 arr_be[1] = length(file) # set length of the file
112 for (i = 1; i < nb; i++)
113 print "find_blks: nb=" nb " arr_bs[" i "]="arr_bs[i]" arr_be[" i "]="arr_be[i];
117 function process_blk(bs, be, bn, i, l) {
119 print "process_blk: bn=" bn ", bs=" bs " ,be=" be
122 # get the first block
123 for (i = bs + 1; i <= be ; i++) {
125 # determine file format
128 s = substr(l, x+2, length(l) - x)
129 if (s == curr_release || s == new_release) {
131 } else if (length(s) == 0 ) {
139 print "process_blk: stream='" s "' length(s)=" length(s)" file_format='" file_format "'"
142 # Handle single stream format
143 if (file_format == 1) {
144 # create new block to be inserted
145 for (i = 1; i <= length(firstblk); i++) {
147 if (l ~ /name:|stream:/) sub(curr_release, new_release, l)
150 # re-create old block and change master to stable/branch
151 for (i = 1; i <= length(firstblk)-1; i++) {
153 if (l ~ /branch:/) sub(master, curr_branch, l)
154 oldmaster[++nex2] = l
156 } else if (file_format == 0) {
157 # Handle multi-stream format
158 for (i = 1; i <= length(firstblk)-1; i++) {
160 if (l ~ sstream) { stream_found = 1; }
161 if (l ~ srelease) { release_found = 1; indent = substr(l, 1, index(l, "-")-1); continue; }
162 if (l ~ sfunctionality) { func_found = 1; }
163 if (l ~ snext_release_tag) { nrt_found = 1; }
166 if (stream_found && release_found && !nrt_found) {
167 newblk[++nex3] = indent new_rel_yaml_tag;
168 newblk[++nex3] = indent br_master_yaml_tag;
169 newblk[++nex3] = indent curr_rel_yaml_tag;
170 newblk[++nex3] = indent br_stable_curr_yaml_tag;
176 if (stream_found && release_found && nrt_found) {
177 newblk[++nex3] = indent new_rel_yaml_tag;
178 newblk[++nex3] = indent next_rel_tag_new_yaml_tag;
179 newblk[++nex3] = indent br_master_yaml_tag;
180 newblk[++nex3] = indent intg_test_yaml_tag;
181 newblk[++nex3] = indent extra_mvn_opts_tag;
182 newblk[++nex3] = indent curr_rel_yaml_tag;
183 newblk[++nex3] = indent next_rel_tag_curr_yaml_tag;
184 newblk[++nex3] = indent br_stable_curr_yaml_tag;
185 stream_found = 0; release_found = 0; nrt_found=0;
192 print "process_blk: append(newblk[]) : stream="stream" release_found="release_found
196 # exit on unknown file format
201 function update_file(be, i, j, l) {
203 # handle lines before "---"
210 print "writing master block"
213 # Handle single stream format
214 if (file_format == 1) {
215 for (j = 1; j <= nex1; j++) # write new branch block
219 print "writing stable block"
222 for (j = 1; j <= nex2; j++) # write updated branch block
225 # Handle multi-stream format
226 } else if (file_format == 0) {
227 # print the first block
228 for (j = 1; j <= nex3; j++) # write multi-stream block
233 print "writing rest of the file"
236 while (be <= n) { # write rest of the file